1 """Platform to control a Salda Smarty XP/XV ventilation unit."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
10 from pysmarty2
import Smarty
16 from .coordinator
import SmartyConfigEntry, SmartyCoordinator
17 from .entity
import SmartyEntity
19 _LOGGER = logging.getLogger(__name__)
22 @dataclass(frozen=True, kw_only=True)
24 """Class describing Smarty switch."""
26 is_on_fn: Callable[[Smarty], bool]
27 turn_on_fn: Callable[[Smarty], bool |
None]
28 turn_off_fn: Callable[[Smarty], bool |
None]
31 ENTITIES: tuple[SmartySwitchDescription, ...] = (
34 translation_key=
"boost",
35 is_on_fn=
lambda smarty: smarty.boost,
36 turn_on_fn=
lambda smarty: smarty.enable_boost(),
37 turn_off_fn=
lambda smarty: smarty.disable_boost(),
44 entry: SmartyConfigEntry,
45 async_add_entities: AddEntitiesCallback,
47 """Set up the Smarty Switch Platform."""
49 coordinator = entry.runtime_data
52 SmartySwitch(coordinator, description)
for description
in ENTITIES
57 """Representation of a Smarty Switch."""
59 entity_description: SmartySwitchDescription
63 coordinator: SmartyCoordinator,
64 entity_description: SmartySwitchDescription,
66 """Initialize the entity."""
70 f
"{coordinator.config_entry.entry_id}_{entity_description.key}"
75 """Return the state of the switch."""
79 """Turn the switch on."""
80 await self.
hasshasshass.async_add_executor_job(
86 """Turn the switch off."""
87 await self.
hasshasshass.async_add_executor_job(
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None __init__(self, SmartyCoordinator coordinator, SmartySwitchDescription entity_description)
None async_setup_entry(HomeAssistant hass, SmartyConfigEntry entry, AddEntitiesCallback async_add_entities)