diff --git a/homeassistant/components/hive/binary_sensor.py b/homeassistant/components/hive/binary_sensor.py index 8e64afa1771..512b06ece6d 100644 --- a/homeassistant/components/hive/binary_sensor.py +++ b/homeassistant/components/hive/binary_sensor.py @@ -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( 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.""" hive = hass.data[DOMAIN][entry.entry_id] + + sensors: list[BinarySensorEntity] = [] + devices = hive.session.deviceList.get("binary_sensor") - if not devices: - return - async_add_entities( - ( - HiveBinarySensorEntity(hive, dev, description) - for dev in devices - for description in BINARY_SENSOR_TYPES - if dev["hiveType"] == description.key - ), - True, + sensors.extend( + HiveBinarySensorEntity(hive, dev, description) + for dev in devices + for description in BINARY_SENSOR_TYPES + if dev["hiveType"] == description.key ) + 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): """Representation of a Hive binary sensor.""" @@ -91,3 +118,24 @@ class HiveBinarySensorEntity(HiveEntity, BinarySensorEntity): self._attr_available = self.device["deviceData"].get("online") else: 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") diff --git a/homeassistant/components/hive/icons.json b/homeassistant/components/hive/icons.json index 671426f6253..186724cd563 100644 --- a/homeassistant/components/hive/icons.json +++ b/homeassistant/components/hive/icons.json @@ -1,4 +1,17 @@ { + "entity": { + "binary_sensor": { + "heating": { + "default": "mdi:radiator" + }, + "hot_water": { + "default": "mdi:hand-water" + }, + "temperature": { + "default": "mdi:thermometer" + } + } + }, "services": { "boost_heating_on": "mdi:radiator", "boost_heating_off": "mdi:radiator-off",