Use UnitOfEnergy in integrations (o-z) (#84221)
parent
3168b30535
commit
ebdf9a8658
|
@ -11,13 +11,13 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
PRESSURE_PSI,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -152,7 +152,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
),
|
||||
SensorEntityDescription(
|
||||
key="GensetTotalEnergy",
|
||||
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,
|
||||
),
|
||||
|
|
|
@ -17,9 +17,9 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_MONITORED_VARIABLES,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
TIME_MINUTES,
|
||||
UnitOfEnergy,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -64,14 +64,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key="usage_session",
|
||||
name="Usage this Session",
|
||||
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="usage_total",
|
||||
name="Total Usage",
|
||||
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,
|
||||
),
|
||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.const import UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
@ -46,7 +46,7 @@ SENSOR_TYPES_ELECTRICITY: tuple[OVOEnergySensorEntityDescription, ...] = (
|
|||
name="OVO Last Electricity Reading",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda usage: usage.electricity[-1].consumption,
|
||||
),
|
||||
OVOEnergySensorEntityDescription(
|
||||
|
@ -80,7 +80,7 @@ SENSOR_TYPES_GAS: tuple[OVOEnergySensorEntityDescription, ...] = (
|
|||
name="OVO Last Gas Reading",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
icon="mdi:gas-cylinder",
|
||||
value=lambda usage: usage.gas[-1].consumption,
|
||||
),
|
||||
|
|
|
@ -14,9 +14,9 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CURRENCY_EURO,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
|
@ -55,14 +55,14 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key="energy_consumption_high",
|
||||
name="Energy Consumption - High Tariff",
|
||||
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="energy_consumption_low",
|
||||
name="Energy Consumption - Low Tariff",
|
||||
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,
|
||||
),
|
||||
|
@ -76,14 +76,14 @@ SENSORS_SMARTMETER: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key="energy_production_high",
|
||||
name="Energy Production - High Tariff",
|
||||
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="energy_production_low",
|
||||
name="Energy Production - Low Tariff",
|
||||
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,
|
||||
),
|
||||
|
@ -193,25 +193,25 @@ SENSORS_SETTINGS: tuple[SensorEntityDescription, ...] = (
|
|||
key="energy_consumption_price_low",
|
||||
name="Energy Consumption Price - Low",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_consumption_price_high",
|
||||
name="Energy Consumption Price - High",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_production_price_low",
|
||||
name="Energy Production Price - Low",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_production_price_high",
|
||||
name="Energy Production Price - High",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
|
|
|
@ -14,10 +14,10 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -203,7 +203,7 @@ class PowerWallEnergyDirectionSensor(PowerWallEntity, SensorEntity):
|
|||
"""Representation of an Powerwall Direction Energy sensor."""
|
||||
|
||||
_attr_state_class = SensorStateClass.TOTAL
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import CONF_HOST, UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -48,7 +48,7 @@ SENSORS: tuple[PureEnergieSensorEntityDescription, ...] = (
|
|||
PureEnergieSensorEntityDescription(
|
||||
key="energy_consumption_total",
|
||||
name="Energy Consumption",
|
||||
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,
|
||||
value_fn=lambda data: data.smartbridge.energy_consumption_total,
|
||||
|
@ -56,7 +56,7 @@ SENSORS: tuple[PureEnergieSensorEntityDescription, ...] = (
|
|||
PureEnergieSensorEntityDescription(
|
||||
key="energy_production_total",
|
||||
name="Energy Production",
|
||||
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,
|
||||
value_fn=lambda data: data.smartbridge.energy_production_total,
|
||||
|
|
|
@ -14,10 +14,9 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -47,7 +46,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = (
|
|||
PVOutputSensorEntityDescription(
|
||||
key="energy_consumption",
|
||||
name="Energy consumed",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda status: status.energy_consumption,
|
||||
|
@ -55,7 +54,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = (
|
|||
PVOutputSensorEntityDescription(
|
||||
key="energy_generation",
|
||||
name="Energy generated",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda status: status.energy_generation,
|
||||
|
@ -63,7 +62,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = (
|
|||
PVOutputSensorEntityDescription(
|
||||
key="normalized_output",
|
||||
name="Efficiency",
|
||||
native_unit_of_measurement=f"{ENERGY_KILO_WATT_HOUR}/{UnitOfPower.KILO_WATT}",
|
||||
native_unit_of_measurement=f"{UnitOfEnergy.KILO_WATT_HOUR}/{UnitOfPower.KILO_WATT}",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda status: status.normalized_output,
|
||||
),
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME, CURRENCY_EURO, ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.const import CONF_NAME, CURRENCY_EURO, UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
@ -30,7 +30,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key="PVPC",
|
||||
icon="mdi:currency-eur",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{ENERGY_KILO_WATT_HOUR}",
|
||||
native_unit_of_measurement=f"{CURRENCY_EURO}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -30,14 +30,14 @@ SENSORS = (
|
|||
SensorEntityDescription(
|
||||
key="zigbee:CurrentSummationDelivered",
|
||||
name="Eagle-200 Total Meter Energy Delivered",
|
||||
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="zigbee:CurrentSummationReceived",
|
||||
name="Eagle-200 Total Meter Energy Received",
|
||||
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,
|
||||
),
|
||||
|
@ -58,7 +58,7 @@ async def async_setup_entry(
|
|||
SensorEntityDescription(
|
||||
key="zigbee:Price",
|
||||
name="Meter Price",
|
||||
native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{ENERGY_KILO_WATT_HOUR}",
|
||||
native_unit_of_measurement=f"{coordinator.data['zigbee:PriceCurrency']}/{UnitOfEnergy.KILO_WATT_HOUR}",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -23,10 +23,10 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
TIME_MINUTES,
|
||||
UnitOfEnergy,
|
||||
UnitOfLength,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
|
@ -256,7 +256,7 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription[Any], ...] = (
|
|||
entity_class=RenaultSensor[KamereonVehicleBatteryStatusData],
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
name="Battery available energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
RenaultSensorEntityDescription(
|
||||
|
|
|
@ -18,12 +18,12 @@ from homeassistant.const import (
|
|||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
DEGREE,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -163,7 +163,7 @@ SENSORS: Final = {
|
|||
("device", "energy"): BlockSensorDescription(
|
||||
key="device|energy",
|
||||
name="Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda value: round(value / 60 / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -171,7 +171,7 @@ SENSORS: Final = {
|
|||
("emeter", "energy"): BlockSensorDescription(
|
||||
key="emeter|energy",
|
||||
name="Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda value: round(value / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -180,7 +180,7 @@ SENSORS: Final = {
|
|||
("emeter", "energyReturned"): BlockSensorDescription(
|
||||
key="emeter|energyReturned",
|
||||
name="Energy Returned",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda value: round(value / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -189,7 +189,7 @@ SENSORS: Final = {
|
|||
("light", "energy"): BlockSensorDescription(
|
||||
key="light|energy",
|
||||
name="Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda value: round(value / 60 / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -198,7 +198,7 @@ SENSORS: Final = {
|
|||
("relay", "energy"): BlockSensorDescription(
|
||||
key="relay|energy",
|
||||
name="Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda value: round(value / 60 / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -206,7 +206,7 @@ SENSORS: Final = {
|
|||
("roller", "rollerEnergy"): BlockSensorDescription(
|
||||
key="roller|rollerEnergy",
|
||||
name="Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda value: round(value / 60 / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -336,7 +336,7 @@ RPC_SENSORS: Final = {
|
|||
key="switch",
|
||||
sub_key="aenergy",
|
||||
name="Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
value=lambda status, _: round(status["total"] / 1000, 2),
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -70,7 +70,7 @@ class SMAsensor(CoordinatorEntity, SensorEntity):
|
|||
self._config_entry_unique_id = config_entry_unique_id
|
||||
self._attr_device_info = device_info
|
||||
|
||||
if self.native_unit_of_measurement == ENERGY_KILO_WATT_HOUR:
|
||||
if self.native_unit_of_measurement == UnitOfEnergy.KILO_WATT_HOUR:
|
||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||
if self.native_unit_of_measurement == UnitOfPower.WATT:
|
||||
|
|
|
@ -10,12 +10,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.const import UnitOfElectricPotential, UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -70,7 +65,7 @@ TREND_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="power_today",
|
||||
name="Total consumption - Today",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
sensor_id="power_today",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -78,7 +73,7 @@ TREND_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="power_current_hour",
|
||||
name="Total consumption - Current hour",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
sensor_id="power_current_hour",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -86,7 +81,7 @@ TREND_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="power_last_5_minutes",
|
||||
name="Total consumption - Last 5 minutes",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
sensor_id="power_last_5_minutes",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -94,7 +89,7 @@ TREND_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="alwayson_today",
|
||||
name="Always on - Today",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
sensor_id="alwayson_today",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -123,7 +118,7 @@ SOLAR_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="solar_today",
|
||||
name="Total production - Today",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
sensor_id="solar_today",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -131,7 +126,7 @@ SOLAR_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="solar_current_hour",
|
||||
name="Total production - Current hour",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
sensor_id="solar_current_hour",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -317,7 +312,7 @@ async def async_setup_entry(
|
|||
description=SmappeeSensorEntityDescription(
|
||||
key="switch",
|
||||
name=f"{actuator.name} - energy today",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
sensor_id=actuator_id,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ADDRESS, ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.const import CONF_ADDRESS, UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
@ -45,7 +45,7 @@ class SmartMeterTexasSensor(CoordinatorEntity, RestoreEntity, SensorEntity):
|
|||
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
|
||||
def __init__(self, meter: Meter, coordinator: DataUpdateCoordinator) -> None:
|
||||
"""Initialize the sensor."""
|
||||
|
|
|
@ -3,7 +3,7 @@ from datetime import timedelta
|
|||
import logging
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import ENERGY_WATT_HOUR, PERCENTAGE, UnitOfPower
|
||||
from homeassistant.const import PERCENTAGE, UnitOfEnergy, UnitOfPower
|
||||
|
||||
from .models import SolarEdgeSensorEntityDescription
|
||||
|
||||
|
@ -34,7 +34,7 @@ SENSOR_TYPES = [
|
|||
name="Lifetime energy",
|
||||
icon="mdi:solar-power",
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -43,7 +43,7 @@ SENSOR_TYPES = [
|
|||
name="Energy this year",
|
||||
entity_registry_enabled_default=False,
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -52,7 +52,7 @@ SENSOR_TYPES = [
|
|||
name="Energy this month",
|
||||
entity_registry_enabled_default=False,
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -61,7 +61,7 @@ SENSOR_TYPES = [
|
|||
name="Energy today",
|
||||
entity_registry_enabled_default=False,
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -143,7 +143,7 @@ SENSOR_TYPES = [
|
|||
name="Imported Energy",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -152,7 +152,7 @@ SENSOR_TYPES = [
|
|||
name="Production Energy",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -161,7 +161,7 @@ SENSOR_TYPES = [
|
|||
name="Consumption Energy",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -170,7 +170,7 @@ SENSOR_TYPES = [
|
|||
name="SelfConsumption Energy",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
@ -179,7 +179,7 @@ SENSOR_TYPES = [
|
|||
name="Exported Energy",
|
||||
entity_registry_enabled_default=False,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
|
|
@ -17,10 +17,10 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -46,13 +46,13 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = {
|
|||
(Units.KWH, False): SensorEntityDescription(
|
||||
key=f"{Units.KWH}_{False}",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(Units.KWH, True): SensorEntityDescription(
|
||||
key=f"{Units.KWH}_{True}",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
(Units.V, False): SensorEntityDescription(
|
||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -32,7 +32,7 @@ async def async_setup_entry(
|
|||
class SpiderPowerPlugEnergy(SensorEntity):
|
||||
"""Representation of a Spider Power Plug (energy)."""
|
||||
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.const import UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -91,7 +91,7 @@ class SrpEntity(SensorEntity):
|
|||
self._name = SENSOR_NAME
|
||||
self.type = SENSOR_TYPE
|
||||
self.coordinator = coordinator
|
||||
self._unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
self._unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
|
|
|
@ -20,7 +20,6 @@ from homeassistant.const import (
|
|||
CONCENTRATION_PARTS_PER_BILLION,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
PRESSURE_HPA,
|
||||
|
@ -34,6 +33,7 @@ from homeassistant.const import (
|
|||
TEMP_KELVIN,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfLength,
|
||||
UnitOfMass,
|
||||
|
@ -215,7 +215,7 @@ SENSOR_UNIT_MAP = {
|
|||
hc.CONCENTRATION_PARTS_PER_MILLION: CONCENTRATION_PARTS_PER_MILLION,
|
||||
hc.ELECTRICAL_CURRENT_AMPERE: ELECTRIC_CURRENT_AMPERE,
|
||||
hc.ELECTRICAL_VOLT_AMPERE: UnitOfApparentPower.VOLT_AMPERE,
|
||||
hc.ENERGY_KILO_WATT_HOUR: ENERGY_KILO_WATT_HOUR,
|
||||
hc.ENERGY_KILO_WATT_HOUR: UnitOfEnergy.KILO_WATT_HOUR,
|
||||
hc.FREQUENCY_HERTZ: UnitOfFrequency.HERTZ,
|
||||
hc.LENGTH_CENTIMETERS: UnitOfLength.CENTIMETERS,
|
||||
hc.LIGHT_LUX: LIGHT_LUX,
|
||||
|
|
|
@ -11,9 +11,9 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
|
@ -222,7 +222,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Average Daily Energy Usage",
|
||||
section="power_usage",
|
||||
measurement="day_average",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
entity_registry_enabled_default=False,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -243,7 +243,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Energy Usage Today",
|
||||
section="power_usage",
|
||||
measurement="day_usage",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
),
|
||||
|
@ -252,7 +252,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Electricity Meter Feed IN Tariff 1",
|
||||
section="power_usage",
|
||||
measurement="meter_high",
|
||||
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,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -262,7 +262,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Electricity Meter Feed IN Tariff 2",
|
||||
section="power_usage",
|
||||
measurement="meter_low",
|
||||
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,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -282,7 +282,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Electricity Meter Feed OUT Tariff 1",
|
||||
section="power_usage",
|
||||
measurement="meter_produced_high",
|
||||
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,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -292,7 +292,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Electricity Meter Feed OUT Tariff 2",
|
||||
section="power_usage",
|
||||
measurement="meter_produced_low",
|
||||
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,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -401,7 +401,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Solar Energy Produced Today",
|
||||
section="power_usage",
|
||||
measurement="day_produced_solar",
|
||||
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,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
|
@ -411,7 +411,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Energy Produced To Grid Today",
|
||||
section="power_usage",
|
||||
measurement="day_to_grid_usage",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
entity_registry_enabled_default=False,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
|
@ -421,7 +421,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Energy Usage From Grid Today",
|
||||
section="power_usage",
|
||||
measurement="day_from_grid_usage",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
entity_registry_enabled_default=False,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
|
|
|
@ -16,8 +16,8 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ATTR_VOLTAGE,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -55,7 +55,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
|||
),
|
||||
TPLinkSensorEntityDescription(
|
||||
key=ATTR_TOTAL_ENERGY_KWH,
|
||||
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,
|
||||
name="Total Consumption",
|
||||
|
@ -64,7 +64,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
|||
),
|
||||
TPLinkSensorEntityDescription(
|
||||
key=ATTR_TODAY_ENERGY_KWH,
|
||||
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,
|
||||
name="Today's Consumption",
|
||||
|
|
|
@ -16,8 +16,6 @@ from homeassistant.const import (
|
|||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_CURRENT_MILLIAMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
PRESSURE_BAR,
|
||||
|
@ -34,6 +32,7 @@ from homeassistant.const import (
|
|||
VOLUME_CUBIC_METERS,
|
||||
Platform,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
||||
|
@ -441,12 +440,12 @@ UNITS = (
|
|||
conversion_fn=lambda x: x / 1000,
|
||||
),
|
||||
UnitOfMeasurement(
|
||||
unit=ENERGY_WATT_HOUR,
|
||||
unit=UnitOfEnergy.WATT_HOUR,
|
||||
aliases={"wh", "watthour"},
|
||||
device_classes={SensorDeviceClass.ENERGY},
|
||||
),
|
||||
UnitOfMeasurement(
|
||||
unit=ENERGY_KILO_WATT_HOUR,
|
||||
unit=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
aliases={"kwh", "kilowatt-hour", "kW·h"},
|
||||
device_classes={SensorDeviceClass.ENERGY},
|
||||
),
|
||||
|
|
|
@ -22,10 +22,9 @@ from homeassistant.const import (
|
|||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONF_NAME,
|
||||
CONF_UNIQUE_ID,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_UNKNOWN,
|
||||
UnitOfEnergy,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_platform, entity_registry as er
|
||||
|
@ -88,8 +87,8 @@ ATTR_LAST_PERIOD = "last_period"
|
|||
ATTR_TARIFF = "tariff"
|
||||
|
||||
DEVICE_CLASS_MAP = {
|
||||
ENERGY_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||
ENERGY_KILO_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||
UnitOfEnergy.WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||
UnitOfEnergy.KILO_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||
}
|
||||
|
||||
ICON = "mdi:counter"
|
||||
|
|
|
@ -18,9 +18,9 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -115,7 +115,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = (
|
|||
key="energy",
|
||||
name="energy use today",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda device: device.energy_today,
|
||||
update_fn=update_energy,
|
||||
|
@ -125,7 +125,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = (
|
|||
key="energy-weekly",
|
||||
name="energy use weekly",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda device: device.weekly_energy_total,
|
||||
update_fn=update_energy,
|
||||
|
@ -135,7 +135,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = (
|
|||
key="energy-monthly",
|
||||
name="energy use monthly",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda device: device.monthly_energy_total,
|
||||
update_fn=update_energy,
|
||||
|
@ -145,7 +145,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = (
|
|||
key="energy-yearly",
|
||||
name="energy use yearly",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda device: device.yearly_energy_total,
|
||||
update_fn=update_energy,
|
||||
|
|
|
@ -14,8 +14,8 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfEnergy,
|
||||
UnitOfLength,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
|
|||
key=CHARGER_ADDED_ENERGY_KEY,
|
||||
name="Added Energy",
|
||||
precision=2,
|
||||
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,
|
||||
),
|
||||
|
@ -102,7 +102,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
|
|||
key=CHARGER_ADDED_DISCHARGED_ENERGY_KEY,
|
||||
name="Discharged Energy",
|
||||
precision=2,
|
||||
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,
|
||||
),
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -46,7 +46,7 @@ ATTRIBUTE_SENSORS = (
|
|||
name="Today Energy",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
key="today_kwh",
|
||||
unique_id_suffix="todaymw",
|
||||
state_conversion=lambda state: round(cast(float, state), 2),
|
||||
|
|
|
@ -9,12 +9,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.const import CONF_DEVICE, UnitOfEnergy, UnitOfPower, UnitOfVolume
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -136,7 +131,7 @@ class CurrentPowerSensor(YoulessBaseSensor):
|
|||
class DeliveryMeterSensor(YoulessBaseSensor):
|
||||
"""The Youless delivery meter value sensor."""
|
||||
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
|
@ -162,7 +157,7 @@ class DeliveryMeterSensor(YoulessBaseSensor):
|
|||
class EnergyMeterSensor(YoulessBaseSensor):
|
||||
"""The Youless low meter value sensor."""
|
||||
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
|
@ -194,7 +189,7 @@ class EnergyMeterSensor(YoulessBaseSensor):
|
|||
class ExtraMeterSensor(YoulessBaseSensor):
|
||||
"""The Youless extra meter value sensor (s0)."""
|
||||
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
_attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
PRESSURE_KPA,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -78,7 +78,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = {
|
|||
"meterElectric_kilowatt_hour": ZWaveMeSensorEntityDescription(
|
||||
key="meterElectric_kilowatt_hour",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
"meterElectric_power_factor": ZWaveMeSensorEntityDescription(
|
||||
|
|
Loading…
Reference in New Issue