Skip to content
Merged
11 changes: 8 additions & 3 deletions homeassistant/components/velux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_HOST, CONF_PASSWORD
from homeassistant.const import (CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP)

DOMAIN = "velux"
DATA_VELUX = "data_velux"
Expand Down Expand Up @@ -40,14 +40,19 @@ async def async_setup(hass, config):
)
return True


class VeluxModule:
"""Abstraction for velux component."""

def __init__(self, hass, config):
"""Initialize for velux component."""

Comment thread
MartinHjelmare marked this conversation as resolved.
Outdated
async def on_hass_stop(event):
"""Close connection when hass stops."""
_LOGGER.info("velux interface terminated")
Comment thread
MartinHjelmare marked this conversation as resolved.
Outdated
await self.pyvlx.disconnect()

hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
Comment thread
MartinHjelmare marked this conversation as resolved.
Outdated
from pyvlx import PyVLX
Comment thread
MartinHjelmare marked this conversation as resolved.
Outdated

host = config[DOMAIN].get(CONF_HOST)
password = config[DOMAIN].get(CONF_PASSWORD)
self.pyvlx = PyVLX(host=host, password=password)
Expand Down