Python homeassistant.const.CONF_HOST Examples

The following are 11 code examples of homeassistant.const.CONF_HOST(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module homeassistant.const , or try the search function .
Example #1
Source File: light.py    From example-custom-config with Apache License 2.0 6 votes vote down vote up
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()) 
Example #2
Source File: switch.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: cover.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
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) 
Example #4
Source File: fan.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
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) 
Example #5
Source File: scene.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
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) 
Example #6
Source File: __init__.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
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 
Example #7
Source File: sensor.py    From lutron-caseta-pro with Apache License 2.0 6 votes vote down vote up
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 
Example #8
Source File: sensor.py    From sensor.plex_recently_added with Apache License 2.0 5 votes vote down vote up
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}] 
Example #9
Source File: switch.py    From sonoff-lan-mode-homeassistant with MIT License 5 votes vote down vote up
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) 
Example #10
Source File: config_flow.py    From wiserHomeAssistantPlatform with MIT License 5 votes vote down vote up
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} 
Example #11
Source File: WuKong.py    From HomeAssistant_Components with Apache License 2.0 4 votes vote down vote up
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),
    ])