Use UnitOfVolume in integrations (#83646)
This commit is contained in:
parent
68efa37bff
commit
456c5515c8
17 changed files with 57 additions and 64 deletions
|
@ -28,7 +28,7 @@ from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CoreState, Event, HomeAssistant, callback
|
from homeassistant.core import CoreState, Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
|
@ -55,7 +55,7 @@ from .const import (
|
||||||
LOGGER,
|
LOGGER,
|
||||||
)
|
)
|
||||||
|
|
||||||
UNIT_CONVERSION = {"m3": VOLUME_CUBIC_METERS}
|
UNIT_CONVERSION = {"m3": UnitOfVolume.CUBIC_METERS}
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
|
@ -7,12 +7,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import PERCENTAGE, PRESSURE_PSI, TEMP_FAHRENHEIT, UnitOfVolume
|
||||||
PERCENTAGE,
|
|
||||||
PRESSURE_PSI,
|
|
||||||
TEMP_FAHRENHEIT,
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -68,7 +63,7 @@ class FloDailyUsageSensor(FloEntity, SensorEntity):
|
||||||
"""Monitors the daily water usage."""
|
"""Monitors the daily water usage."""
|
||||||
|
|
||||||
_attr_icon = WATER_ICON
|
_attr_icon = WATER_ICON
|
||||||
_attr_native_unit_of_measurement = VOLUME_GALLONS
|
_attr_native_unit_of_measurement = UnitOfVolume.GALLONS
|
||||||
_attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
|
_attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
|
||||||
_attr_device_class = SensorDeviceClass.WATER
|
_attr_device_class = SensorDeviceClass.WATER
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import VOLUME_GALLONS
|
from homeassistant.const import UnitOfVolume
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
@ -35,45 +35,45 @@ FLUME_QUERIES_SENSOR: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="current_interval",
|
key="current_interval",
|
||||||
name="Current",
|
name="Current",
|
||||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/m",
|
native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/m",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="month_to_date",
|
key="month_to_date",
|
||||||
name="Current Month",
|
name="Current Month",
|
||||||
native_unit_of_measurement=VOLUME_GALLONS,
|
native_unit_of_measurement=UnitOfVolume.GALLONS,
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="week_to_date",
|
key="week_to_date",
|
||||||
name="Current Week",
|
name="Current Week",
|
||||||
native_unit_of_measurement=VOLUME_GALLONS,
|
native_unit_of_measurement=UnitOfVolume.GALLONS,
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="today",
|
key="today",
|
||||||
name="Current Day",
|
name="Current Day",
|
||||||
native_unit_of_measurement=VOLUME_GALLONS,
|
native_unit_of_measurement=UnitOfVolume.GALLONS,
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="last_60_min",
|
key="last_60_min",
|
||||||
name="60 Minutes",
|
name="60 Minutes",
|
||||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/h",
|
native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/h",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="last_24_hrs",
|
key="last_24_hrs",
|
||||||
name="24 Hours",
|
name="24 Hours",
|
||||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/d",
|
native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/d",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="last_30_days",
|
key="last_30_days",
|
||||||
name="30 Days",
|
name="30 Days",
|
||||||
native_unit_of_measurement=f"{VOLUME_GALLONS}/mo",
|
native_unit_of_measurement=f"{UnitOfVolume.GALLONS}/mo",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,10 +24,10 @@ from homeassistant.const import (
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
PRESSURE_HPA,
|
PRESSURE_HPA,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
VOLUME_CUBIC_METERS,
|
|
||||||
UnitOfElectricCurrent,
|
UnitOfElectricCurrent,
|
||||||
UnitOfPrecipitationDepth,
|
UnitOfPrecipitationDepth,
|
||||||
UnitOfSpeed,
|
UnitOfSpeed,
|
||||||
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -154,13 +154,13 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
||||||
),
|
),
|
||||||
"GAS_POWER": SensorEntityDescription(
|
"GAS_POWER": SensorEntityDescription(
|
||||||
key="GAS_POWER",
|
key="GAS_POWER",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"GAS_ENERGY_COUNTER": SensorEntityDescription(
|
"GAS_ENERGY_COUNTER": SensorEntityDescription(
|
||||||
key="GAS_ENERGY_COUNTER",
|
key="GAS_ENERGY_COUNTER",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
@ -115,7 +115,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="total_gas_m3",
|
key="total_gas_m3",
|
||||||
name="Total gas",
|
name="Total gas",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
|
@ -129,7 +129,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="total_liter_m3",
|
key="total_liter_m3",
|
||||||
name="Total water usage",
|
name="Total water usage",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
icon="mdi:gauge",
|
icon="mdi:gauge",
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
||||||
PRESSURE_BAR,
|
PRESSURE_BAR,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TIME_HOURS,
|
TIME_HOURS,
|
||||||
VOLUME_LITERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
@ -102,7 +102,7 @@ SENSOR_TYPES = (
|
||||||
key="reservoir_content",
|
key="reservoir_content",
|
||||||
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=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -112,7 +112,7 @@ SENSOR_TYPES = (
|
||||||
key="total_saved",
|
key="total_saved",
|
||||||
name="Total saved",
|
name="Total saved",
|
||||||
icon="mdi:water-opacity",
|
icon="mdi:water-opacity",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -122,7 +122,7 @@ SENSOR_TYPES = (
|
||||||
key="total_replenished",
|
key="total_replenished",
|
||||||
name="Total replenished",
|
name="Total replenished",
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -140,7 +140,7 @@ SENSOR_TYPES = (
|
||||||
key="totver",
|
key="totver",
|
||||||
name="Total use",
|
name="Total use",
|
||||||
icon="mdi:chart-donut",
|
icon="mdi:chart-donut",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
@ -150,7 +150,7 @@ SENSOR_TYPES = (
|
||||||
key="reservoir_content_max",
|
key="reservoir_content_max",
|
||||||
name="Max reservoir content",
|
name="Max reservoir content",
|
||||||
icon="mdi:waves",
|
icon="mdi:waves",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
|
|
@ -22,7 +22,7 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, VOLUME_LITERS
|
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfVolume
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -39,7 +39,7 @@ SENSOR_DESCRIPTIONS = {
|
||||||
KegtronSensorDeviceClass.KEG_SIZE: SensorEntityDescription(
|
KegtronSensorDeviceClass.KEG_SIZE: SensorEntityDescription(
|
||||||
key=KegtronSensorDeviceClass.KEG_SIZE,
|
key=KegtronSensorDeviceClass.KEG_SIZE,
|
||||||
icon="mdi:keg",
|
icon="mdi:keg",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
|
@ -50,14 +50,14 @@ SENSOR_DESCRIPTIONS = {
|
||||||
KegtronSensorDeviceClass.VOLUME_START: SensorEntityDescription(
|
KegtronSensorDeviceClass.VOLUME_START: SensorEntityDescription(
|
||||||
key=KegtronSensorDeviceClass.VOLUME_START,
|
key=KegtronSensorDeviceClass.VOLUME_START,
|
||||||
icon="mdi:keg",
|
icon="mdi:keg",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
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=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.VOLUME,
|
device_class=SensorDeviceClass.VOLUME,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CURRENCY_CENT, VOLUME_LITERS
|
from homeassistant.const import CURRENCY_CENT, UnitOfVolume
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -127,7 +127,7 @@ class StationPriceSensor(
|
||||||
@property
|
@property
|
||||||
def native_unit_of_measurement(self) -> str:
|
def native_unit_of_measurement(self) -> str:
|
||||||
"""Return the units of measurement."""
|
"""Return the units of measurement."""
|
||||||
return f"{CURRENCY_CENT}/{VOLUME_LITERS}"
|
return f"{CURRENCY_CENT}/{UnitOfVolume.LITERS}"
|
||||||
|
|
||||||
def _get_station_name(self):
|
def _get_station_name(self):
|
||||||
default_name = f"station {self._station_id}"
|
default_name = f"station {self._station_id}"
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
VOLUME_LITERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -174,7 +174,7 @@ class OmniLogicSaltLevelSensor(OmnilogicSensor):
|
||||||
|
|
||||||
if self._unit_type == "Metric":
|
if self._unit_type == "Metric":
|
||||||
salt_return = round(int(salt_return) / 1000, 2)
|
salt_return = round(int(salt_return) / 1000, 2)
|
||||||
unit_of_measurement = f"{MASS_GRAMS}/{VOLUME_LITERS}"
|
unit_of_measurement = f"{MASS_GRAMS}/{UnitOfVolume.LITERS}"
|
||||||
|
|
||||||
self._unit = unit_of_measurement
|
self._unit = unit_of_measurement
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@ from homeassistant.const import (
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
VOLUME_CUBIC_METERS,
|
|
||||||
VOLUME_LITERS,
|
|
||||||
UnitOfElectricCurrent,
|
UnitOfElectricCurrent,
|
||||||
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||||
|
@ -42,7 +41,7 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = (
|
||||||
key="gas_consumption",
|
key="gas_consumption",
|
||||||
name="Gas Consumption",
|
name="Gas Consumption",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
|
@ -188,7 +187,7 @@ SENSORS_SETTINGS: tuple[SensorEntityDescription, ...] = (
|
||||||
name="Gas Consumption Price",
|
name="Gas Consumption Price",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{VOLUME_CUBIC_METERS}",
|
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfVolume.CUBIC_METERS}",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="energy_consumption_price_low",
|
key="energy_consumption_price_low",
|
||||||
|
@ -221,14 +220,14 @@ SENSORS_WATERMETER: tuple[SensorEntityDescription, ...] = (
|
||||||
key="consumption_day",
|
key="consumption_day",
|
||||||
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=UnitOfVolume.LITERS,
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="consumption_total",
|
key="consumption_total",
|
||||||
name="Consumption Total",
|
name="Consumption Total",
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.WATER,
|
device_class=SensorDeviceClass.WATER,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
PRESSURE_BAR,
|
PRESSURE_BAR,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
@ -222,14 +222,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="gas_consumed_interval",
|
key="gas_consumed_interval",
|
||||||
name="Gas consumed interval",
|
name="Gas consumed interval",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="gas_consumed_cumulative",
|
key="gas_consumed_cumulative",
|
||||||
name="Gas consumed cumulative",
|
name="Gas consumed cumulative",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
state_class=SensorStateClass.TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
),
|
),
|
||||||
|
|
|
@ -29,7 +29,7 @@ from homeassistant.const import (
|
||||||
POWER_KILO_WATT,
|
POWER_KILO_WATT,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TIME_MINUTES,
|
TIME_MINUTES,
|
||||||
VOLUME_LITERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -312,7 +312,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = (
|
||||||
entity_class=RenaultSensor[KamereonVehicleCockpitData],
|
entity_class=RenaultSensor[KamereonVehicleCockpitData],
|
||||||
icon="mdi:fuel",
|
icon="mdi:fuel",
|
||||||
name="Fuel quantity",
|
name="Fuel quantity",
|
||||||
native_unit_of_measurement=VOLUME_LITERS,
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
requires_fuel=True,
|
requires_fuel=True,
|
||||||
value_lambda=_get_rounded_value,
|
value_lambda=_get_rounded_value,
|
||||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.const import (
|
||||||
LENGTH_KILOMETERS,
|
LENGTH_KILOMETERS,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
VOLUME_LITERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -160,7 +160,7 @@ class StarlineSensor(StarlineEntity, SensorEntity):
|
||||||
if type_value == "percents":
|
if type_value == "percents":
|
||||||
return PERCENTAGE
|
return PERCENTAGE
|
||||||
if type_value == "litres":
|
if type_value == "litres":
|
||||||
return VOLUME_LITERS
|
return UnitOfVolume.LITERS
|
||||||
return self.entity_description.native_unit_of_measurement
|
return self.entity_description.native_unit_of_measurement
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -18,8 +18,7 @@ from homeassistant.const import (
|
||||||
LENGTH_MILES,
|
LENGTH_MILES,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRESSURE_HPA,
|
PRESSURE_HPA,
|
||||||
VOLUME_GALLONS,
|
UnitOfVolume,
|
||||||
VOLUME_LITERS,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
@ -55,7 +54,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS = "L/100km"
|
FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS = "L/100km"
|
||||||
FUEL_CONSUMPTION_MILES_PER_GALLON = "mi/gal"
|
FUEL_CONSUMPTION_MILES_PER_GALLON = "mi/gal"
|
||||||
|
|
||||||
L_PER_GAL = VolumeConverter.convert(1, VOLUME_GALLONS, VOLUME_LITERS)
|
L_PER_GAL = VolumeConverter.convert(1, UnitOfVolume.GALLONS, UnitOfVolume.LITERS)
|
||||||
KM_PER_MI = DistanceConverter.convert(1, LENGTH_MILES, LENGTH_KILOMETERS)
|
KM_PER_MI = DistanceConverter.convert(1, LENGTH_MILES, LENGTH_KILOMETERS)
|
||||||
|
|
||||||
# Sensor available to "Subaru Safety Plus" subscribers with Gen1 or Gen2 vehicles
|
# Sensor available to "Subaru Safety Plus" subscribers with Gen1 or Gen2 vehicles
|
||||||
|
|
|
@ -9,7 +9,7 @@ from surepy.enums import EntityType
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_VOLTAGE, PERCENTAGE, VOLUME_MILLILITERS
|
from homeassistant.const import ATTR_VOLTAGE, PERCENTAGE, UnitOfVolume
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -88,7 +88,7 @@ class Felaqua(SurePetcareEntity, SensorEntity):
|
||||||
"""Sure Petcare Felaqua."""
|
"""Sure Petcare Felaqua."""
|
||||||
|
|
||||||
_attr_device_class = SensorDeviceClass.VOLUME
|
_attr_device_class = SensorDeviceClass.VOLUME
|
||||||
_attr_native_unit_of_measurement = VOLUME_MILLILITERS
|
_attr_native_unit_of_measurement = UnitOfVolume.MILLILITERS
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, surepetcare_id: int, coordinator: SurePetcareDataCoordinator
|
self, surepetcare_id: int, coordinator: SurePetcareDataCoordinator
|
||||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -164,7 +164,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||||
section="gas_usage",
|
section="gas_usage",
|
||||||
measurement="day_average",
|
measurement="day_average",
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
cls=ToonGasMeterDeviceSensor,
|
cls=ToonGasMeterDeviceSensor,
|
||||||
),
|
),
|
||||||
|
@ -174,7 +174,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||||
section="gas_usage",
|
section="gas_usage",
|
||||||
measurement="day_usage",
|
measurement="day_usage",
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
cls=ToonGasMeterDeviceSensor,
|
cls=ToonGasMeterDeviceSensor,
|
||||||
),
|
),
|
||||||
ToonSensorEntityDescription(
|
ToonSensorEntityDescription(
|
||||||
|
@ -193,7 +193,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||||
name="Gas Meter",
|
name="Gas Meter",
|
||||||
section="gas_usage",
|
section="gas_usage",
|
||||||
measurement="meter",
|
measurement="meter",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.GAS,
|
device_class=SensorDeviceClass.GAS,
|
||||||
cls=ToonGasMeterDeviceSensor,
|
cls=ToonGasMeterDeviceSensor,
|
||||||
|
@ -312,7 +312,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||||
name="Average Daily Water Usage",
|
name="Average Daily Water Usage",
|
||||||
section="water_usage",
|
section="water_usage",
|
||||||
measurement="day_average",
|
measurement="day_average",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
cls=ToonWaterMeterDeviceSensor,
|
cls=ToonWaterMeterDeviceSensor,
|
||||||
|
@ -323,7 +323,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||||
name="Water Usage Today",
|
name="Water Usage Today",
|
||||||
section="water_usage",
|
section="water_usage",
|
||||||
measurement="day_usage",
|
measurement="day_usage",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
cls=ToonWaterMeterDeviceSensor,
|
cls=ToonWaterMeterDeviceSensor,
|
||||||
|
@ -334,7 +334,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
||||||
name="Water Meter",
|
name="Water Meter",
|
||||||
section="water_usage",
|
section="water_usage",
|
||||||
measurement="meter",
|
measurement="meter",
|
||||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||||
icon="mdi:water",
|
icon="mdi:water",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
VOLUME_CUBIC_METERS,
|
UnitOfVolume,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -98,7 +98,7 @@ class YoulessBaseSensor(CoordinatorEntity, SensorEntity):
|
||||||
class GasSensor(YoulessBaseSensor):
|
class GasSensor(YoulessBaseSensor):
|
||||||
"""The Youless gas sensor."""
|
"""The Youless gas sensor."""
|
||||||
|
|
||||||
_attr_native_unit_of_measurement = VOLUME_CUBIC_METERS
|
_attr_native_unit_of_measurement = UnitOfVolume.CUBIC_METERS
|
||||||
_attr_device_class = SensorDeviceClass.GAS
|
_attr_device_class = SensorDeviceClass.GAS
|
||||||
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue