Use SensorDeviceClass.VOLUME in components (#79253)

This commit is contained in:
epenet 2022-09-29 09:38:06 +02:00 committed by GitHub
parent 0e764b57c2
commit fab3ee90b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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,

View File

@ -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(

View File

@ -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(

View File

@ -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",

View File

@ -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

View File

@ -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."""

View File

@ -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__(