Skip to content

Commit

Permalink
Add energy totalizers.
Browse files Browse the repository at this point in the history
  • Loading branch information
lnx85 committed May 3, 2024
1 parent 5cadcfe commit ded226e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/delios/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class TotalizerData:

def __init__(self, data: dict) -> None:
"""Initialize totalizer data from JSON."""
self.produced = float(data["totalizers"]["TotalEnergyPV"])
self.photovoltaic = float(data["totalizers"]["TotalEnergyPV"])
self.buyed = float(data["totalizers"]["TotalEnergyBuyed"])
self.injected = float(data["totalizers"]["TotalEnergyInjected"])
self.self_consumed = float(data["totalizers"]["TotalEnergySelfConsumed"])
Expand Down
37 changes: 37 additions & 0 deletions custom_components/delios/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower,
UnitOfEnergy,
UnitOfTemperature,
)

Expand Down Expand Up @@ -320,4 +321,40 @@ class HelperFilterEntity:
name="Inverter Firmware",
value=lambda data: data["firmware"].firmware,
),
DeliosInverterAttribute(
type=DeliosEntityType.SENSOR,
key="photovoltaic_energy_total",
name="Photovoltaic Energy Total",
state_class=SensorStateClass.TOTAL_INCREASING,
device_class=SensorDeviceClass.ENERGY,
unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
value=lambda data: data["totalizer"].photovoltaic,
),
DeliosInverterAttribute(
type=DeliosEntityType.SENSOR,
key="grid_energy_total",
name="Buyed Energy Total",
state_class=SensorStateClass.TOTAL_INCREASING,
device_class=SensorDeviceClass.ENERGY,
unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
value=lambda data: data["totalizer"].buyed,
),
DeliosInverterAttribute(
type=DeliosEntityType.SENSOR,
key="injected_energy_total",
name="Injected Energy Total",
state_class=SensorStateClass.TOTAL_INCREASING,
device_class=SensorDeviceClass.ENERGY,
unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
value=lambda data: data["totalizer"].injected,
),
DeliosInverterAttribute(
type=DeliosEntityType.SENSOR,
key="self_consumed_energy_total",
name="Self Consumed Energy Total",
state_class=SensorStateClass.TOTAL_INCREASING,
device_class=SensorDeviceClass.ENERGY,
unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
value=lambda data: data["totalizer"].self_consumed,
),
]

0 comments on commit ded226e

Please sign in to comment.