Skip to content

Commit

Permalink
Extract attribute into sensor for PVOutput (#62894)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Dec 28, 2021
1 parent 4745e2f commit d63b7bc
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions homeassistant/components/pvoutput/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
ATTR_VOLTAGE,
CONF_API_KEY,
CONF_NAME,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR,
POWER_KILO_WATT,
POWER_WATT,
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
Expand Down Expand Up @@ -67,6 +72,14 @@ class PVOutputSensorEntityDescription(


SENSORS: tuple[PVOutputSensorEntityDescription, ...] = (
PVOutputSensorEntityDescription(
key="energy_consumption",
name="Energy Consumed",
native_unit_of_measurement=ENERGY_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
value_fn=lambda status: status.energy_consumption,
),
PVOutputSensorEntityDescription(
key="energy_generation",
name="Energy Generated",
Expand All @@ -75,6 +88,45 @@ class PVOutputSensorEntityDescription(
state_class=SensorStateClass.TOTAL_INCREASING,
value_fn=lambda status: status.energy_generation,
),
PVOutputSensorEntityDescription(
key="normalized_ouput",
name="Efficiency",
native_unit_of_measurement=f"{ENERGY_KILO_WATT_HOUR}/{POWER_KILO_WATT}",
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda status: status.normalized_ouput,
),
PVOutputSensorEntityDescription(
key="power_consumption",
name="Power Consumed",
native_unit_of_measurement=POWER_WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda status: status.power_consumption,
),
PVOutputSensorEntityDescription(
key="power_generation",
name="Power Generated",
native_unit_of_measurement=POWER_WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda status: status.power_generation,
),
PVOutputSensorEntityDescription(
key="temperature",
name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda status: status.temperature,
),
PVOutputSensorEntityDescription(
key="voltage",
name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda status: status.voltage,
),
)


Expand Down

0 comments on commit d63b7bc

Please sign in to comment.