mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Use VOLUME device_class in flume (#79585)
This commit is contained in:
parent
253f6616cf
commit
f3e05534ee
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.components.sensor import SensorEntityDescription
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "flume"
|
||||
@ -19,43 +18,6 @@ DEVICE_SCAN_INTERVAL = timedelta(minutes=1)
|
||||
_LOGGER = logging.getLogger(__package__)
|
||||
|
||||
FLUME_TYPE_SENSOR = 2
|
||||
FLUME_QUERIES_SENSOR: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="current_interval",
|
||||
name="Current",
|
||||
native_unit_of_measurement="gal/m",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="month_to_date",
|
||||
name="Current Month",
|
||||
native_unit_of_measurement="gal",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="week_to_date",
|
||||
name="Current Week",
|
||||
native_unit_of_measurement="gal",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="today",
|
||||
name="Current Day",
|
||||
native_unit_of_measurement="gal",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_60_min",
|
||||
name="60 Minutes",
|
||||
native_unit_of_measurement="gal/h",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_24_hrs",
|
||||
name="24 Hours",
|
||||
native_unit_of_measurement="gal/d",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_30_days",
|
||||
name="30 Days",
|
||||
native_unit_of_measurement="gal/mo",
|
||||
),
|
||||
)
|
||||
|
||||
FLUME_AUTH = "flume_auth"
|
||||
FLUME_HTTP_SESSION = "http_session"
|
||||
|
@ -3,8 +3,13 @@ from numbers import Number
|
||||
|
||||
from pyflume import FlumeData
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import VOLUME_GALLONS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
@ -14,7 +19,6 @@ from .const import (
|
||||
FLUME_AUTH,
|
||||
FLUME_DEVICES,
|
||||
FLUME_HTTP_SESSION,
|
||||
FLUME_QUERIES_SENSOR,
|
||||
FLUME_TYPE_SENSOR,
|
||||
KEY_DEVICE_ID,
|
||||
KEY_DEVICE_LOCATION,
|
||||
@ -24,6 +28,47 @@ from .const import (
|
||||
from .coordinator import FlumeDeviceDataUpdateCoordinator
|
||||
from .entity import FlumeEntity
|
||||
|
||||
FLUME_QUERIES_SENSOR: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="current_interval",
|
||||
name="Current",
|
||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/m",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="month_to_date",
|
||||
name="Current Month",
|
||||
native_unit_of_measurement=VOLUME_GALLONS,
|
||||
device_class=SensorDeviceClass.VOLUME,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="week_to_date",
|
||||
name="Current Week",
|
||||
native_unit_of_measurement=VOLUME_GALLONS,
|
||||
device_class=SensorDeviceClass.VOLUME,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="today",
|
||||
name="Current Day",
|
||||
native_unit_of_measurement=VOLUME_GALLONS,
|
||||
device_class=SensorDeviceClass.VOLUME,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_60_min",
|
||||
name="60 Minutes",
|
||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/h",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_24_hrs",
|
||||
name="24 Hours",
|
||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/d",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="last_30_days",
|
||||
name="30 Days",
|
||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/mo",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user