1 """Support for the Hive binary sensors."""
3 from datetime
import timedelta
6 from apyhiveapi
import Hive
9 BinarySensorDeviceClass,
11 BinarySensorEntityDescription,
17 from .const
import DOMAIN
18 from .entity
import HiveEntity
24 BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
26 key=
"contactsensor", device_class=BinarySensorDeviceClass.OPENING
30 device_class=BinarySensorDeviceClass.MOTION,
34 device_class=BinarySensorDeviceClass.CONNECTIVITY,
38 device_class=BinarySensorDeviceClass.SMOKE,
42 device_class=BinarySensorDeviceClass.SOUND,
46 device_class=BinarySensorDeviceClass.SOUND,
50 SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
53 translation_key=
"heating",
57 translation_key=
"heating",
61 translation_key=
"hot_water",
65 translation_key=
"hot_water",
71 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
73 """Set up Hive thermostat based on a config entry."""
75 hive = hass.data[DOMAIN][entry.entry_id]
77 sensors: list[BinarySensorEntity] = []
79 devices = hive.session.deviceList.get(
"binary_sensor")
83 for description
in BINARY_SENSOR_TYPES
84 if dev[
"hiveType"] == description.key
87 devices = hive.session.deviceList.get(
"sensor")
91 for description
in SENSOR_TYPES
92 if dev[
"hiveType"] == description.key
99 """Representation of a Hive binary sensor."""
104 hive_device: dict[str, Any],
105 entity_description: BinarySensorEntityDescription,
107 """Initialise hive binary sensor."""
112 """Update all Node data from Hive."""
117 if self.
devicedevicedevice[
"hiveType"] !=
"Connectivity":
124 """Hive Sensor Entity."""
129 hive_device: dict[str, Any],
130 entity_description: BinarySensorEntityDescription,
132 """Initialise hive sensor."""
137 """Update all Node data from Hive."""
None __init__(self, Hive hive, dict[str, Any] hive_device, BinarySensorEntityDescription entity_description)
None __init__(self, Hive hive, dict[str, Any] hive_device, BinarySensorEntityDescription entity_description)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)