Use SensorDeviceClass.VOLUME in components (#79253)
This commit is contained in:
parent
0e764b57c2
commit
fab3ee90b2
8 changed files with 23 additions and 2 deletions
|
@ -67,6 +67,7 @@ async def async_setup_entry(
|
||||||
class FloDailyUsageSensor(FloEntity, SensorEntity):
|
class FloDailyUsageSensor(FloEntity, SensorEntity):
|
||||||
"""Monitors the daily water usage."""
|
"""Monitors the daily water usage."""
|
||||||
|
|
||||||
|
_attr_device_class = SensorDeviceClass.VOLUME
|
||||||
_attr_icon = WATER_ICON
|
_attr_icon = WATER_ICON
|
||||||
_attr_native_unit_of_measurement = VOLUME_GALLONS
|
_attr_native_unit_of_measurement = VOLUME_GALLONS
|
||||||
_attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
|
_attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
|
||||||
|
|
|
@ -103,6 +103,7 @@ SENSOR_TYPES = (
|
||||||
name="Reservoir content",
|
name="Reservoir content",
|
||||||
icon="mdi:car-coolant-level",
|
icon="mdi:car-coolant-level",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda coordinator: coordinator.data.reservoir_content,
|
value_fn=lambda coordinator: coordinator.data.reservoir_content,
|
||||||
|
@ -112,6 +113,7 @@ SENSOR_TYPES = (
|
||||||
name="Total saved",
|
name="Total saved",
|
||||||
icon="mdi:water-opacity",
|
icon="mdi:water-opacity",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda coordinator: coordinator.data.total_saved,
|
value_fn=lambda coordinator: coordinator.data.total_saved,
|
||||||
|
@ -121,6 +123,7 @@ SENSOR_TYPES = (
|
||||||
name="Total replenished",
|
name="Total replenished",
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda coordinator: coordinator.data.total_replenished,
|
value_fn=lambda coordinator: coordinator.data.total_replenished,
|
||||||
|
@ -138,6 +141,7 @@ SENSOR_TYPES = (
|
||||||
name="Total use",
|
name="Total use",
|
||||||
icon="mdi:chart-donut",
|
icon="mdi:chart-donut",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda coordinator: coordinator.data.totver,
|
value_fn=lambda coordinator: coordinator.data.totver,
|
||||||
|
@ -147,6 +151,7 @@ SENSOR_TYPES = (
|
||||||
name="Max reservoir content",
|
name="Max reservoir content",
|
||||||
icon="mdi:waves",
|
icon="mdi:waves",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda coordinator: coordinator.data.reservoir_content_max,
|
value_fn=lambda coordinator: coordinator.data.reservoir_content_max,
|
||||||
|
|
|
@ -39,6 +39,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
key=KegtronSensorDeviceClass.KEG_SIZE,
|
key=KegtronSensorDeviceClass.KEG_SIZE,
|
||||||
icon="mdi:keg",
|
icon="mdi:keg",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
KegtronSensorDeviceClass.KEG_TYPE: SensorEntityDescription(
|
KegtronSensorDeviceClass.KEG_TYPE: SensorEntityDescription(
|
||||||
|
@ -49,12 +50,14 @@ SENSOR_DESCRIPTIONS = {
|
||||||
key=KegtronSensorDeviceClass.VOLUME_START,
|
key=KegtronSensorDeviceClass.VOLUME_START,
|
||||||
icon="mdi:keg",
|
icon="mdi:keg",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
KegtronSensorDeviceClass.VOLUME_DISPENSED: SensorEntityDescription(
|
KegtronSensorDeviceClass.VOLUME_DISPENSED: SensorEntityDescription(
|
||||||
key=KegtronSensorDeviceClass.VOLUME_DISPENSED,
|
key=KegtronSensorDeviceClass.VOLUME_DISPENSED,
|
||||||
icon="mdi:keg",
|
icon="mdi:keg",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
KegtronSensorDeviceClass.PORT_STATE: SensorEntityDescription(
|
KegtronSensorDeviceClass.PORT_STATE: SensorEntityDescription(
|
||||||
|
|
|
@ -90,6 +90,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
||||||
name="Water volume estimation at 40 °C",
|
name="Water volume estimation at 40 °C",
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
|
@ -98,6 +99,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
||||||
name="Water consumption",
|
name="Water consumption",
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
|
@ -105,6 +107,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
||||||
name="Outlet engine",
|
name="Outlet engine",
|
||||||
icon="mdi:fan-chevron-down",
|
icon="mdi:fan-chevron-down",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
|
|
|
@ -222,6 +222,7 @@ SENSORS_WATERMETER: tuple[SensorEntityDescription, ...] = (
|
||||||
name="Consumption Day",
|
name="Consumption Day",
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=VOLUME_LITERS,
|
||||||
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="consumption_total",
|
key="consumption_total",
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
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.const import VOLUME_GALLONS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -80,6 +80,8 @@ class StreamlabsUsageData:
|
||||||
class StreamLabsDailyUsage(SensorEntity):
|
class StreamLabsDailyUsage(SensorEntity):
|
||||||
"""Monitors the daily water usage."""
|
"""Monitors the daily water usage."""
|
||||||
|
|
||||||
|
_attr_device_class = SensorDeviceClass.VOLUME
|
||||||
|
|
||||||
def __init__(self, location_name, streamlabs_usage_data):
|
def __init__(self, location_name, streamlabs_usage_data):
|
||||||
"""Initialize the daily water usage device."""
|
"""Initialize the daily water usage device."""
|
||||||
self._location_name = location_name
|
self._location_name = location_name
|
||||||
|
|
|
@ -8,7 +8,11 @@ from pysuez import SuezClient
|
||||||
from pysuez.client import PySuezError
|
from pysuez.client import PySuezError
|
||||||
import voluptuous as vol
|
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.const import CONF_PASSWORD, CONF_USERNAME, VOLUME_LITERS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -63,6 +67,7 @@ class SuezSensor(SensorEntity):
|
||||||
_attr_name = NAME
|
_attr_name = NAME
|
||||||
_attr_icon = ICON
|
_attr_icon = ICON
|
||||||
_attr_native_unit_of_measurement = VOLUME_LITERS
|
_attr_native_unit_of_measurement = VOLUME_LITERS
|
||||||
|
_attr_device_class = SensorDeviceClass.VOLUME
|
||||||
|
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
|
|
|
@ -87,6 +87,7 @@ class SureBattery(SurePetcareEntity, SensorEntity):
|
||||||
class Felaqua(SurePetcareEntity, SensorEntity):
|
class Felaqua(SurePetcareEntity, SensorEntity):
|
||||||
"""Sure Petcare Felaqua."""
|
"""Sure Petcare Felaqua."""
|
||||||
|
|
||||||
|
_attr_device_class = SensorDeviceClass.VOLUME
|
||||||
_attr_native_unit_of_measurement = VOLUME_MILLILITERS
|
_attr_native_unit_of_measurement = VOLUME_MILLILITERS
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue