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