当前位置: 首页>>代码示例>>Python>>正文


Python const.CONF_HOST属性代码示例

本文整理汇总了Python中homeassistant.const.CONF_HOST属性的典型用法代码示例。如果您正苦于以下问题:Python const.CONF_HOST属性的具体用法?Python const.CONF_HOST怎么用?Python const.CONF_HOST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在homeassistant.const的用法示例。


在下文中一共展示了const.CONF_HOST属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Awesome Light platform."""
    # Assign configuration variables.
    # The configuration check takes care they are present.
    host = config[CONF_HOST]
    username = config[CONF_USERNAME]
    password = config.get(CONF_PASSWORD)

    # Setup connection with devices/cloud
    hub = awesomelights.Hub(host, username, password)

    # Verify that passed in configuration works
    if not hub.is_valid_login():
        _LOGGER.error("Could not connect to AwesomeLight hub")
        return

    # Add devices
    add_entities(AwesomeLight(light) for light in hub.lights()) 
开发者ID:home-assistant,项目名称:example-custom-config,代码行数:20,代码来源:light.py

示例2: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Configure the platform."""
    if discovery_info is None:
        return
    bridge = Caseta(discovery_info[CONF_HOST])
    await bridge.open()

    data = CasetaData(bridge)
    devices = [
        CasetaSwitch(switch, data, discovery_info[CONF_MAC])
        for switch in discovery_info[CONF_DEVICES]
    ]
    data.set_devices(devices)

    async_add_devices(devices, True)

    # register callbacks
    bridge.register(data.read_output)

    # start bridge main loop
    bridge.start(hass) 
开发者ID:upsert,项目名称:lutron-caseta-pro,代码行数:23,代码来源:switch.py

示例3: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Configure the platform."""
    if discovery_info is None:
        return
    bridge = Caseta(discovery_info[CONF_HOST])
    await bridge.open()

    data = CasetaData(bridge, hass)
    devices = [
        CasetaCover(cover, data, discovery_info[CONF_MAC])
        for cover in discovery_info[CONF_DEVICES]
    ]
    data.set_devices(devices)

    async_add_devices(devices)

    # register callbacks
    bridge.register(data.read_output)

    # start bridge main loop
    bridge.start(hass) 
开发者ID:upsert,项目名称:lutron-caseta-pro,代码行数:23,代码来源:cover.py

示例4: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Configure the platform."""
    if discovery_info is None:
        return
    bridge = Caseta(discovery_info[CONF_HOST])
    yield from bridge.open()

    data = CasetaData(bridge)
    devices = [
        CasetaFan(fan, data, discovery_info[CONF_MAC])
        for fan in discovery_info[CONF_DEVICES]
    ]
    data.set_devices(devices)

    async_add_devices(devices, True)

    # register callbacks
    bridge.register(data.read_output)

    # start bridge main loop
    bridge.start(hass) 
开发者ID:upsert,项目名称:lutron-caseta-pro,代码行数:23,代码来源:fan.py

示例5: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Configure the platform."""
    if discovery_info is None:
        return
    bridge = Caseta(discovery_info[CONF_HOST])
    await bridge.open()

    data = CasetaData(bridge, hass)
    devices = [
        CasetaScene(scene, data, discovery_info[CONF_MAC])
        for scene in discovery_info[CONF_DEVICES]
    ]
    data.set_devices(devices)

    async_add_devices(devices)

    # register callbacks
    bridge.register(data.read_output)

    # start bridge main loop
    bridge.start(hass) 
开发者ID:upsert,项目名称:lutron-caseta-pro,代码行数:23,代码来源:scene.py

示例6: async_setup

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup(hass, config):
    """Initialize the component and loads the integration report."""
    if CONF_BRIDGES in config[DOMAIN]:
        for bridge in config[DOMAIN][CONF_BRIDGES]:
            host = bridge[CONF_HOST]
            # get the file name for the JSON integration report
            fname = get_config_file(hass, host)

            # check if the file exists
            if not os.path.exists(fname) or not os.path.isfile(fname):
                _LOGGER.info(
                    "Integration Report for host %s not found at location %s",
                    host,
                    fname,
                )
                hass.async_add_job(request_configuration, hass, config, host, bridge)
            else:
                _LOGGER.debug("Loading Integration Report %s", fname)
                await async_setup_bridge(hass, config, fname, bridge)

    return True 
开发者ID:upsert,项目名称:lutron-caseta-pro,代码行数:23,代码来源:__init__.py

示例7: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Configure the platform."""
    if discovery_info is None:
        return
    bridge = Caseta(discovery_info[CONF_HOST])
    await bridge.open()

    data = CasetaData(bridge, hass)
    devices = [
        CasetaPicoRemote(pico, data, discovery_info[CONF_MAC])
        for pico in discovery_info[CONF_DEVICES]
    ]
    data.set_devices(devices)

    async_add_devices(devices)

    # register callbacks
    bridge.register(data.read_output)

    # start bridge main loop
    bridge.start(hass)


# pylint: disable=too-many-instance-attributes 
开发者ID:upsert,项目名称:lutron-caseta-pro,代码行数:26,代码来源:sensor.py

示例8: __init__

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def __init__(self, hass, conf, name):
        from pytz import timezone
        self._name = name
        self.conf_dir = str(hass.config.path()) + '/'
        self._dir = conf.get(CONF_IMG_CACHE)
        if self._name:
            self._dir = self._dir + self._name.replace(' ', '_') + '/'
        self.img = '{0}{1}{2}{3}{4}.jpg'.format(
            self.conf_dir, {}, self._dir, {}, {})
        self.img_url = '{0}{1}{2}{3}.jpg'.format({}, self._dir, {}, {})
        self._tz = timezone(str(hass.config.time_zone))
        self.cert = conf.get(CONF_SSL_CERT)
        self.ssl = 's' if conf.get(CONF_SSL) or self.cert else ''
        self.token = conf.get(CONF_TOKEN)
        self.server_name = conf.get(CONF_SERVER)
        self.max_items = int(conf.get(CONF_MAX))
        self.dl_images = conf.get(CONF_DL_IMAGES)
        self.on_deck = conf.get(CONF_ON_DECK)
        self.sections = conf.get(CONF_SECTION_TYPES)
        self.excludes = conf.get(CONF_EXCLUDE_KEYWORDS)
        self.resolution = conf.get(CONF_RESOLUTION)
        if self.server_name:
            _LOGGER.warning(
                "Plex Recently Added: The server_name option has been removed. Use host and port options instead.")
            return
        else:
            self.server_ip = conf.get(CONF_HOST)
            self.local_ip = conf.get(CONF_HOST)
            self.port = conf.get(CONF_PORT)
        self.url_elements = [self.ssl, self.server_ip, self.local_ip,
                             self.port, self.token, self.cert, self.dl_images]
        self.change_detected = False
        self._state = None
        self.card_json = []
        self.api_json = []
        self.data = [{1}] 
开发者ID:custom-components,项目名称:sensor.plex_recently_added,代码行数:38,代码来源:sensor.py

示例9: async_setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the Sonoff LAN Mode Switch platform."""
    host = config.get(CONF_HOST)
    name = config.get(CONF_NAME)
    icon = config.get(CONF_ICON)

    async_add_entities([HassSonoffSwitch(hass, host, name, icon)], True) 
开发者ID:beveradb,项目名称:sonoff-lan-mode-homeassistant,代码行数:10,代码来源:switch.py

示例10: validate_input

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def validate_input(hass, data):
    """Validate the user input allows us to connect.

    Data has the keys from DATA_SCHEMA with values provided by the user.
    """

    try:
        wiser = await hass.async_add_executor_job(
            wiserHub, data[CONF_HOST], data[CONF_PASSWORD]
        )
        wiser_id = await hass.async_add_executor_job(wiser.getWiserHubName)

    except WiserHubTimeoutException:
        raise CannotConnect
    except WiserHubAuthenticationException:
        raise InvalidAuth
    except WiserRESTException:
        raise UnknownError
    except requests.exceptions.ConnectionError:
        raise CannotConnect
    except RuntimeError:
        raise UnknownError

    unique_id = str(f"{DOMAIN}-{wiser_id}")
    name = wiser_id

    return {"title": name, "unique_id": unique_id} 
开发者ID:asantaga,项目名称:wiserHomeAssistantPlatform,代码行数:29,代码来源:config_flow.py

示例11: setup_platform

# 需要导入模块: from homeassistant import const [as 别名]
# 或者: from homeassistant.const import CONF_HOST [as 别名]
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
    """Setup the demo switches."""
    host = config.get(CONF_HOST)
    mode =  config.get(CONF_MODE)
    prefix = config.get(CONF_PREFIX)
    if host == None:
        _Log.error('pls enter host ip address!')
        return False

    # def SendControlCommand(call):
    #     code = call.data.get('code')
    #     _Log.info(code)
    #     hass.states.set('WuKong.Send_Control_Command', code)

    service = WuKongService(hass,host,mode)


    hass.services.register(DOMAIN, 'Send_Control_Command', service.SendControlCommand)
    hass.services.register(DOMAIN, 'Send_Open_Command', service.SendOpenCommand)
    hass.services.register(DOMAIN, 'Send_Install_Command', service.SendInstallCommand)
    hass.services.register(DOMAIN, 'Send_Clean_Command', service.SendCleanCommand)
    hass.services.register(DOMAIN, 'Send_Command_Queue', service.SendCommandQueue)
    hass.services.register(DOMAIN, 'Send_Connect_Command', service.SendConnectCommand)


    add_devices_callback([
        WuKongSwitch(hass, host, prefix, 'tv_ctl_up', False, 'mdi:arrow-up-bold-circle', True, mode,19),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_down', False, 'mdi:arrow-down-bold-circle', True, mode,20),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_left', False, 'mdi:arrow-left-bold-circle', True, mode,21),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_right', False, 'mdi:arrow-right-bold-circle', True, mode,22),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_home', False, 'mdi:home', True, mode,3),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_back', False, 'mdi:backup-restore', True, mode,4),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_ok', False, 'mdi:adjust', True, mode,23),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_volup', False, 'mdi:volume-high', True, mode,24),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_voldown', False, 'mdi:volume-medium', True, mode,25),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_power', False, 'mdi:power', True, mode, 26),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_menu', False, 'mdi:menu', True, mode, 82),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_1', False, 'mdi:numeric-1-box', True, mode,8),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_2', False, 'mdi:numeric-2-box', True, mode,9),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_3', False, 'mdi:numeric-3-box', True, mode,10),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_4', False, 'mdi:numeric-4-box', True, mode,11),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_5', False, 'mdi:numeric-5-box', True, mode,12),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_6', False, 'mdi:numeric-6-box', True, mode,13),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_7', False, 'mdi:numeric-7-box', True, mode,14),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_8', False, 'mdi:numeric-8-box', True, mode,15),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_9', False, 'mdi:numeric-9-box', True, mode,16),
        WuKongSwitch(hass, host, prefix, 'tv_ctl_0', False, 'mdi:numeric-0-box', True, mode,7),

        WuKongSwitch(hass, host, prefix, 'tv_ctl_clean', False, 'mdi:notification-clear-all', True, mode,999),
    ]) 
开发者ID:charleyzhu,项目名称:HomeAssistant_Components,代码行数:52,代码来源:WuKong.py


注:本文中的homeassistant.const.CONF_HOST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。