mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Add missing binary sensors to Hive integration (#122296)
* add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors * add missing sensors
This commit is contained in:
parent
3df6b34a03
commit
ba276a5cb6
@ -47,6 +47,25 @@ BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||||
|
BinarySensorEntityDescription(
|
||||||
|
key="Heating_State",
|
||||||
|
translation_key="heating",
|
||||||
|
),
|
||||||
|
BinarySensorEntityDescription(
|
||||||
|
key="Heating_Boost",
|
||||||
|
translation_key="heating",
|
||||||
|
),
|
||||||
|
BinarySensorEntityDescription(
|
||||||
|
key="Hotwater_State",
|
||||||
|
translation_key="hot_water",
|
||||||
|
),
|
||||||
|
BinarySensorEntityDescription(
|
||||||
|
key="Hotwater_Boost",
|
||||||
|
translation_key="hot_water",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
@ -54,19 +73,27 @@ async def async_setup_entry(
|
|||||||
"""Set up Hive thermostat based on a config entry."""
|
"""Set up Hive thermostat based on a config entry."""
|
||||||
|
|
||||||
hive = hass.data[DOMAIN][entry.entry_id]
|
hive = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
|
sensors: list[BinarySensorEntity] = []
|
||||||
|
|
||||||
devices = hive.session.deviceList.get("binary_sensor")
|
devices = hive.session.deviceList.get("binary_sensor")
|
||||||
if not devices:
|
sensors.extend(
|
||||||
return
|
HiveBinarySensorEntity(hive, dev, description)
|
||||||
async_add_entities(
|
for dev in devices
|
||||||
(
|
for description in BINARY_SENSOR_TYPES
|
||||||
HiveBinarySensorEntity(hive, dev, description)
|
if dev["hiveType"] == description.key
|
||||||
for dev in devices
|
|
||||||
for description in BINARY_SENSOR_TYPES
|
|
||||||
if dev["hiveType"] == description.key
|
|
||||||
),
|
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
devices = hive.session.deviceList.get("sensor")
|
||||||
|
sensors.extend(
|
||||||
|
HiveSensorEntity(hive, dev, description)
|
||||||
|
for dev in devices
|
||||||
|
for description in SENSOR_TYPES
|
||||||
|
if dev["hiveType"] == description.key
|
||||||
|
)
|
||||||
|
|
||||||
|
async_add_entities(sensors, True)
|
||||||
|
|
||||||
|
|
||||||
class HiveBinarySensorEntity(HiveEntity, BinarySensorEntity):
|
class HiveBinarySensorEntity(HiveEntity, BinarySensorEntity):
|
||||||
"""Representation of a Hive binary sensor."""
|
"""Representation of a Hive binary sensor."""
|
||||||
@ -91,3 +118,24 @@ class HiveBinarySensorEntity(HiveEntity, BinarySensorEntity):
|
|||||||
self._attr_available = self.device["deviceData"].get("online")
|
self._attr_available = self.device["deviceData"].get("online")
|
||||||
else:
|
else:
|
||||||
self._attr_available = True
|
self._attr_available = True
|
||||||
|
|
||||||
|
|
||||||
|
class HiveSensorEntity(HiveEntity, BinarySensorEntity):
|
||||||
|
"""Hive Sensor Entity."""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
hive: Hive,
|
||||||
|
hive_device: dict[str, Any],
|
||||||
|
entity_description: BinarySensorEntityDescription,
|
||||||
|
) -> None:
|
||||||
|
"""Initialise hive sensor."""
|
||||||
|
super().__init__(hive, hive_device)
|
||||||
|
self.entity_description = entity_description
|
||||||
|
|
||||||
|
async def async_update(self) -> None:
|
||||||
|
"""Update all Node data from Hive."""
|
||||||
|
await self.hive.session.updateData(self.device)
|
||||||
|
self.device = await self.hive.sensor.getSensor(self.device)
|
||||||
|
self._attr_is_on = self.device["status"]["state"] == "ON"
|
||||||
|
self._attr_available = self.device["deviceData"].get("online")
|
||||||
|
@ -1,4 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"heating": {
|
||||||
|
"default": "mdi:radiator"
|
||||||
|
},
|
||||||
|
"hot_water": {
|
||||||
|
"default": "mdi:hand-water"
|
||||||
|
},
|
||||||
|
"temperature": {
|
||||||
|
"default": "mdi:thermometer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"boost_heating_on": "mdi:radiator",
|
"boost_heating_on": "mdi:radiator",
|
||||||
"boost_heating_off": "mdi:radiator-off",
|
"boost_heating_off": "mdi:radiator-off",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user