Skip to content

Commit

Permalink
Merge pull request #31 from mattjgalloway/add-pv-energy-sensor
Browse files Browse the repository at this point in the history
Add PV energy sensor
  • Loading branch information
tomasmcguinness authored Feb 13, 2024
2 parents f4e16c8 + 11f4315 commit c872157
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion custom_components/mixergy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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=None, # PVPowerSensor is already in kW
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):
Expand All @@ -443,4 +461,4 @@ def icon(self):

@property
def name(self):
return f"Holiday Mode"
return f"Holiday Mode"

0 comments on commit c872157

Please sign in to comment.