1 """Support for IntelliFire Binary Sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
9 BinarySensorDeviceClass,
11 BinarySensorEntityDescription,
18 from .
import IntellifireDataUpdateCoordinator
19 from .const
import DOMAIN
20 from .entity
import IntellifireEntity
23 @dataclass(frozen=True)
25 """Mixin for required keys."""
27 value_fn: Callable[[IntellifireDataUpdateCoordinator], bool |
None]
30 @dataclass(frozen=True)
32 BinarySensorEntityDescription, IntellifireBinarySensorRequiredKeysMixin
34 """Describes a binary sensor entity."""
37 INTELLIFIRE_BINARY_SENSORS: tuple[IntellifireBinarySensorEntityDescription, ...] = (
40 translation_key=
"flame",
41 value_fn=
lambda coordinator: coordinator.data.is_on,
45 translation_key=
"timer_on",
46 value_fn=
lambda coordinator: coordinator.data.timer_on,
50 translation_key=
"pilot_light_on",
51 value_fn=
lambda coordinator: coordinator.data.pilot_on,
55 translation_key=
"thermostat_on",
56 value_fn=
lambda coordinator: coordinator.data.thermostat_on,
59 key=
"error_pilot_flame",
60 translation_key=
"pilot_flame_error",
61 entity_category=EntityCategory.DIAGNOSTIC,
62 value_fn=
lambda coordinator: coordinator.data.error_pilot_flame,
63 device_class=BinarySensorDeviceClass.PROBLEM,
67 translation_key=
"flame_error",
68 entity_category=EntityCategory.DIAGNOSTIC,
69 value_fn=
lambda coordinator: coordinator.data.error_flame,
70 device_class=BinarySensorDeviceClass.PROBLEM,
73 key=
"error_fan_delay",
74 translation_key=
"fan_delay_error",
75 entity_category=EntityCategory.DIAGNOSTIC,
76 value_fn=
lambda coordinator: coordinator.data.error_fan_delay,
77 device_class=BinarySensorDeviceClass.PROBLEM,
80 key=
"error_maintenance",
81 translation_key=
"maintenance_error",
82 entity_category=EntityCategory.DIAGNOSTIC,
83 value_fn=
lambda coordinator: coordinator.data.error_maintenance,
84 device_class=BinarySensorDeviceClass.PROBLEM,
88 translation_key=
"disabled_error",
89 entity_category=EntityCategory.DIAGNOSTIC,
90 value_fn=
lambda coordinator: coordinator.data.error_disabled,
91 device_class=BinarySensorDeviceClass.PROBLEM,
95 translation_key=
"fan_error",
96 entity_category=EntityCategory.DIAGNOSTIC,
97 value_fn=
lambda coordinator: coordinator.data.error_fan,
98 device_class=BinarySensorDeviceClass.PROBLEM,
102 translation_key=
"lights_error",
103 entity_category=EntityCategory.DIAGNOSTIC,
104 value_fn=
lambda coordinator: coordinator.data.error_lights,
105 device_class=BinarySensorDeviceClass.PROBLEM,
108 key=
"error_accessory",
109 translation_key=
"accessory_error",
110 entity_category=EntityCategory.DIAGNOSTIC,
111 value_fn=
lambda coordinator: coordinator.data.error_accessory,
112 device_class=BinarySensorDeviceClass.PROBLEM,
115 key=
"error_soft_lock_out",
116 translation_key=
"soft_lock_out_error",
117 entity_category=EntityCategory.DIAGNOSTIC,
118 value_fn=
lambda coordinator: coordinator.data.error_soft_lock_out,
119 device_class=BinarySensorDeviceClass.PROBLEM,
122 key=
"error_ecm_offline",
123 translation_key=
"ecm_offline_error",
124 entity_category=EntityCategory.DIAGNOSTIC,
125 value_fn=
lambda coordinator: coordinator.data.error_ecm_offline,
126 device_class=BinarySensorDeviceClass.PROBLEM,
130 translation_key=
"offline_error",
131 entity_category=EntityCategory.DIAGNOSTIC,
132 value_fn=
lambda coordinator: coordinator.data.error_offline,
133 device_class=BinarySensorDeviceClass.PROBLEM,
136 key=
"local_connectivity",
137 translation_key=
"local_connectivity",
138 entity_category=EntityCategory.DIAGNOSTIC,
139 device_class=BinarySensorDeviceClass.CONNECTIVITY,
140 value_fn=
lambda coordinator: coordinator.fireplace.local_connectivity,
143 key=
"cloud_connectivity",
144 translation_key=
"cloud_connectivity",
145 entity_category=EntityCategory.DIAGNOSTIC,
146 device_class=BinarySensorDeviceClass.CONNECTIVITY,
147 value_fn=
lambda coordinator: coordinator.fireplace.cloud_connectivity,
155 async_add_entities: AddEntitiesCallback,
157 """Set up a IntelliFire On/Off Sensor."""
158 coordinator: IntellifireDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
162 for description
in INTELLIFIRE_BINARY_SENSORS
167 """Extends IntellifireEntity with Binary Sensor specific logic."""
169 entity_description: IntellifireBinarySensorEntityDescription
173 """Use this to get the correct value."""
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)