Add water meter to Youless intergration (#117452)

Co-authored-by: Franck Nijhof <git@frenck.dev>
pull/117462/head
Ben Van Mechelen 2024-05-14 21:50:38 +02:00 committed by GitHub
parent d441a62aa6
commit dad9423c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 0 deletions

View File

@ -42,6 +42,7 @@ async def async_setup_entry(
async_add_entities(
[
WaterSensor(coordinator, device),
GasSensor(coordinator, device),
EnergyMeterSensor(
coordinator, device, "low", SensorStateClass.TOTAL_INCREASING
@ -110,6 +111,27 @@ class YoulessBaseSensor(
return super().available and self.get_sensor is not None
class WaterSensor(YoulessBaseSensor):
"""The Youless Water sensor."""
_attr_native_unit_of_measurement = UnitOfVolume.CUBIC_METERS
_attr_device_class = SensorDeviceClass.WATER
_attr_state_class = SensorStateClass.TOTAL_INCREASING
def __init__(
self, coordinator: DataUpdateCoordinator[YoulessAPI], device: str
) -> None:
"""Instantiate a Water sensor."""
super().__init__(coordinator, device, "water", "Water meter", "water")
self._attr_name = "Water usage"
self._attr_icon = "mdi:water"
@property
def get_sensor(self) -> YoulessSensor | None:
"""Get the sensor for providing the value."""
return self.coordinator.data.water_meter
class GasSensor(YoulessBaseSensor):
"""The Youless gas sensor."""