Use UnitOfEnergy in integrations (o-z) (#84221)

This commit is contained in:
epenet 2022-12-19 10:58:37 +01:00 committed by GitHub
parent 3168b30535
commit ebdf9a8658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 120 additions and 134 deletions

View file

@ -9,11 +9,10 @@ from homeassistant.components.sensor import (
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR,
PERCENTAGE,
PRESSURE_BAR,
TEMP_CELSIUS,
UnitOfEnergy,
UnitOfPower,
UnitOfVolume,
)
@ -123,28 +122,28 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="electricity_consumed_interval",
name="Electricity consumed interval",
native_unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
),
SensorEntityDescription(
key="electricity_consumed_peak_interval",
name="Electricity consumed peak interval",
native_unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
),
SensorEntityDescription(
key="electricity_consumed_off_peak_interval",
name="Electricity consumed off peak interval",
native_unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
),
SensorEntityDescription(
key="electricity_produced_interval",
name="Electricity produced interval",
native_unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
entity_registry_enabled_default=False,
@ -152,14 +151,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="electricity_produced_peak_interval",
name="Electricity produced peak interval",
native_unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
),
SensorEntityDescription(
key="electricity_produced_off_peak_interval",
name="Electricity produced off peak interval",
native_unit_of_measurement=ENERGY_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
),
@ -180,14 +179,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="electricity_consumed_off_peak_cumulative",
name="Electricity consumed off peak cumulative",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="electricity_consumed_peak_cumulative",
name="Electricity consumed peak cumulative",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
@ -208,14 +207,14 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="electricity_produced_off_peak_cumulative",
name="Electricity produced off peak cumulative",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="electricity_produced_peak_cumulative",
name="Electricity produced peak cumulative",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
@ -243,7 +242,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="net_electricity_cumulative",
name="Net electricity cumulative",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL,
),