From 5b32540a844ad95aac1a5ae5cee342c0f1bc836f Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 25 Oct 2022 13:21:47 +0200 Subject: [PATCH] Set water device class to flo, homewizard, p1_monitor, toon (#80944) --- homeassistant/components/flo/sensor.py | 1 + homeassistant/components/homewizard/sensor.py | 2 +- homeassistant/components/p1_monitor/sensor.py | 3 ++- homeassistant/components/toon/sensor.py | 3 +++ tests/components/homewizard/test_sensor.py | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/flo/sensor.py b/homeassistant/components/flo/sensor.py index 9f793b749e4..9cb070a1c62 100644 --- a/homeassistant/components/flo/sensor.py +++ b/homeassistant/components/flo/sensor.py @@ -71,6 +71,7 @@ class FloDailyUsageSensor(FloEntity, SensorEntity): _attr_icon = WATER_ICON _attr_native_unit_of_measurement = VOLUME_GALLONS _attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING + _attr_device_class = SensorDeviceClass.WATER def __init__(self, device): """Initialize the daily water usage sensor.""" diff --git a/homeassistant/components/homewizard/sensor.py b/homeassistant/components/homewizard/sensor.py index 6fc1d38ec12..4baaff8835d 100644 --- a/homeassistant/components/homewizard/sensor.py +++ b/homeassistant/components/homewizard/sensor.py @@ -131,7 +131,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = ( name="Total water usage", native_unit_of_measurement=VOLUME_CUBIC_METERS, icon="mdi:gauge", - device_class=SensorDeviceClass.VOLUME, + device_class=SensorDeviceClass.WATER, state_class=SensorStateClass.TOTAL_INCREASING, ), ) diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index e55c8dacea5..8a1c9d68b5a 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -222,13 +222,14 @@ SENSORS_WATERMETER: tuple[SensorEntityDescription, ...] = ( name="Consumption Day", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=VOLUME_LITERS, - device_class=SensorDeviceClass.VOLUME, + device_class=SensorDeviceClass.WATER, ), SensorEntityDescription( key="consumption_total", name="Consumption Total", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=VOLUME_CUBIC_METERS, + device_class=SensorDeviceClass.WATER, ), SensorEntityDescription( key="pulse_count", diff --git a/homeassistant/components/toon/sensor.py b/homeassistant/components/toon/sensor.py index 371672e184e..9178cc6c01a 100644 --- a/homeassistant/components/toon/sensor.py +++ b/homeassistant/components/toon/sensor.py @@ -316,6 +316,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( icon="mdi:water", entity_registry_enabled_default=False, cls=ToonWaterMeterDeviceSensor, + device_class=SensorDeviceClass.WATER, ), ToonSensorEntityDescription( key="water_daily_usage", @@ -326,6 +327,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( icon="mdi:water", entity_registry_enabled_default=False, cls=ToonWaterMeterDeviceSensor, + device_class=SensorDeviceClass.WATER, ), ToonSensorEntityDescription( key="water_meter_reading", @@ -337,6 +339,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = ( entity_registry_enabled_default=False, state_class=SensorStateClass.TOTAL_INCREASING, cls=ToonWaterMeterDeviceSensor, + device_class=SensorDeviceClass.WATER, ), ToonSensorEntityDescription( key="water_value", diff --git a/tests/components/homewizard/test_sensor.py b/tests/components/homewizard/test_sensor.py index c8238c75643..d405a713edb 100644 --- a/tests/components/homewizard/test_sensor.py +++ b/tests/components/homewizard/test_sensor.py @@ -609,7 +609,7 @@ async def test_sensor_entity_total_liters( assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == VOLUME_CUBIC_METERS - assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLUME + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.WATER assert state.attributes.get(ATTR_ICON) == "mdi:gauge"