mirror of
https://github.com/home-assistant/core.git
synced 2026-07-02 12:17:30 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
"""Support for Vallox ventilation units."""
|
|
|
|
import ipaddress
|
|
|
|
from vallox_websocket_api import Vallox
|
|
import voluptuous as vol
|
|
|
|
from homeassistant.const import CONF_HOST, CONF_NAME, Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import config_validation as cv
|
|
from homeassistant.helpers.typing import ConfigType
|
|
|
|
from .const import DEFAULT_NAME, DOMAIN
|
|
from .coordinator import ValloxConfigEntry, ValloxDataUpdateCoordinator
|
|
from .services import async_setup_services
|
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
|
vol.All(
|
|
cv.deprecated(DOMAIN),
|
|
{
|
|
DOMAIN: vol.Schema(
|
|
{
|
|
vol.Required(CONF_HOST): vol.All(ipaddress.ip_address, cv.string),
|
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
|
}
|
|
)
|
|
},
|
|
),
|
|
extra=vol.ALLOW_EXTRA,
|
|
)
|
|
|
|
PLATFORMS: list[str] = [
|
|
Platform.BINARY_SENSOR,
|
|
Platform.DATE,
|
|
Platform.FAN,
|
|
Platform.NUMBER,
|
|
Platform.SENSOR,
|
|
Platform.SWITCH,
|
|
]
|
|
|
|
|
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|
"""Set up the Vallox integration."""
|
|
async_setup_services(hass)
|
|
return True
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ValloxConfigEntry) -> bool:
|
|
"""Set up the client and boot the platforms."""
|
|
host = entry.data[CONF_HOST]
|
|
|
|
client = Vallox(host)
|
|
|
|
coordinator = ValloxDataUpdateCoordinator(hass, entry, client)
|
|
|
|
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_unload_entry(hass: HomeAssistant, entry: ValloxConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|