forked from mochman/recteq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
61 lines (46 loc) · 1.44 KB
/
__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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""The Recteq integration."""
import asyncio
import logging
import async_timeout
from .const import (
DOMAIN,
ISSUE_LINK,
PLATFORMS,
PROJECT,
VERSION,
)
from .device import RecteqDevice
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
from homeassistant.exceptions import ConfigEntryNotReady
from integrationhelper.const import CC_STARTUP_VERSION
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistant, config):
hass.data[DOMAIN] = {}
_LOGGER.info(CC_STARTUP_VERSION.format(
name=PROJECT,
version=VERSION,
issue_link=ISSUE_LINK
))
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
hass.data[DOMAIN][entry.entry_id] = RecteqDevice(hass, entry)
for platform in PLATFORMS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform)
)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, PLATFORM)
for PLATFORM in PLATFORMS
]
)
)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok