1 """Support for the Hive sensors."""
3 from collections.abc
import Callable
4 from dataclasses
import dataclass
5 from datetime
import timedelta
8 from apyhiveapi
import Hive
13 SensorEntityDescription,
27 from .const
import DOMAIN
28 from .entity
import HiveEntity
34 @dataclass(frozen=True)
36 """Describes Hive sensor entity."""
38 fn: Callable[[StateType], StateType] =
lambda x: x
41 SENSOR_TYPES: tuple[HiveSensorEntityDescription, ...] = (
44 native_unit_of_measurement=PERCENTAGE,
45 device_class=SensorDeviceClass.BATTERY,
46 entity_category=EntityCategory.DIAGNOSTIC,
50 native_unit_of_measurement=UnitOfPower.WATT,
51 state_class=SensorStateClass.MEASUREMENT,
52 device_class=SensorDeviceClass.POWER,
53 entity_category=EntityCategory.DIAGNOSTIC,
56 key=
"Current_Temperature",
57 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
58 state_class=SensorStateClass.MEASUREMENT,
59 device_class=SensorDeviceClass.TEMPERATURE,
60 entity_category=EntityCategory.DIAGNOSTIC,
63 key=
"Heating_Current_Temperature",
64 device_class=SensorDeviceClass.TEMPERATURE,
65 state_class=SensorStateClass.MEASUREMENT,
66 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
69 key=
"Heating_Target_Temperature",
70 device_class=SensorDeviceClass.TEMPERATURE,
71 state_class=SensorStateClass.MEASUREMENT,
72 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
76 device_class=SensorDeviceClass.ENUM,
77 options=[
"schedule",
"manual",
"off"],
78 translation_key=
"heating",
79 fn=
lambda x: x.lower()
if isinstance(x, str)
else None,
83 device_class=SensorDeviceClass.ENUM,
84 options=[
"schedule",
"on",
"off"],
85 translation_key=
"hot_water",
86 fn=
lambda x: x.lower()
if isinstance(x, str)
else None,
92 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
94 """Set up Hive thermostat based on a config entry."""
95 hive = hass.data[DOMAIN][entry.entry_id]
96 devices = hive.session.deviceList.get(
"sensor")
103 for description
in SENSOR_TYPES
104 if dev[
"hiveType"] == description.key
111 """Hive Sensor Entity."""
113 entity_description: HiveSensorEntityDescription
118 hive_device: dict[str, Any],
119 entity_description: HiveSensorEntityDescription,
121 """Initialise hive sensor."""
126 """Update all Node data from Hive."""
None __init__(self, Hive hive, dict[str, Any] hive_device, HiveSensorEntityDescription entity_description)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)