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_USERNAME,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
UnitOfPower,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
@ -262,7 +262,7 @@ class AtomeSensor(SensorEntity):
if sensor_type == LIVE_TYPE:
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
else:
self._attr_device_class = SensorDeviceClass.ENERGY

View file

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
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.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -28,7 +28,7 @@ SENSOR_TYPES = [
SensorEntityDescription(
key="instantaneouspower",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT,
name="Power Output",
),

View file

@ -14,8 +14,8 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
ENERGY_KILO_WATT_HOUR,
PERCENTAGE,
POWER_WATT,
TEMP_CELSIUS,
UnitOfPower,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -302,7 +302,7 @@ class PowerSensor(SHCEntity, SensorEntity):
"""Representation of an SHC power reporting sensor."""
_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:
"""Initialize an SHC power reporting sensor."""

View file

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

View file

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

View file

@ -17,8 +17,8 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR,
FREQUENCY_HERTZ,
PERCENTAGE,
POWER_KILO_WATT,
TEMP_CELSIUS,
UnitOfPower,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
@ -90,7 +90,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
name="Compressor estimated power consumption",
device_class=SensorDeviceClass.POWER,
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),
),
DaikinSensorEntityDescription(

View file

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

View file

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

View file

@ -22,8 +22,8 @@ from homeassistant.const import (
ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR,
FREQUENCY_HERTZ,
POWER_WATT,
UnitOfElectricCurrent,
UnitOfPower,
)
from homeassistant.core import HomeAssistant, callback
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 = {
"Wh": ENERGY_WATT_HOUR,
"kWh": ENERGY_KILO_WATT_HOUR,
"W": POWER_WATT,
"W": UnitOfPower.WATT,
"A": UnitOfElectricCurrent.AMPERE,
"V": ELECTRIC_POTENTIAL_VOLT,
"°": DEGREE,

View file

@ -14,7 +14,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
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.helpers import entity_platform
from homeassistant.helpers.typing import StateType
@ -27,7 +27,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="instant_readings",
name="Power Usage",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
@ -97,7 +97,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key=CONF_CURRENT_VALUES,
name="Power Usage",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT,
),
)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,10 +11,10 @@ from homeassistant.const import (
CONF_SENSORS,
CONF_TEMPERATURE_UNIT,
ELECTRIC_POTENTIAL_VOLT,
POWER_WATT,
TIME_HOURS,
TIME_MINUTES,
TIME_SECONDS,
UnitOfPower,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -38,8 +38,6 @@ from .const import (
DATA_PULSES = "pulses"
DATA_WATT_SECONDS = "watt_seconds"
UNIT_WATTS = POWER_WATT
COUNTER_ICON = "mdi:counter"
@ -165,7 +163,7 @@ class GEMSensor(SensorEntity):
class CurrentSensor(GEMSensor):
"""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
def __init__(

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@
from __future__ import annotations
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
@ -30,7 +30,7 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="total_output_power",
name="Output Power",
api_key="invTodayPpv",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
GrowattSensorEntityDescription(
@ -45,7 +45,7 @@ TOTAL_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="total_maximum_output",
name="Maximum power",
api_key="nominalPower",
native_unit_of_measurement=POWER_WATT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
),
)