1 """Define switch func."""
3 from __future__
import annotations
5 from collections.abc
import Awaitable, Callable
6 from dataclasses
import dataclass
14 from .
import IntellifireDataUpdateCoordinator
15 from .const
import DOMAIN
16 from .entity
import IntellifireEntity
19 @dataclass(frozen=True)
21 """Mixin for required keys."""
23 on_fn: Callable[[IntellifireDataUpdateCoordinator], Awaitable]
24 off_fn: Callable[[IntellifireDataUpdateCoordinator], Awaitable]
25 value_fn: Callable[[IntellifireDataUpdateCoordinator], bool]
28 @dataclass(frozen=True)
30 SwitchEntityDescription, IntellifireSwitchRequiredKeysMixin
32 """Describes a switch entity."""
35 INTELLIFIRE_SWITCHES: tuple[IntellifireSwitchEntityDescription, ...] = (
38 translation_key=
"flame",
39 on_fn=
lambda coordinator: coordinator.control_api.flame_on(),
40 off_fn=
lambda coordinator: coordinator.control_api.flame_off(),
41 value_fn=
lambda coordinator: coordinator.read_api.data.is_on,
45 translation_key=
"pilot_light",
46 on_fn=
lambda coordinator: coordinator.control_api.pilot_on(),
47 off_fn=
lambda coordinator: coordinator.control_api.pilot_off(),
48 value_fn=
lambda coordinator: coordinator.read_api.data.pilot_on,
56 async_add_entities: AddEntitiesCallback,
58 """Configure switch entities."""
59 coordinator: IntellifireDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
63 for description
in INTELLIFIRE_SWITCHES
68 """Define an Intellifire Switch."""
70 entity_description: IntellifireSwitchEntityDescription
73 """Turn on the switch."""
78 """Turn off the switch."""
83 def is_on(self) -> bool | None:
84 """Return the on state."""
None async_turn_on(self, **Any kwargs)
None async_update_ha_state(self, bool force_refresh=False)
None async_turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)