Use UnitOfEnergy in integrations (a-n) (#84220)
parent
ebdf9a8658
commit
0dd20fb309
|
@ -20,7 +20,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CURRENCY_DOLLAR, ENERGY_KILO_WATT_HOUR, PERCENTAGE
|
||||
from homeassistant.const import CURRENCY_DOLLAR, PERCENTAGE, UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
@ -34,7 +34,7 @@ ICONS = {
|
|||
"feed_in": "mdi:solar-power",
|
||||
}
|
||||
|
||||
UNIT = f"{CURRENCY_DOLLAR}/{ENERGY_KILO_WATT_HOUR}"
|
||||
UNIT = f"{CURRENCY_DOLLAR}/{UnitOfEnergy.KILO_WATT_HOUR}"
|
||||
|
||||
|
||||
def format_cents_to_dollars(cents: float) -> float:
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -266,7 +266,7 @@ class AtomeSensor(SensorEntity):
|
|||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
else:
|
||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||
self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
self._attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
def update(self) -> None:
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS, UnitOfPower
|
||||
from homeassistant.const import TEMP_CELSIUS, UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -43,7 +43,7 @@ SENSOR_TYPES = [
|
|||
SensorEntityDescription(
|
||||
key="totalenergy",
|
||||
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,
|
||||
name="Total Energy",
|
||||
),
|
||||
|
|
|
@ -12,9 +12,9 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -321,7 +321,7 @@ class EnergySensor(SHCEntity, 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, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||
"""Initialize an SHC energy reporting sensor."""
|
||||
|
|
|
@ -9,11 +9,11 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -81,7 +81,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key="totalconsum",
|
||||
name="Total 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,
|
||||
),
|
||||
|
|
|
@ -38,12 +38,12 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.const import (
|
||||
CONF_RESOURCES,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
REVOLUTIONS_PER_MINUTE,
|
||||
TEMP_CELSIUS,
|
||||
TIME_DAYS,
|
||||
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -249,7 +249,7 @@ SENSOR_TYPES = (
|
|||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
name="Energy total",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
sensor_id=SENSOR_POWER_TOTAL,
|
||||
),
|
||||
ComfoconnectSensorEntityDescription(
|
||||
|
@ -265,7 +265,7 @@ SENSOR_TYPES = (
|
|||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
name="Preheater energy total",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
sensor_id=SENSOR_PREHEATER_POWER_TOTAL,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -14,9 +14,9 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -98,7 +98,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
name="Cool energy consumption",
|
||||
icon="mdi:snowflake",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
entity_registry_enabled_default=False,
|
||||
value_func=lambda device: round(device.last_hour_cool_energy_consumption, 2),
|
||||
),
|
||||
|
@ -107,7 +107,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
name="Heat energy consumption",
|
||||
icon="mdi:fire",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
entity_registry_enabled_default=False,
|
||||
value_func=lambda device: round(device.last_hour_heat_energy_consumption, 2),
|
||||
),
|
||||
|
@ -116,7 +116,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
name="Energy consumption",
|
||||
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_func=lambda device: round(device.today_energy_consumption, 2),
|
||||
),
|
||||
DaikinSensorEntityDescription(
|
||||
|
@ -134,7 +134,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
name="Compressor energy consumption",
|
||||
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,
|
||||
entity_registry_enabled_default=False,
|
||||
value_func=lambda device: round(device.today_total_energy_consumption, 2),
|
||||
),
|
||||
|
|
|
@ -34,11 +34,11 @@ from homeassistant.const import (
|
|||
ATTR_TEMPERATURE,
|
||||
ATTR_VOLTAGE,
|
||||
CONCENTRATION_PARTS_PER_BILLION,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
PRESSURE_HPA,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -134,7 +134,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (
|
|||
instance_check=Consumption,
|
||||
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,
|
||||
),
|
||||
DeconzSensorDescription[Daylight](
|
||||
key="daylight_status",
|
||||
|
|
|
@ -12,15 +12,15 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.const import (
|
||||
CURRENCY_EURO,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
VOLUME_CUBIC_METERS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
PRICE_EUR_KWH: Final = f"EUR/{ENERGY_KILO_WATT_HOUR}"
|
||||
PRICE_EUR_KWH: Final = f"EUR/{UnitOfEnergy.KILO_WATT_HOUR}"
|
||||
PRICE_EUR_M3: Final = f"EUR/{VOLUME_CUBIC_METERS}"
|
||||
|
||||
|
||||
|
@ -50,28 +50,28 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
|
|||
key="dsmr/reading/electricity_delivered_1",
|
||||
name="Low tariff usage",
|
||||
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,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/reading/electricity_returned_1",
|
||||
name="Low tariff returned",
|
||||
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,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/reading/electricity_delivered_2",
|
||||
name="High tariff usage",
|
||||
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,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/reading/electricity_returned_2",
|
||||
name="High tariff returned",
|
||||
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,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
|
@ -224,37 +224,37 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
|
|||
key="dsmr/day-consumption/electricity1",
|
||||
name="Low tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/day-consumption/electricity2",
|
||||
name="High tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/day-consumption/electricity1_returned",
|
||||
name="Low tariff return",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/day-consumption/electricity2_returned",
|
||||
name="High tariff return",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/day-consumption/electricity_merged",
|
||||
name="Power usage total",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/day-consumption/electricity_returned_merged",
|
||||
name="Power return total",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/day-consumption/electricity1_cost",
|
||||
|
@ -399,37 +399,37 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
|
|||
key="dsmr/current-month/electricity1",
|
||||
name="Current month low tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-month/electricity2",
|
||||
name="Current month high tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-month/electricity1_returned",
|
||||
name="Current month low tariff returned",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-month/electricity2_returned",
|
||||
name="Current month high tariff returned",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-month/electricity_merged",
|
||||
name="Current month power usage total",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-month/electricity_returned_merged",
|
||||
name="Current month power return total",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-month/electricity1_cost",
|
||||
|
@ -477,37 +477,37 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
|
|||
key="dsmr/current-year/electricity1",
|
||||
name="Current year low tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-year/electricity2",
|
||||
name="Current year high tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-year/electricity1_returned",
|
||||
name="Current year low tariff returned",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-year/electricity2_returned",
|
||||
name="Current year high tariff usage",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-year/electricity_merged",
|
||||
name="Current year power usage total",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-year/electricity_returned_merged",
|
||||
name="Current year power returned total",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
DSMRReaderSensorEntityDescription(
|
||||
key="dsmr/current-year/electricity1_cost",
|
||||
|
|
|
@ -18,10 +18,9 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.const import (
|
||||
CONF_NAME,
|
||||
DEGREE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -255,8 +254,8 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
SENSORS = {desc.key: desc for desc in SENSOR_TYPES}
|
||||
|
||||
SENSOR_UNIT_MAPPING = {
|
||||
"Wh": ENERGY_WATT_HOUR,
|
||||
"kWh": ENERGY_KILO_WATT_HOUR,
|
||||
"Wh": UnitOfEnergy.WATT_HOUR,
|
||||
"kWh": UnitOfEnergy.KILO_WATT_HOUR,
|
||||
"W": UnitOfPower.WATT,
|
||||
"A": UnitOfElectricCurrent.AMPERE,
|
||||
"V": UnitOfElectricPotential.VOLT,
|
||||
|
|
|
@ -14,7 +14,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 import entity_platform
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
@ -34,7 +34,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
key="energy_day",
|
||||
name="Daily Consumption",
|
||||
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,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
|
@ -42,7 +42,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
key="energy_week",
|
||||
name="Weekly Consumption",
|
||||
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,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
|
@ -50,14 +50,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
key="energy_month",
|
||||
name="Monthly Consumption",
|
||||
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,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="energy_year",
|
||||
name="Yearly Consumption",
|
||||
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,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
|
|
|
@ -8,7 +8,7 @@ from pyflick import FlickAPI, FlickPrice
|
|||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, CURRENCY_CENT, ENERGY_KILO_WATT_HOUR
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, CURRENCY_CENT, UnitOfEnergy
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
@ -35,7 +35,7 @@ class FlickPricingSensor(SensorEntity):
|
|||
"""Entity object for Flick Electric sensor."""
|
||||
|
||||
_attr_attribution = "Data provided by Flick Electric"
|
||||
_attr_native_unit_of_measurement = f"{CURRENCY_CENT}/{ENERGY_KILO_WATT_HOUR}"
|
||||
_attr_native_unit_of_measurement = f"{CURRENCY_CENT}/{UnitOfEnergy.KILO_WATT_HOUR}"
|
||||
|
||||
def __init__(self, api: FlickAPI) -> None:
|
||||
"""Entity object for Flick Electric sensor."""
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower
|
||||
|
||||
from .models import ForecastSolarSensorEntityDescription
|
||||
|
||||
|
@ -22,14 +22,14 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
name="Estimated energy production - today",
|
||||
state=lambda estimate: estimate.energy_production_today / 1000,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="energy_production_tomorrow",
|
||||
name="Estimated energy production - tomorrow",
|
||||
state=lambda estimate: estimate.energy_production_tomorrow / 1000,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="power_highest_peak_time_today",
|
||||
|
@ -84,13 +84,13 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
|
|||
name="Estimated energy production - this hour",
|
||||
state=lambda estimate: estimate.energy_current_hour / 1000,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
ForecastSolarSensorEntityDescription(
|
||||
key="energy_next_hour",
|
||||
state=lambda estimate: estimate.sum_energy_production(1) / 1000,
|
||||
name="Estimated energy production - next hour",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
)
|
||||
|
|
|
@ -17,11 +17,11 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -158,7 +158,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
|
|||
FritzSensorEntityDescription(
|
||||
key="total_energy",
|
||||
name="Total Energy",
|
||||
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,
|
||||
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
|
||||
|
|
|
@ -11,7 +11,6 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS,
|
||||
TEMP_CELSIUS,
|
||||
|
@ -19,6 +18,7 @@ from homeassistant.const import (
|
|||
TIME_SECONDS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -64,7 +64,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
key="whOut",
|
||||
name="Wh out",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
|
@ -72,7 +72,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
key="whStored",
|
||||
name="Wh stored",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
|
|
|
@ -3,10 +3,10 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="inverter_energy_today",
|
||||
name="Energy today",
|
||||
api_key="powerToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
precision=1,
|
||||
),
|
||||
|
@ -26,7 +26,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="inverter_energy_total",
|
||||
name="Lifetime energy output",
|
||||
api_key="powerTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
precision=1,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
|
|
|
@ -3,9 +3,9 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
||||
|
@ -24,14 +24,14 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_battery_charge_today",
|
||||
name="Battery charged today",
|
||||
api_key="eBatChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_battery_charge_lifetime",
|
||||
name="Lifetime battery charged",
|
||||
api_key="eBatChargeTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -39,14 +39,14 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_battery_discharge_today",
|
||||
name="Battery discharged today",
|
||||
api_key="eBatDisChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_battery_discharge_lifetime",
|
||||
name="Lifetime battery discharged",
|
||||
api_key="eBatDisChargeTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -54,14 +54,14 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_solar_generation_today",
|
||||
name="Solar energy today",
|
||||
api_key="epvToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_solar_generation_lifetime",
|
||||
name="Lifetime solar energy",
|
||||
api_key="epvTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -98,14 +98,14 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_load_consumption_today",
|
||||
name="Load consumption today",
|
||||
api_key="elocalLoadToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_load_consumption_lifetime",
|
||||
name="Lifetime load consumption",
|
||||
api_key="elocalLoadTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -113,14 +113,14 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_export_to_grid_today",
|
||||
name="Export to grid today",
|
||||
api_key="etoGridToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_export_to_grid_lifetime",
|
||||
name="Lifetime export to grid",
|
||||
api_key="etogridTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -193,35 +193,35 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_system_production_today",
|
||||
name="System production today (self-consumption + export)",
|
||||
api_key="eCharge",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_load_consumption_solar_today",
|
||||
name="Load consumption today (solar)",
|
||||
api_key="eChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_self_consumption_today",
|
||||
name="Self consumption today (solar + battery)",
|
||||
api_key="eChargeToday1",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_load_consumption_battery_today",
|
||||
name="Load consumption today (battery)",
|
||||
api_key="echarge1",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="mix_import_from_grid_today",
|
||||
name="Import from grid today (load)",
|
||||
api_key="etouser",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
# This sensor is manually created using the most recent X-Axis value from the chartData
|
||||
|
@ -236,7 +236,7 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_import_from_grid_today_combined",
|
||||
name="Import from grid today (load + charging)",
|
||||
api_key="etouser_combined", # This id is not present in the raw API data, it is added by the sensor
|
||||
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,
|
||||
previous_value_drop_threshold=0.2,
|
||||
|
|
|
@ -3,10 +3,10 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -18,14 +18,14 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="storage_storage_production_today",
|
||||
name="Storage production today",
|
||||
api_key="eBatDisChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="storage_storage_production_lifetime",
|
||||
name="Lifetime Storage production",
|
||||
api_key="eBatDisChargeTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -33,21 +33,21 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="storage_grid_discharge_today",
|
||||
name="Grid discharged today",
|
||||
api_key="eacDisChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="storage_load_consumption_today",
|
||||
name="Load consumption today",
|
||||
api_key="eopDischrToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="storage_load_consumption_lifetime",
|
||||
name="Lifetime load consumption",
|
||||
api_key="eopDischrTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -55,14 +55,14 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="storage_grid_charged_today",
|
||||
name="Grid charged today",
|
||||
api_key="eacChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="storage_charge_storage_lifetime",
|
||||
name="Lifetime storaged charged",
|
||||
api_key="eChargeTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
@ -97,7 +97,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="storage_charge_today",
|
||||
name="Charge today",
|
||||
api_key="eChargeToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
|
@ -111,14 +111,14 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="storage_import_from_grid_today",
|
||||
name="Import from grid today",
|
||||
api_key="eToUserToday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
key="storage_import_from_grid_total",
|
||||
name="Import from grid total",
|
||||
api_key="eToUserTotal",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
|
|
@ -7,11 +7,11 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_today",
|
||||
name="Energy today",
|
||||
api_key="eacToday",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -32,7 +32,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_total",
|
||||
name="Lifetime energy output",
|
||||
api_key="eacTotal",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -42,7 +42,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_total_input_1",
|
||||
name="Lifetime total energy input 1",
|
||||
api_key="epv1Total",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -52,7 +52,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_today_input_1",
|
||||
name="Energy Today Input 1",
|
||||
api_key="epv1Today",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -85,7 +85,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_total_input_2",
|
||||
name="Lifetime total energy input 2",
|
||||
api_key="epv2Total",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -95,7 +95,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_today_input_2",
|
||||
name="Energy Today Input 2",
|
||||
api_key="epv2Today",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -128,7 +128,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_total_input_3",
|
||||
name="Lifetime total energy input 3",
|
||||
api_key="epv3Total",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -138,7 +138,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_today_input_3",
|
||||
name="Energy Today Input 3",
|
||||
api_key="epv3Today",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -171,7 +171,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_total_input_4",
|
||||
name="Lifetime total energy input 4",
|
||||
api_key="epv4Total",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -181,7 +181,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_energy_today_input_4",
|
||||
name="Energy Today Input 4",
|
||||
api_key="epv4Today",
|
||||
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,
|
||||
precision=1,
|
||||
|
@ -214,7 +214,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_solar_generation_total",
|
||||
name="Lifetime total solar energy",
|
||||
api_key="epvTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -295,7 +295,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_all_batteries_discharge_today",
|
||||
name="All batteries discharged today",
|
||||
api_key="edischargeToday",
|
||||
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,
|
||||
),
|
||||
|
@ -303,7 +303,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_all_batteries_discharge_total",
|
||||
name="Lifetime total all batteries discharged",
|
||||
api_key="edischargeTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -319,7 +319,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_battery_1_discharge_total",
|
||||
name="Lifetime total battery 1 discharged",
|
||||
api_key="bdc1DischargeTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -335,7 +335,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_battery_2_discharge_total",
|
||||
name="Lifetime total battery 2 discharged",
|
||||
api_key="bdc1DischargeTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -344,7 +344,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_all_batteries_charge_today",
|
||||
name="All batteries charged today",
|
||||
api_key="echargeToday",
|
||||
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,
|
||||
),
|
||||
|
@ -352,7 +352,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_all_batteries_charge_total",
|
||||
name="Lifetime total all batteries charged",
|
||||
api_key="echargeTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -368,7 +368,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_battery_1_charge_total",
|
||||
name="Lifetime total battery 1 charged",
|
||||
api_key="bdc1ChargeTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -384,7 +384,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_battery_2_charge_total",
|
||||
name="Lifetime total battery 2 charged",
|
||||
api_key="bdc1ChargeTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -393,7 +393,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_export_to_grid_today",
|
||||
name="Export to grid today",
|
||||
api_key="etoGridToday",
|
||||
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,
|
||||
),
|
||||
|
@ -401,7 +401,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_export_to_grid_total",
|
||||
name="Lifetime total export to grid",
|
||||
api_key="etoGridTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
@ -410,7 +410,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="tlx_load_consumption_today",
|
||||
name="Load consumption today",
|
||||
api_key="elocalLoadToday",
|
||||
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,
|
||||
),
|
||||
|
@ -418,7 +418,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="mix_load_consumption_total",
|
||||
name="Lifetime total load consumption",
|
||||
api_key="elocalLoadTotal",
|
||||
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,
|
||||
never_resets=True,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import UnitOfEnergy, UnitOfPower
|
||||
|
||||
from .sensor_entity_description import GrowattSensorEntityDescription
|
||||
|
||||
|
@ -23,7 +23,7 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="total_energy_today",
|
||||
name="Energy Today",
|
||||
api_key="todayEnergy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
GrowattSensorEntityDescription(
|
||||
|
@ -37,7 +37,7 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
|
|||
key="total_energy_output",
|
||||
name="Lifetime energy output",
|
||||
api_key="totalEnergy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
),
|
||||
|
|
|
@ -24,7 +24,6 @@ from homeassistant.const import (
|
|||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
ELECTRIC_CURRENT_AMPERE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
PRESSURE_HPA,
|
||||
|
@ -32,6 +31,7 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
Platform,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
UnitOfSoundPressure,
|
||||
)
|
||||
|
@ -167,7 +167,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
|
|||
name="Energy kWh",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
),
|
||||
CharacteristicsTypes.VENDOR_EVE_ENERGY_WATT: HomeKitSensorEntityDescription(
|
||||
key=CharacteristicsTypes.VENDOR_EVE_ENERGY_WATT,
|
||||
|
@ -181,7 +181,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
|
|||
name="Energy kWh",
|
||||
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,
|
||||
),
|
||||
CharacteristicsTypes.VENDOR_EVE_ENERGY_VOLTAGE: HomeKitSensorEntityDescription(
|
||||
key=CharacteristicsTypes.VENDOR_EVE_ENERGY_VOLTAGE,
|
||||
|
|
|
@ -15,14 +15,13 @@ from homeassistant.const import (
|
|||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
DEGREE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
PRESSURE_HPA,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
UnitOfPrecipitationDepth,
|
||||
|
@ -136,13 +135,13 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"ENERGY_COUNTER": SensorEntityDescription(
|
||||
key="ENERGY_COUNTER",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
"IEC_ENERGY_COUNTER": SensorEntityDescription(
|
||||
key="IEC_ENERGY_COUNTER",
|
||||
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,
|
||||
),
|
||||
|
|
|
@ -10,12 +10,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.const import PERCENTAGE, UnitOfEnergy, UnitOfPower, UnitOfVolume
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -58,28 +53,28 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
|
|||
SensorEntityDescription(
|
||||
key="total_power_import_t1_kwh",
|
||||
name="Total power import T1",
|
||||
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="total_power_import_t2_kwh",
|
||||
name="Total power import T2",
|
||||
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="total_power_export_t1_kwh",
|
||||
name="Total power export T1",
|
||||
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="total_power_export_t2_kwh",
|
||||
name="Total power export T2",
|
||||
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,
|
||||
),
|
||||
|
|
|
@ -15,11 +15,11 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
@ -82,7 +82,7 @@ ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = {
|
|||
),
|
||||
"WattHours": IotaWattSensorEntityDescription(
|
||||
"WattHours",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
|
|
|
@ -9,11 +9,11 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_WATT_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
TIME_SECONDS,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -63,7 +63,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key="energy_added",
|
||||
name="Energy added",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
|
|
|
@ -7,11 +7,7 @@ from homeassistant.components.sensor import (
|
|||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.const import UnitOfElectricCurrent, UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
@ -48,7 +44,7 @@ async def async_setup_platform(
|
|||
SensorEntityDescription(
|
||||
key="Setenergy",
|
||||
name="Energy Target",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
),
|
||||
|
@ -69,7 +65,7 @@ async def async_setup_platform(
|
|||
SensorEntityDescription(
|
||||
key="E pres",
|
||||
name="Session Energy",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
),
|
||||
|
@ -79,7 +75,7 @@ async def async_setup_platform(
|
|||
SensorEntityDescription(
|
||||
key="E total",
|
||||
name="Total Energy",
|
||||
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,
|
||||
),
|
||||
|
|
|
@ -15,10 +15,10 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -321,7 +321,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHome:Day",
|
||||
name="Home Consumption Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -329,7 +329,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHome:Month",
|
||||
name="Home Consumption Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -337,7 +337,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHome:Year",
|
||||
name="Home Consumption Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -345,7 +345,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHome:Total",
|
||||
name="Home Consumption Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -354,7 +354,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeBat:Day",
|
||||
name="Home Consumption from Battery Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -362,7 +362,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeBat:Month",
|
||||
name="Home Consumption from Battery Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -370,7 +370,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeBat:Year",
|
||||
name="Home Consumption from Battery Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -378,7 +378,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeBat:Total",
|
||||
name="Home Consumption from Battery Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -387,7 +387,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeGrid:Day",
|
||||
name="Home Consumption from Grid Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -395,7 +395,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeGrid:Month",
|
||||
name="Home Consumption from Grid Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -403,7 +403,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeGrid:Year",
|
||||
name="Home Consumption from Grid Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -411,7 +411,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomeGrid:Total",
|
||||
name="Home Consumption from Grid Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -420,7 +420,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomePv:Day",
|
||||
name="Home Consumption from PV Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -428,7 +428,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomePv:Month",
|
||||
name="Home Consumption from PV Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -436,7 +436,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomePv:Year",
|
||||
name="Home Consumption from PV Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -444,7 +444,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyHomePv:Total",
|
||||
name="Home Consumption from PV Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -453,7 +453,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv1:Day",
|
||||
name="Energy PV1 Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -461,7 +461,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv1:Month",
|
||||
name="Energy PV1 Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -469,7 +469,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv1:Year",
|
||||
name="Energy PV1 Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -477,7 +477,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv1:Total",
|
||||
name="Energy PV1 Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -486,7 +486,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv2:Day",
|
||||
name="Energy PV2 Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -494,7 +494,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv2:Month",
|
||||
name="Energy PV2 Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -502,7 +502,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv2:Year",
|
||||
name="Energy PV2 Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -510,7 +510,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv2:Total",
|
||||
name="Energy PV2 Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -519,7 +519,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv3:Day",
|
||||
name="Energy PV3 Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -527,7 +527,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv3:Month",
|
||||
name="Energy PV3 Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -535,7 +535,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv3:Year",
|
||||
name="Energy PV3 Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -543,7 +543,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyPv3:Total",
|
||||
name="Energy PV3 Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -552,7 +552,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:Yield:Day",
|
||||
name="Energy Yield Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
entity_registry_enabled_default=True,
|
||||
formatter="format_energy",
|
||||
|
@ -561,7 +561,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:Yield:Month",
|
||||
name="Energy Yield Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -569,7 +569,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:Yield:Year",
|
||||
name="Energy Yield Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -577,7 +577,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:Yield:Total",
|
||||
name="Energy Yield Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -586,7 +586,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargeGrid:Day",
|
||||
name="Battery Charge from Grid Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -594,7 +594,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargeGrid:Month",
|
||||
name="Battery Charge from Grid Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -602,7 +602,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargeGrid:Year",
|
||||
name="Battery Charge from Grid Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -610,7 +610,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargeGrid:Total",
|
||||
name="Battery Charge from Grid Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -619,7 +619,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargePv:Day",
|
||||
name="Battery Charge from PV Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -627,7 +627,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargePv:Month",
|
||||
name="Battery Charge from PV Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -635,7 +635,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargePv:Year",
|
||||
name="Battery Charge from PV Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -643,7 +643,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyChargePv:Total",
|
||||
name="Battery Charge from PV Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
@ -652,7 +652,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyDischargeGrid:Day",
|
||||
name="Energy Discharge to Grid Day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -660,7 +660,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyDischargeGrid:Month",
|
||||
name="Energy Discharge to Grid Month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -668,7 +668,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyDischargeGrid:Year",
|
||||
name="Energy Discharge to Grid Year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
formatter="format_energy",
|
||||
),
|
||||
|
@ -676,7 +676,7 @@ SENSOR_PROCESS_DATA = [
|
|||
module_id="scb:statistic:EnergyFlow",
|
||||
key="Statistic:EnergyDischargeGrid:Total",
|
||||
name="Energy Discharge to Grid Total",
|
||||
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,
|
||||
formatter="format_energy",
|
||||
|
|
|
@ -15,9 +15,9 @@ from homeassistant.const import (
|
|||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
CONF_IP_ADDRESS,
|
||||
CONF_USERNAME,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -45,14 +45,14 @@ HEATER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
SensorEntityDescription(
|
||||
key=CONSUMPTION_YEAR,
|
||||
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,
|
||||
name="Year consumption",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=CONSUMPTION_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,
|
||||
name="Day consumption",
|
||||
),
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
|
|||
SensorEntity,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY, ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.const import CONF_API_KEY, UnitOfEnergy, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -153,7 +153,7 @@ class NeurioEnergy(SensorEntity):
|
|||
self._attr_device_class = SensorDeviceClass.POWER
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
elif sensor_type == DAILY_TYPE:
|
||||
self._unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
self._unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
|
||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
|
||||
|
|
Loading…
Reference in New Issue