From 7fa3ee8d7c1e1101fd391d44550ebf26653fc23a Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Fri, 9 Feb 2024 20:28:15 +0000 Subject: [PATCH 1/2] Add PV energy integration sensor Just like we have an integration sensor for energy of the electric energy used, also have one for PV. --- custom_components/mixergy/sensor.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/custom_components/mixergy/sensor.py b/custom_components/mixergy/sensor.py index 6945a0d..998ba4a 100644 --- a/custom_components/mixergy/sensor.py +++ b/custom_components/mixergy/sensor.py @@ -45,6 +45,7 @@ async def async_update_data(): new_entities.append(TargetTemperatureSensor(coordinator, tank)) new_entities.append(HolidayModeSensor(coordinator, tank)) new_entities.append(PVPowerSensor(coordinator, tank)) + new_entities.append(PVEnergySensor(tank)) new_entities.append(IsChargingSensor(coordinator, tank)) async_add_entities(new_entities) @@ -423,6 +424,23 @@ def unit_of_measurement(self): def name(self): return f"Mixergy Electric PV Power" +class PVEnergySensor(IntegrationSensor): + + def __init__(self, tank:Tank): + super().__init__( + name="Mixergy Electric PV Energy", + source_entity="sensor.mixergy_electric_pv_power", + round_digits=2, + unit_prefix="k", + unit_time="h", + integration_method="left", + unique_id=f"mixergy_{tank.tank_id}_pv_energy" + ) + + @property + def icon(self): + return "mdi:lightning-bolt" + class HolidayModeSensor(BinarySensorBase): def __init__(self, coordinator, tank:Tank): @@ -443,4 +461,4 @@ def icon(self): @property def name(self): - return f"Holiday Mode" \ No newline at end of file + return f"Holiday Mode" From 11f43157e1e3ce71e5e692f77db4038868fcec6d Mon Sep 17 00:00:00 2001 From: Matt Galloway Date: Sat, 10 Feb 2024 11:09:09 +0000 Subject: [PATCH 2/2] PVPowerSensor already in kW --- custom_components/mixergy/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/mixergy/sensor.py b/custom_components/mixergy/sensor.py index 998ba4a..b9031fe 100644 --- a/custom_components/mixergy/sensor.py +++ b/custom_components/mixergy/sensor.py @@ -431,7 +431,7 @@ def __init__(self, tank:Tank): name="Mixergy Electric PV Energy", source_entity="sensor.mixergy_electric_pv_power", round_digits=2, - unit_prefix="k", + unit_prefix=None, # PVPowerSensor is already in kW unit_time="h", integration_method="left", unique_id=f"mixergy_{tank.tank_id}_pv_energy"