Use POWER device class in enphase_envoy (#83811)
This commit is contained in:
parent
4fe025b297
commit
1667b4b19e
2 changed files with 14 additions and 13 deletions
|
@ -1,12 +1,10 @@
|
|||
"""The enphase_envoy component."""
|
||||
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import ENERGY_WATT_HOUR, POWER_WATT, Platform
|
||||
from homeassistant.const import Platform, UnitOfEnergy, UnitOfPower
|
||||
|
||||
DOMAIN = "enphase_envoy"
|
||||
|
||||
|
@ -20,54 +18,56 @@ SENSORS = (
|
|||
SensorEntityDescription(
|
||||
key="production",
|
||||
name="Current Power Production",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="daily_production",
|
||||
name="Today's Energy Production",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="seven_days_production",
|
||||
name="Last Seven Days Energy Production",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="lifetime_production",
|
||||
name="Lifetime Energy Production",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="consumption",
|
||||
name="Current Power Consumption",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="daily_consumption",
|
||||
name="Today's Energy Consumption",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="seven_days_consumption",
|
||||
name="Last Seven Days Energy Consumption",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="lifetime_consumption",
|
||||
name="Lifetime Energy Consumption",
|
||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
),
|
||||
|
|
|
@ -14,7 +14,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.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -60,8 +60,9 @@ def _inverter_last_report_time(
|
|||
INVERTER_SENSORS = (
|
||||
EnvoySensorEntityDescription(
|
||||
key=INVERTERS_KEY,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
value_fn=lambda watt_report_time: watt_report_time[0],
|
||||
),
|
||||
EnvoySensorEntityDescription(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue