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."""
|
"""The enphase_envoy component."""
|
||||||
|
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ENERGY_WATT_HOUR, POWER_WATT, Platform
|
from homeassistant.const import Platform, UnitOfEnergy, UnitOfPower
|
||||||
|
|
||||||
DOMAIN = "enphase_envoy"
|
DOMAIN = "enphase_envoy"
|
||||||
|
|
||||||
|
@ -20,54 +18,56 @@ SENSORS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="production",
|
key="production",
|
||||||
name="Current Power Production",
|
name="Current Power Production",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.POWER,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="daily_production",
|
key="daily_production",
|
||||||
name="Today's Energy 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,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="seven_days_production",
|
key="seven_days_production",
|
||||||
name="Last Seven Days Energy 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,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="lifetime_production",
|
key="lifetime_production",
|
||||||
name="Lifetime Energy Production",
|
name="Lifetime Energy Production",
|
||||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="consumption",
|
key="consumption",
|
||||||
name="Current Power Consumption",
|
name="Current Power Consumption",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.POWER,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="daily_consumption",
|
key="daily_consumption",
|
||||||
name="Today's Energy 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,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="seven_days_consumption",
|
key="seven_days_consumption",
|
||||||
name="Last Seven Days Energy 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,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="lifetime_consumption",
|
key="lifetime_consumption",
|
||||||
name="Lifetime Energy Consumption",
|
name="Lifetime Energy Consumption",
|
||||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
|
|
|
@ -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 POWER_WATT
|
from homeassistant.const import UnitOfPower
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -60,8 +60,9 @@ def _inverter_last_report_time(
|
||||||
INVERTER_SENSORS = (
|
INVERTER_SENSORS = (
|
||||||
EnvoySensorEntityDescription(
|
EnvoySensorEntityDescription(
|
||||||
key=INVERTERS_KEY,
|
key=INVERTERS_KEY,
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.POWER,
|
||||||
value_fn=lambda watt_report_time: watt_report_time[0],
|
value_fn=lambda watt_report_time: watt_report_time[0],
|
||||||
),
|
),
|
||||||
EnvoySensorEntityDescription(
|
EnvoySensorEntityDescription(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue