forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
48 lines (32 loc) · 1.44 KB
/
Copy path__init__.py
File metadata and controls
48 lines (32 loc) · 1.44 KB
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
"""Home Assistant integration for indevolt device."""
from __future__ import annotations
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN
from .coordinator import IndevoltConfigEntry, IndevoltCoordinator
from .services import async_setup_services
PLATFORMS: list[Platform] = [
Platform.BINARY_SENSOR,
Platform.BUTTON,
Platform.NUMBER,
Platform.SELECT,
Platform.SENSOR,
Platform.SWITCH,
]
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup_entry(hass: HomeAssistant, entry: IndevoltConfigEntry) -> bool:
"""Set up indevolt integration entry using given configuration."""
coordinator = IndevoltCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up indevolt services (actions)."""
await async_setup_services(hass)
return True
async def async_unload_entry(hass: HomeAssistant, entry: IndevoltConfigEntry) -> bool:
"""Unload a config entry / clean up resources (when integration is removed / reloaded)."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)