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 button."""
26 press_fn: Callable[[Smarty], bool |
None]
29 ENTITIES: tuple[SmartyButtonDescription, ...] = (
31 key=
"reset_filters_timer",
32 translation_key=
"reset_filters_timer",
33 press_fn=
lambda smarty: smarty.reset_filters_timer(),
40 entry: SmartyConfigEntry,
41 async_add_entities: AddEntitiesCallback,
43 """Set up the Smarty Button Platform."""
45 coordinator = entry.runtime_data
48 SmartyButton(coordinator, description)
for description
in ENTITIES
53 """Representation of a Smarty Button."""
55 entity_description: SmartyButtonDescription
59 coordinator: SmartyCoordinator,
60 entity_description: SmartyButtonDescription,
62 """Initialize the entity."""
66 f
"{coordinator.config_entry.entry_id}_{entity_description.key}"
70 """Press the button."""
71 await self.
hasshasshass.async_add_executor_job(