1 """Support for an Intergas heater via an InComfort/InTouch Lan2RF gateway."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
9 from incomfortclient
import Heater
as InComfortHeater
12 BinarySensorDeviceClass,
14 BinarySensorEntityDescription,
19 from .
import InComfortConfigEntry
20 from .coordinator
import InComfortDataCoordinator
21 from .entity
import IncomfortBoilerEntity
24 @dataclass(frozen=True, kw_only=True)
26 """Describes Incomfort binary sensor entity."""
29 extra_state_attributes_fn: Callable[[dict[str, Any]], dict[str, Any]] |
None =
None
32 SENSOR_TYPES: tuple[IncomfortBinarySensorEntityDescription, ...] = (
35 translation_key=
"fault",
36 device_class=BinarySensorDeviceClass.PROBLEM,
37 value_key=
"is_failed",
38 extra_state_attributes_fn=
lambda status: {
39 "fault_code": status[
"fault_code"]
or "none",
44 translation_key=
"is_pumping",
45 device_class=BinarySensorDeviceClass.RUNNING,
46 value_key=
"is_pumping",
50 translation_key=
"is_burning",
51 device_class=BinarySensorDeviceClass.RUNNING,
52 value_key=
"is_burning",
56 translation_key=
"is_tapping",
57 device_class=BinarySensorDeviceClass.RUNNING,
58 value_key=
"is_tapping",
65 entry: InComfortConfigEntry,
66 async_add_entities: AddEntitiesCallback,
68 """Set up an InComfort/InTouch binary_sensor entity."""
69 incomfort_coordinator = entry.runtime_data
70 heaters = incomfort_coordinator.data.heaters
74 for description
in SENSOR_TYPES
79 """Representation of an InComfort binary sensor."""
81 entity_description: IncomfortBinarySensorEntityDescription
85 coordinator: InComfortDataCoordinator,
86 heater: InComfortHeater,
87 description: IncomfortBinarySensorEntityDescription,
89 """Initialize the binary sensor."""
90 super().
__init__(coordinator, heater)
96 """Return the status of the sensor."""
101 """Return the device state attributes."""
102 if (attributes_fn := self.
entity_descriptionentity_description.extra_state_attributes_fn)
is None:
dict[str, Any]|None extra_state_attributes(self)
None __init__(self, InComfortDataCoordinator coordinator, InComfortHeater heater, IncomfortBinarySensorEntityDescription description)
None async_setup_entry(HomeAssistant hass, InComfortConfigEntry entry, AddEntitiesCallback async_add_entities)