From fab3ee90b2dbcc553297716515c95ab7331fcee7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 29 Sep 2022 09:38:06 +0200 Subject: [PATCH] Use SensorDeviceClass.VOLUME in components (#79253) --- homeassistant/components/flo/sensor.py | 1 + homeassistant/components/justnimbus/sensor.py | 5 +++++ homeassistant/components/kegtron/sensor.py | 3 +++ homeassistant/components/overkiz/sensor.py | 3 +++ homeassistant/components/p1_monitor/sensor.py | 1 + homeassistant/components/streamlabswater/sensor.py | 4 +++- homeassistant/components/suez_water/sensor.py | 7 ++++++- homeassistant/components/surepetcare/sensor.py | 1 + 8 files changed, 23 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/flo/sensor.py b/homeassistant/components/flo/sensor.py index e7fbd293bd1..9f793b749e4 100644 --- a/homeassistant/components/flo/sensor.py +++ b/homeassistant/components/flo/sensor.py @@ -67,6 +67,7 @@ async def async_setup_entry( class FloDailyUsageSensor(FloEntity, SensorEntity): """Monitors the daily water usage.""" + _attr_device_class = SensorDeviceClass.VOLUME _attr_icon = WATER_ICON _attr_native_unit_of_measurement = VOLUME_GALLONS _attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING diff --git a/homeassistant/components/justnimbus/sensor.py b/homeassistant/components/justnimbus/sensor.py index 73a68ac9139..41f1e81d5b3 100644 --- a/homeassistant/components/justnimbus/sensor.py +++ b/homeassistant/components/justnimbus/sensor.py @@ -103,6 +103,7 @@ SENSOR_TYPES = ( name="Reservoir content", icon="mdi:car-coolant-level", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda coordinator: coordinator.data.reservoir_content, @@ -112,6 +113,7 @@ SENSOR_TYPES = ( name="Total saved", icon="mdi:water-opacity", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda coordinator: coordinator.data.total_saved, @@ -121,6 +123,7 @@ SENSOR_TYPES = ( name="Total replenished", icon="mdi:water", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda coordinator: coordinator.data.total_replenished, @@ -138,6 +141,7 @@ SENSOR_TYPES = ( name="Total use", icon="mdi:chart-donut", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING, entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda coordinator: coordinator.data.totver, @@ -147,6 +151,7 @@ SENSOR_TYPES = ( name="Max reservoir content", icon="mdi:waves", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL, entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda coordinator: coordinator.data.reservoir_content_max, diff --git a/homeassistant/components/kegtron/sensor.py b/homeassistant/components/kegtron/sensor.py index f52a7c79634..892d8651185 100644 --- a/homeassistant/components/kegtron/sensor.py +++ b/homeassistant/components/kegtron/sensor.py @@ -39,6 +39,7 @@ SENSOR_DESCRIPTIONS = { key=KegtronSensorDeviceClass.KEG_SIZE, icon="mdi:keg", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, ), KegtronSensorDeviceClass.KEG_TYPE: SensorEntityDescription( @@ -49,12 +50,14 @@ SENSOR_DESCRIPTIONS = { key=KegtronSensorDeviceClass.VOLUME_START, icon="mdi:keg", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, ), KegtronSensorDeviceClass.VOLUME_DISPENSED: SensorEntityDescription( key=KegtronSensorDeviceClass.VOLUME_DISPENSED, icon="mdi:keg", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL, ), KegtronSensorDeviceClass.PORT_STATE: SensorEntityDescription( diff --git a/homeassistant/components/overkiz/sensor.py b/homeassistant/components/overkiz/sensor.py index 83f123eaad7..e80e08e263a 100644 --- a/homeassistant/components/overkiz/sensor.py +++ b/homeassistant/components/overkiz/sensor.py @@ -90,6 +90,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [ name="Water volume estimation at 40 °C", icon="mdi:water", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, entity_registry_enabled_default=False, state_class=SensorStateClass.MEASUREMENT, ), @@ -98,6 +99,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [ name="Water consumption", icon="mdi:water", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, ), OverkizSensorDescription( @@ -105,6 +107,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [ name="Outlet engine", icon="mdi:fan-chevron-down", native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.MEASUREMENT, ), OverkizSensorDescription( diff --git a/homeassistant/components/p1_monitor/sensor.py b/homeassistant/components/p1_monitor/sensor.py index 757bf249ca1..e55c8dacea5 100644 --- a/homeassistant/components/p1_monitor/sensor.py +++ b/homeassistant/components/p1_monitor/sensor.py @@ -222,6 +222,7 @@ SENSORS_WATERMETER: tuple[SensorEntityDescription, ...] = ( name="Consumption Day", state_class=SensorStateClass.TOTAL_INCREASING, native_unit_of_measurement=VOLUME_LITERS, + device_class=SensorDeviceClass.VOLUME, ), SensorEntityDescription( key="consumption_total", diff --git a/homeassistant/components/streamlabswater/sensor.py b/homeassistant/components/streamlabswater/sensor.py index afef8070fcb..1a1070d1ea8 100644 --- a/homeassistant/components/streamlabswater/sensor.py +++ b/homeassistant/components/streamlabswater/sensor.py @@ -3,7 +3,7 @@ from __future__ import annotations from datetime import timedelta -from homeassistant.components.sensor import SensorEntity +from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.const import VOLUME_GALLONS from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -80,6 +80,8 @@ class StreamlabsUsageData: class StreamLabsDailyUsage(SensorEntity): """Monitors the daily water usage.""" + _attr_device_class = SensorDeviceClass.VOLUME + def __init__(self, location_name, streamlabs_usage_data): """Initialize the daily water usage device.""" self._location_name = location_name diff --git a/homeassistant/components/suez_water/sensor.py b/homeassistant/components/suez_water/sensor.py index ac691829236..77b1de6555e 100644 --- a/homeassistant/components/suez_water/sensor.py +++ b/homeassistant/components/suez_water/sensor.py @@ -8,7 +8,11 @@ from pysuez import SuezClient from pysuez.client import PySuezError import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity +from homeassistant.components.sensor import ( + PLATFORM_SCHEMA, + SensorDeviceClass, + SensorEntity, +) from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, VOLUME_LITERS from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -63,6 +67,7 @@ class SuezSensor(SensorEntity): _attr_name = NAME _attr_icon = ICON _attr_native_unit_of_measurement = VOLUME_LITERS + _attr_device_class = SensorDeviceClass.VOLUME def __init__(self, client): """Initialize the data object.""" diff --git a/homeassistant/components/surepetcare/sensor.py b/homeassistant/components/surepetcare/sensor.py index e9967054900..1ae22710060 100644 --- a/homeassistant/components/surepetcare/sensor.py +++ b/homeassistant/components/surepetcare/sensor.py @@ -87,6 +87,7 @@ class SureBattery(SurePetcareEntity, SensorEntity): class Felaqua(SurePetcareEntity, SensorEntity): """Sure Petcare Felaqua.""" + _attr_device_class = SensorDeviceClass.VOLUME _attr_native_unit_of_measurement = VOLUME_MILLILITERS def __init__( -- GitLab