mirror of
https://github.com/home-assistant/core.git
synced 2025-04-29 19:57:52 +00:00
Add water meter to Youless intergration (#117452)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
d441a62aa6
commit
dad9423c08
@ -42,6 +42,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
|
WaterSensor(coordinator, device),
|
||||||
GasSensor(coordinator, device),
|
GasSensor(coordinator, device),
|
||||||
EnergyMeterSensor(
|
EnergyMeterSensor(
|
||||||
coordinator, device, "low", SensorStateClass.TOTAL_INCREASING
|
coordinator, device, "low", SensorStateClass.TOTAL_INCREASING
|
||||||
@ -110,6 +111,27 @@ class YoulessBaseSensor(
|
|||||||
return super().available and self.get_sensor is not None
|
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):
|
class GasSensor(YoulessBaseSensor):
|
||||||
"""The Youless gas sensor."""
|
"""The Youless gas sensor."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user