def setup(hass, config): """ Sets up the Wink component. """ logger = logging.getLogger(__name__) if not validate_config(config, {DOMAIN: [CONF_ACCESS_TOKEN]}, logger): return False pywink.set_bearer_token(config[DOMAIN][CONF_ACCESS_TOKEN]) # Load components for the devices in the Wink that we support for component_name, func_exists, discovery_type in (('light', pywink.get_bulbs, DISCOVER_LIGHTS), ('switch', pywink.get_switches, DISCOVER_SWITCHES), ('sensor', pywink.get_sensors, DISCOVER_SENSORS)): if func_exists(): component = get_component(component_name) # Ensure component is loaded if component.DOMAIN not in hass.components: bootstrap.setup_component(hass, component.DOMAIN, config) # Fire discovery event hass.bus.fire(EVENT_PLATFORM_DISCOVERED, { ATTR_SERVICE: discovery_type, ATTR_DISCOVERED: {} }) return True
def setup(hass, config): """ Sets up the Wink component. """ logger = logging.getLogger(__name__) if not validate_config(config, {DOMAIN: [CONF_ACCESS_TOKEN]}, logger): return False pywink.set_bearer_token(config[DOMAIN][CONF_ACCESS_TOKEN]) # Load components for the devices in the Wink that we support for component_name, func_exists, discovery_type in ( ('light', pywink.get_bulbs, DISCOVER_LIGHTS), ('switch', pywink.get_switches, DISCOVER_SWITCHES), ('sensor', pywink.get_sensors, DISCOVER_SENSORS)): if func_exists(): component = get_component(component_name) # Ensure component is loaded bootstrap.setup_component(hass, component.DOMAIN, config) # Fire discovery event hass.bus.fire(EVENT_PLATFORM_DISCOVERED, { ATTR_SERVICE: discovery_type, ATTR_DISCOVERED: {} }) return True
def get_devices(hass, config): """ Find and return Wink switches. """ token = config.get(CONF_ACCESS_TOKEN) if token is None: logging.getLogger(__name__).error( "Missing wink access_token - " "get one at https://winkbearertoken.appspot.com/") return [] pywink.set_bearer_token(token) return get_switches()
def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the Wink platform. """ if discovery_info is None: token = config.get(CONF_ACCESS_TOKEN) if token is None: logging.getLogger(__name__).error( "Missing wink access_token - " "get one at https://winkbearertoken.appspot.com/") return pywink.set_bearer_token(token) add_devices(WinkSensorDevice(sensor) for sensor in pywink.get_sensors())
def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Find and return Wink lights. """ token = config.get(CONF_ACCESS_TOKEN) if not pywink.is_token_set() and token is None: logging.getLogger(__name__).error( "Missing wink access_token - " "get one at https://winkbearertoken.appspot.com/") return elif token is not None: pywink.set_bearer_token(token) add_devices_callback(WinkLight(light) for light in pywink.get_bulbs())
def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Find and return Wink lights. """ token = config.get(CONF_ACCESS_TOKEN) if not pywink.is_token_set() and token is None: logging.getLogger(__name__).error( "Missing wink access_token - " "get one at https://winkbearertoken.appspot.com/") return elif token is not None: pywink.set_bearer_token(token) add_devices_callback( WinkLight(light) for light in pywink.get_bulbs())