1 """Support for Salda Smarty XP/XV Ventilation Unit Binary Sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
9 from pysmarty2
import Smarty
12 BinarySensorDeviceClass,
14 BinarySensorEntityDescription,
19 from .coordinator
import SmartyConfigEntry, SmartyCoordinator
20 from .entity
import SmartyEntity
22 _LOGGER = logging.getLogger(__name__)
25 @dataclass(frozen=True, kw_only=True)
27 """Class describing Smarty binary sensor entities."""
29 value_fn: Callable[[Smarty], bool]
32 ENTITIES: tuple[SmartyBinarySensorEntityDescription, ...] = (
35 translation_key=
"alarm",
36 device_class=BinarySensorDeviceClass.PROBLEM,
37 value_fn=
lambda smarty: smarty.alarm,
41 translation_key=
"warning",
42 device_class=BinarySensorDeviceClass.PROBLEM,
43 value_fn=
lambda smarty: smarty.warning,
47 translation_key=
"boost_state",
48 value_fn=
lambda smarty: smarty.boost,
55 entry: SmartyConfigEntry,
56 async_add_entities: AddEntitiesCallback,
58 """Set up the Smarty Binary Sensor Platform."""
60 coordinator = entry.runtime_data
68 """Representation of a Smarty Binary Sensor."""
70 entity_description: SmartyBinarySensorEntityDescription
74 coordinator: SmartyCoordinator,
75 entity_description: SmartyBinarySensorEntityDescription,
77 """Initialize the entity."""
81 f
"{coordinator.config_entry.entry_id}_{entity_description.key}"
86 """Return the state of the binary sensor."""
None __init__(self, SmartyCoordinator coordinator, SmartyBinarySensorEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, SmartyConfigEntry entry, AddEntitiesCallback async_add_entities)