Use UnitOfPower in integrations [a-g] (#83812)

This commit is contained in:
epenet 2022-12-12 11:48:09 +01:00 committed by GitHub
parent 431df618c3
commit 4fe025b297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 88 additions and 91 deletions

View file

@ -18,7 +18,7 @@ from homeassistant.const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
POWER_WATT, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -262,7 +262,7 @@ class AtomeSensor(SensorEntity):
if sensor_type == LIVE_TYPE: if sensor_type == LIVE_TYPE:
self._attr_device_class = SensorDeviceClass.POWER self._attr_device_class = SensorDeviceClass.POWER
self._attr_native_unit_of_measurement = POWER_WATT self._attr_native_unit_of_measurement = UnitOfPower.WATT
self._attr_state_class = SensorStateClass.MEASUREMENT self._attr_state_class = SensorStateClass.MEASUREMENT
else: else:
self._attr_device_class = SensorDeviceClass.ENERGY self._attr_device_class = SensorDeviceClass.ENERGY

View file

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT, TEMP_CELSIUS from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS, UnitOfPower
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -28,7 +28,7 @@ SENSOR_TYPES = [
SensorEntityDescription( SensorEntityDescription(
key="instantaneouspower", key="instantaneouspower",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
name="Power Output", name="Power Output",
), ),

View file

@ -14,8 +14,8 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -302,7 +302,7 @@ class PowerSensor(SHCEntity, SensorEntity):
"""Representation of an SHC power reporting sensor.""" """Representation of an SHC power reporting sensor."""
_attr_device_class = SensorDeviceClass.POWER _attr_device_class = SensorDeviceClass.POWER
_attr_native_unit_of_measurement = POWER_WATT _attr_native_unit_of_measurement = UnitOfPower.WATT
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
"""Initialize an SHC power reporting sensor.""" """Initialize an SHC power reporting sensor."""

View file

@ -12,9 +12,9 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -53,7 +53,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="power", key="power",
name="Current power", name="Current power",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View file

@ -40,11 +40,11 @@ from homeassistant.const import (
CONF_RESOURCES, CONF_RESOURCES,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
REVOLUTIONS_PER_MINUTE, REVOLUTIONS_PER_MINUTE,
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_DAYS, TIME_DAYS,
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -241,7 +241,7 @@ SENSOR_TYPES = (
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
name="Power usage", name="Power usage",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
sensor_id=SENSOR_POWER_CURRENT, sensor_id=SENSOR_POWER_CURRENT,
), ),
ComfoconnectSensorEntityDescription( ComfoconnectSensorEntityDescription(
@ -257,7 +257,7 @@ SENSOR_TYPES = (
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
name="Preheater power usage", name="Preheater power usage",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
sensor_id=SENSOR_PREHEATER_POWER_CURRENT, sensor_id=SENSOR_PREHEATER_POWER_CURRENT,
), ),
ComfoconnectSensorEntityDescription( ComfoconnectSensorEntityDescription(

View file

@ -17,8 +17,8 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_KILO_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -90,7 +90,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
name="Compressor estimated power consumption", name="Compressor estimated power consumption",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
value_func=lambda device: round(device.current_total_power_consumption, 2), value_func=lambda device: round(device.current_total_power_consumption, 2),
), ),
DaikinSensorEntityDescription( DaikinSensorEntityDescription(

View file

@ -37,9 +37,9 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
PRESSURE_HPA, PRESSURE_HPA,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -180,7 +180,7 @@ ENTITY_DESCRIPTIONS: tuple[DeconzSensorDescription, ...] = (
instance_check=Power, instance_check=Power,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
), ),
DeconzSensorDescription[Pressure]( DeconzSensorDescription[Pressure](
key="pressure", key="pressure",

View file

@ -14,9 +14,9 @@ from homeassistant.const import (
CURRENCY_EURO, CURRENCY_EURO,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
POWER_KILO_WATT,
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -78,14 +78,14 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
key="dsmr/reading/electricity_currently_delivered", key="dsmr/reading/electricity_currently_delivered",
name="Current power usage", name="Current power usage",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
key="dsmr/reading/electricity_currently_returned", key="dsmr/reading/electricity_currently_returned",
name="Current power return", name="Current power return",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -93,7 +93,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current power usage L1", name="Current power usage L1",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -101,7 +101,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current power usage L2", name="Current power usage L2",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -109,7 +109,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current power usage L3", name="Current power usage L3",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -117,7 +117,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current power return L1", name="Current power return L1",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -125,7 +125,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current power return L2", name="Current power return L2",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -133,7 +133,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current power return L3", name="Current power return L3",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(

View file

@ -22,8 +22,8 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
POWER_WATT,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_registry as er from homeassistant.helpers import config_validation as cv, entity_registry as er
@ -257,7 +257,7 @@ SENSORS = {desc.key: desc for desc in SENSOR_TYPES}
SENSOR_UNIT_MAPPING = { SENSOR_UNIT_MAPPING = {
"Wh": ENERGY_WATT_HOUR, "Wh": ENERGY_WATT_HOUR,
"kWh": ENERGY_KILO_WATT_HOUR, "kWh": ENERGY_KILO_WATT_HOUR,
"W": POWER_WATT, "W": UnitOfPower.WATT,
"A": UnitOfElectricCurrent.AMPERE, "A": UnitOfElectricCurrent.AMPERE,
"V": ELECTRIC_POTENTIAL_VOLT, "V": ELECTRIC_POTENTIAL_VOLT,
"°": DEGREE, "°": DEGREE,

View file

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
@ -27,7 +27,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="instant_readings", key="instant_readings",
name="Power Usage", name="Power Usage",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
@ -97,7 +97,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key=CONF_CURRENT_VALUES, key=CONF_CURRENT_VALUES,
name="Power Usage", name="Power Usage",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
) )

View file

@ -21,8 +21,8 @@ from homeassistant.const import (
CONF_UNIT_OF_MEASUREMENT, CONF_UNIT_OF_MEASUREMENT,
CONF_URL, CONF_URL,
CONF_VALUE_TEMPLATE, CONF_VALUE_TEMPLATE,
POWER_WATT,
STATE_UNKNOWN, STATE_UNKNOWN,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import template from homeassistant.helpers import template
@ -46,7 +46,7 @@ CONF_ONLY_INCLUDE_FEEDID = "include_only_feed_id"
CONF_SENSOR_NAMES = "sensor_names" CONF_SENSOR_NAMES = "sensor_names"
DECIMALS = 2 DECIMALS = 2
DEFAULT_UNIT = POWER_WATT DEFAULT_UNIT = UnitOfPower.WATT
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5) MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)
ONLY_INCL_EXCL_NONE = "only_include_exclude_or_none" ONLY_INCL_EXCL_NONE = "only_include_exclude_or_none"

View file

@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import POWER_WATT from homeassistant.const import UnitOfPower
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -64,7 +64,7 @@ class EmonitorPowerSensor(CoordinatorEntity, SensorEntity):
"""Representation of an Emonitor power sensor entity.""" """Representation of an Emonitor power sensor entity."""
_attr_device_class = SensorDeviceClass.POWER _attr_device_class = SensorDeviceClass.POWER
_attr_native_unit_of_measurement = POWER_WATT _attr_native_unit_of_measurement = UnitOfPower.WATT
_attr_state_class = SensorStateClass.MEASUREMENT _attr_state_class = SensorStateClass.MEASUREMENT
def __init__( def __init__(

View file

@ -19,10 +19,10 @@ from homeassistant.const import (
CONF_ID, CONF_ID,
CONF_NAME, CONF_NAME,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
STATE_CLOSED, STATE_CLOSED,
STATE_OPEN, STATE_OPEN,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -82,7 +82,7 @@ SENSOR_DESC_HUMIDITY = EnOceanSensorEntityDescription(
SENSOR_DESC_POWER = EnOceanSensorEntityDescription( SENSOR_DESC_POWER = EnOceanSensorEntityDescription(
key=SENSOR_TYPE_POWER, key=SENSOR_TYPE_POWER,
name="Power", name="Power",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
icon="mdi:power-plug", icon="mdi:power-plug",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
from .models import ForecastSolarSensorEntityDescription from .models import ForecastSolarSensorEntityDescription
@ -47,7 +47,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state=lambda estimate: estimate.power_production_now, state=lambda estimate: estimate.power_production_now,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
), ),
ForecastSolarSensorEntityDescription( ForecastSolarSensorEntityDescription(
key="power_production_next_hour", key="power_production_next_hour",
@ -57,7 +57,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
name="Estimated power production - next hour", name="Estimated power production - next hour",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
), ),
ForecastSolarSensorEntityDescription( ForecastSolarSensorEntityDescription(
key="power_production_next_12hours", key="power_production_next_12hours",
@ -67,7 +67,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
name="Estimated power production - next 12 hours", name="Estimated power production - next 12 hours",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
), ),
ForecastSolarSensorEntityDescription( ForecastSolarSensorEntityDescription(
key="power_production_next_24hours", key="power_production_next_24hours",
@ -77,7 +77,7 @@ SENSORS: tuple[ForecastSolarSensorEntityDescription, ...] = (
name="Estimated power production - next 24 hours", name="Estimated power production - next 24 hours",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
), ),
ForecastSolarSensorEntityDescription( ForecastSolarSensorEntityDescription(
key="energy_current_hour", key="energy_current_hour",

View file

@ -20,9 +20,9 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -131,7 +131,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
FritzSensorEntityDescription( FritzSensorEntityDescription(
key="power_consumption", key="power_consumption",
name="Power Consumption", name="Power Consumption",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return] suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]

View file

@ -16,10 +16,10 @@ from homeassistant.const import (
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_VOLT_AMPERE_REACTIVE, POWER_VOLT_AMPERE_REACTIVE,
POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity import DeviceInfo, EntityCategory
@ -132,7 +132,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_ac", key="power_ac",
name="Power AC", name="Power AC",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -396,7 +396,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_real_phase_1", key="power_real_phase_1",
name="Power real phase 1", name="Power real phase 1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -404,7 +404,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_real_phase_2", key="power_real_phase_2",
name="Power real phase 2", name="Power real phase 2",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -412,7 +412,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_real_phase_3", key="power_real_phase_3",
name="Power real phase 3", name="Power real phase 3",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -420,7 +420,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_real", key="power_real",
name="Power real", name="Power real",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -485,7 +485,7 @@ OHMPILOT_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_real_ac", key="power_real_ac",
name="Power", name="Power",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -546,28 +546,28 @@ POWER_FLOW_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="power_battery", key="power_battery",
name="Power battery", name="Power battery",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="power_grid", key="power_grid",
name="Power grid", name="Power grid",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="power_load", key="power_load",
name="Power load", name="Power load",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="power_photovoltaics", key="power_photovoltaics",
name="Power photovoltaics", name="Power photovoltaics",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View file

@ -14,12 +14,12 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
SIGNAL_STRENGTH_DECIBELS, SIGNAL_STRENGTH_DECIBELS,
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_MINUTES, TIME_MINUTES,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -34,7 +34,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="wattsIn", key="wattsIn",
name="Watts in", name="Watts in",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
@ -49,7 +49,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="wattsOut", key="wattsOut",
name="Watts out", name="Watts out",
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(

View file

@ -11,10 +11,10 @@ from homeassistant.const import (
CONF_SENSORS, CONF_SENSORS,
CONF_TEMPERATURE_UNIT, CONF_TEMPERATURE_UNIT,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
POWER_WATT,
TIME_HOURS, TIME_HOURS,
TIME_MINUTES, TIME_MINUTES,
TIME_SECONDS, TIME_SECONDS,
UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -38,8 +38,6 @@ from .const import (
DATA_PULSES = "pulses" DATA_PULSES = "pulses"
DATA_WATT_SECONDS = "watt_seconds" DATA_WATT_SECONDS = "watt_seconds"
UNIT_WATTS = POWER_WATT
COUNTER_ICON = "mdi:counter" COUNTER_ICON = "mdi:counter"
@ -165,7 +163,7 @@ class GEMSensor(SensorEntity):
class CurrentSensor(GEMSensor): class CurrentSensor(GEMSensor):
"""Entity showing power usage on one channel of the monitor.""" """Entity showing power usage on one channel of the monitor."""
_attr_native_unit_of_measurement = UNIT_WATTS _attr_native_unit_of_measurement = UnitOfPower.WATT
_attr_device_class = SensorDeviceClass.POWER _attr_device_class = SensorDeviceClass.POWER
def __init__( def __init__(

View file

@ -6,9 +6,9 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -51,7 +51,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_wattage_input_1", key="inverter_wattage_input_1",
name="Input 1 Wattage", name="Input 1 Wattage",
api_key="ppv1", api_key="ppv1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -75,7 +75,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_wattage_input_2", key="inverter_wattage_input_2",
name="Input 2 Wattage", name="Input 2 Wattage",
api_key="ppv2", api_key="ppv2",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -99,7 +99,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_wattage_input_3", key="inverter_wattage_input_3",
name="Input 3 Wattage", name="Input 3 Wattage",
api_key="ppv3", api_key="ppv3",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -107,7 +107,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_internal_wattage", key="inverter_internal_wattage",
name="Internal wattage", name="Internal wattage",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -138,7 +138,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_current_wattage", key="inverter_current_wattage",
name="Output power", name="Output power",
api_key="pac", api_key="pac",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -146,7 +146,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_current_reactive_wattage", key="inverter_current_reactive_wattage",
name="Reactive wattage", name="Reactive wattage",
api_key="pacr", api_key="pacr",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),

View file

@ -6,8 +6,7 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_KILO_WATT, UnitOfPower,
POWER_WATT,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -70,7 +69,7 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="mix_battery_discharge_w", key="mix_battery_discharge_w",
name="Battery discharging W", name="Battery discharging W",
api_key="pDischarge1", api_key="pDischarge1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -130,56 +129,56 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="mix_battery_charge", key="mix_battery_charge",
name="Battery charging", name="Battery charging",
api_key="chargePower", api_key="chargePower",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_load_consumption", key="mix_load_consumption",
name="Load consumption", name="Load consumption",
api_key="pLocalLoad", api_key="pLocalLoad",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_wattage_pv_1", key="mix_wattage_pv_1",
name="PV1 Wattage", name="PV1 Wattage",
api_key="pPv1", api_key="pPv1",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_wattage_pv_2", key="mix_wattage_pv_2",
name="PV2 Wattage", name="PV2 Wattage",
api_key="pPv2", api_key="pPv2",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_wattage_pv_all", key="mix_wattage_pv_all",
name="All PV Wattage", name="All PV Wattage",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_export_to_grid", key="mix_export_to_grid",
name="Export to grid", name="Export to grid",
api_key="pactogrid", api_key="pactogrid",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_import_from_grid", key="mix_import_from_grid",
name="Import from grid", name="Import from grid",
api_key="pactouser", api_key="pactouser",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_battery_discharge_kw", key="mix_battery_discharge_kw",
name="Battery discharging kW", name="Battery discharging kW",
api_key="pdisCharge1", api_key="pdisCharge1",
native_unit_of_measurement=POWER_KILO_WATT, native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(

View file

@ -7,8 +7,8 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -70,7 +70,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_solar_production", key="storage_solar_production",
name="Solar power production", name="Solar power production",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -84,7 +84,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_power_flow", key="storage_power_flow",
name="Storage charging/ discharging(-ve)", name="Storage charging/ discharging(-ve)",
api_key="pCharge", api_key="pCharge",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -104,7 +104,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_import_from_grid", key="storage_import_from_grid",
name="Import from grid", name="Import from grid",
api_key="pAcInPut", api_key="pAcInPut",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -126,7 +126,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_load_consumption", key="storage_load_consumption",
name="Load consumption", name="Load consumption",
api_key="outPutPower", api_key="outPutPower",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(

View file

@ -6,9 +6,9 @@ from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
POWER_WATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfPower,
) )
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -70,7 +70,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_wattage_input_1", key="tlx_wattage_input_1",
name="Input 1 Wattage", name="Input 1 Wattage",
api_key="ppv1", api_key="ppv1",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -112,7 +112,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_wattage_input_2", key="tlx_wattage_input_2",
name="Input 2 Wattage", name="Input 2 Wattage",
api_key="ppv2", api_key="ppv2",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -120,7 +120,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_internal_wattage", key="tlx_internal_wattage",
name="Internal wattage", name="Internal wattage",
api_key="ppv", api_key="ppv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),
@ -143,7 +143,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_current_wattage", key="tlx_current_wattage",
name="Output power", name="Output power",
api_key="pac", api_key="pac",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
precision=1, precision=1,
), ),

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
from .sensor_entity_description import GrowattSensorEntityDescription from .sensor_entity_description import GrowattSensorEntityDescription
@ -30,7 +30,7 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="total_output_power", key="total_output_power",
name="Output Power", name="Output Power",
api_key="invTodayPpv", api_key="invTodayPpv",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
@ -45,7 +45,7 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="total_maximum_output", key="total_maximum_output",
name="Maximum power", name="Maximum power",
api_key="nominalPower", api_key="nominalPower",
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),
) )