forked from sysofwan/ha-triones
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
25 lines (20 loc) · 911 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.const import CONF_MAC
from .const import DOMAIN
from .triones import TrionesInstance
PLATFORMS = ["light"]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Triones from a config entry."""
instance = TrionesInstance(entry.data[CONF_MAC])
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = instance
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
instance = hass.data[DOMAIN].pop(entry.entry_id)
await instance.disconnect()
return unload_ok