Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """Support to embed Foo."""
- from homeassistant import config_entries
- from homeassistant.helpers import config_entry_flow
- DOMAIN = 'foo'
- async def async_setup(hass, config):
- """Set up the Foo component."""
- conf = config.get(DOMAIN)
- hass.data[DOMAIN] = conf or {}
- if conf is not None:
- hass.async_create_task(hass.config_entries.flow.async_init(
- DOMAIN, context={'source': config_entries.SOURCE_IMPORT}))
- return True
- async def async_setup_entry(hass, entry):
- """Set up Foo from a config entry."""
- hass.async_create_task(hass.config_entries.async_forward_entry_setup(
- entry, 'switch'))
- return True
- async def _async_has_devices(hass):
- """Return if there are devices that can be discovered."""
- def discover():
- return [{'name': 'super_switch', 'host': '1.1.1.1', 'uid': '42'}]
- return await hass.async_add_executor_job(discover)
- config_entry_flow.register_discovery_flow(
- DOMAIN, 'Foo', _async_has_devices, config_entries.CONN_CLASS_LOCAL_PUSH)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement