def setup(hass, yaml_config): """Activate the emulated_hue component.""" config = Config(yaml_config) server = HomeAssistantWSGI(hass, development=False, server_host=config.host_ip_addr, server_port=config.listen_port, api_password=None, ssl_certificate=None, ssl_key=None, cors_origins=[]) server.register_view(DescriptionXmlView(hass, config)) server.register_view(HueUsernameView(hass)) server.register_view(HueLightsView(hass, config)) upnp_listener = UPNPResponderThread(config.host_ip_addr, config.listen_port) def start_emulated_hue_bridge(event): """Start the emulated hue bridge.""" server.start() upnp_listener.start() hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_emulated_hue_bridge) def stop_emulated_hue_bridge(event): """Stop the emulated hue bridge.""" upnp_listener.stop() server.stop() hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_emulated_hue_bridge) return True
def setup(hass, yaml_config): """Activate the emulated_hue component.""" config = Config(yaml_config) server = HomeAssistantWSGI( hass, development=False, server_host=config.host_ip_addr, server_port=config.listen_port, api_password=None, ssl_certificate=None, ssl_key=None, cors_origins=[], use_x_forwarded_for=False, trusted_networks=[] ) server.register_view(DescriptionXmlView(hass, config)) server.register_view(HueUsernameView(hass)) server.register_view(HueLightsView(hass, config)) upnp_listener = UPNPResponderThread( config.host_ip_addr, config.listen_port) @asyncio.coroutine def stop_emulated_hue_bridge(event): """Stop the emulated hue bridge.""" upnp_listener.stop() yield from server.stop() @asyncio.coroutine def start_emulated_hue_bridge(event): """Start the emulated hue bridge.""" upnp_listener.start() hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_emulated_hue_bridge) yield from server.start() hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_emulated_hue_bridge) return True
def setup(hass, yaml_config): """Activate the emulated_hue component.""" config = Config(hass, yaml_config.get(DOMAIN, {})) server = HomeAssistantWSGI(hass, development=False, server_host=config.host_ip_addr, server_port=config.listen_port, api_password=None, ssl_certificate=None, ssl_key=None, cors_origins=None, use_x_forwarded_for=False, trusted_networks=[], login_threshold=0, is_ban_enabled=False) server.register_view(DescriptionXmlView(config)) server.register_view(HueUsernameView) server.register_view(HueAllLightsStateView(config)) server.register_view(HueOneLightStateView(config)) server.register_view(HueOneLightChangeView(config)) upnp_listener = UPNPResponderThread(config.host_ip_addr, config.listen_port, config.upnp_bind_multicast, config.advertise_ip, config.advertise_port) @asyncio.coroutine def stop_emulated_hue_bridge(event): """Stop the emulated hue bridge.""" upnp_listener.stop() yield from server.stop() @asyncio.coroutine def start_emulated_hue_bridge(event): """Start the emulated hue bridge.""" upnp_listener.start() yield from server.start() hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_emulated_hue_bridge) hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_emulated_hue_bridge) return True
def setup(hass, yaml_config): """Activate the emulated_hue component.""" config = Config(hass, yaml_config.get(DOMAIN, {})) server = HomeAssistantWSGI( hass, server_host=config.host_ip_addr, server_port=config.listen_port, api_password=None, ssl_certificate=None, ssl_key=None, cors_origins=None, use_x_forwarded_for=False, trusted_networks=[], login_threshold=0, is_ban_enabled=False ) server.register_view(DescriptionXmlView(config)) server.register_view(HueUsernameView) server.register_view(HueAllLightsStateView(config)) server.register_view(HueOneLightStateView(config)) server.register_view(HueOneLightChangeView(config)) upnp_listener = UPNPResponderThread( config.host_ip_addr, config.listen_port, config.upnp_bind_multicast, config.advertise_ip, config.advertise_port) @asyncio.coroutine def stop_emulated_hue_bridge(event): """Stop the emulated hue bridge.""" upnp_listener.stop() yield from server.stop() @asyncio.coroutine def start_emulated_hue_bridge(event): """Start the emulated hue bridge.""" upnp_listener.start() yield from server.start() hass.bus.async_listen_once( EVENT_HOMEASSISTANT_STOP, stop_emulated_hue_bridge) hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_emulated_hue_bridge) return True
def setup(hass, config): """Activate the emulated_hue component.""" hue_list = [] for hue_name, conf in config[DOMAIN].items(): _LOGGER.info("emulated hue {}".format(hue_name)) config = Config(hass, conf, hue_name) server = HomeAssistantWSGI(hass, server_host=config.host_ip_addr, server_port=config.listen_port, api_password=None, ssl_certificate=None, ssl_key=None, cors_origins=None, use_x_forwarded_for=False, trusted_networks=[], login_threshold=0, is_ban_enabled=False) server.register_view(DescriptionXmlView(config)) server.register_view(HueUsernameView) server.register_view(HueAllLightsStateView(config)) server.register_view(HueOneLightStateView(config)) server.register_view(HueOneLightChangeView(config)) upnp_listener = UPNPResponderThread(config.host_ip_addr, config.listen_port, config.upnp_bind_multicast, config.advertise_ip, config.advertise_port, config.target_ip) hue_data = { 'config': config, 'server': server, 'upnp_listener': upnp_listener } hue_list.append(hue_data) @asyncio.coroutine def stop_emulated_hue_bridge(event): """Stop the emulated hue bridge.""" for hue_data in hue_list: hue_data['upnp_listener'].stop() yield from hue_data['server'].stop() @asyncio.coroutine def start_emulated_hue_bridge(event): """Start the emulated hue bridge.""" for hue_data in hue_list: hue_data['upnp_listener'].start() yield from hue_data['server'].start() hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_emulated_hue_bridge) hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_emulated_hue_bridge) return True