Use POWER device class in solarlog (#83822)
parent
a30f14a15e
commit
fa06398721
|
@ -11,10 +11,10 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.util.dt import as_local
|
||||
|
||||
|
@ -43,27 +43,29 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="power_ac",
|
||||
name="power AC",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="power_dc",
|
||||
name="power DC",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="voltage_ac",
|
||||
name="voltage AC",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="voltage_dc",
|
||||
name="voltage DC",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
@ -71,7 +73,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="yield_day",
|
||||
name="yield day",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
|
@ -79,7 +81,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="yield_yesterday",
|
||||
name="yield yesterday",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
|
@ -87,7 +89,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="yield_month",
|
||||
name="yield month",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
|
@ -95,7 +97,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="yield_year",
|
||||
name="yield year",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
|
@ -103,7 +105,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="yield_total",
|
||||
name="yield total",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
|
@ -111,42 +113,42 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
SolarLogSensorEntityDescription(
|
||||
key="consumption_ac",
|
||||
name="consumption AC",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="consumption_day",
|
||||
name="consumption day",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="consumption_yesterday",
|
||||
name="consumption yesterday",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="consumption_month",
|
||||
name="consumption month",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="consumption_year",
|
||||
name="consumption year",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="consumption_total",
|
||||
name="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,
|
||||
value=lambda value: round(value / 1000, 3),
|
||||
|
@ -155,14 +157,14 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="total_power",
|
||||
name="installed peak power",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
SolarLogSensorEntityDescription(
|
||||
key="alternator_loss",
|
||||
name="alternator loss",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
@ -187,7 +189,7 @@ SENSOR_TYPES: tuple[SolarLogSensorEntityDescription, ...] = (
|
|||
key="power_available",
|
||||
name="power available",
|
||||
icon="mdi:solar-power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue