1 """Support for VELUX KLF 200 devices."""
3 from pyvlx
import PyVLX, PyVLXException
9 from .const
import DOMAIN, LOGGER, PLATFORMS
13 """Set up the velux component."""
17 await module.async_start()
19 except PyVLXException
as ex:
20 LOGGER.exception(
"Can't connect to velux interface: %s", ex)
23 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = module
25 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
31 """Unload a config entry."""
32 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
36 """Abstraction for velux component."""
39 """Initialize for velux component."""
45 """Velux component setup."""
47 async
def on_hass_stop(event):
48 """Close connection when hass stops."""
49 LOGGER.debug(
"Velux interface terminated")
50 await self.
pyvlxpyvlx.disconnect()
52 async
def async_reboot_gateway(service_call: ServiceCall) ->
None:
53 await self.
pyvlxpyvlx.reboot_gateway()
55 self.
_hass_hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
58 self.
pyvlxpyvlx = PyVLX(host=host, password=password)
60 self.
_hass_hass.services.async_register(
61 DOMAIN,
"reboot_gateway", async_reboot_gateway
65 """Start velux component."""
66 LOGGER.debug(
"Velux interface started")
67 await self.
pyvlxpyvlx.load_scenes()
68 await self.
pyvlxpyvlx.load_nodes()
def __init__(self, hass, domain_config)
web.Response get(self, web.Request request, str config_key)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)