1 """Support for Vallox ventilation unit switches."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
8 from vallox_websocket_api
import Vallox
16 from .const
import DOMAIN
17 from .coordinator
import ValloxDataUpdateCoordinator
18 from .entity
import ValloxEntity
22 """Representation of a Vallox switch."""
24 entity_description: ValloxSwitchEntityDescription
25 _attr_entity_category = EntityCategory.CONFIG
30 coordinator: ValloxDataUpdateCoordinator,
31 description: ValloxSwitchEntityDescription,
34 """Initialize the Vallox switch."""
44 """Return true if the switch is on."""
46 value := self.coordinator.data.get(self.
entity_descriptionentity_description.metric_key)
60 """Update the current value."""
62 await self.
_client_client.set_values({metric_key: 1
if value
else 0})
66 @dataclass(frozen=True, kw_only=True)
68 """Describes Vallox switch entity."""
73 SWITCH_ENTITIES: tuple[ValloxSwitchEntityDescription, ...] = (
76 translation_key=
"bypass_locked",
77 metric_key=
"A_CYC_BYPASS_LOCKED",
85 async_add_entities: AddEntitiesCallback,
87 """Set up the switches."""
89 data = hass.data[DOMAIN][entry.entry_id]
93 data[
"name"], data[
"coordinator"], description, data[
"client"]
95 for description
in SWITCH_ENTITIES
None async_turn_on(self, **Any kwargs)
None _set_value(self, bool value)
None async_turn_off(self, **Any kwargs)
None __init__(self, str name, ValloxDataUpdateCoordinator coordinator, ValloxSwitchEntityDescription description, Vallox client)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)