diff --git a/custom_components/delios/client.py b/custom_components/delios/client.py index 8657b50..28c99fe 100644 --- a/custom_components/delios/client.py +++ b/custom_components/delios/client.py @@ -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"]) diff --git a/custom_components/delios/entity.py b/custom_components/delios/entity.py index 0fc3c99..078c3b2 100644 --- a/custom_components/delios/entity.py +++ b/custom_components/delios/entity.py @@ -15,6 +15,7 @@ UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfPower, + UnitOfEnergy, UnitOfTemperature, ) @@ -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, + ), ]