Skip to content

Commit 8458763

Browse files
committed
Automatically check for changed battery capacity
1 parent 8d3976c commit 8458763

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

source/inverter.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,23 @@ def __init__(self):
1313
super().__init__()
1414

1515
self.device = None
16-
1716
self.hostname = EnvironmentVariableGetter.get("INVERTER_HOSTNAME")
18-
sems_portal_api_handler = SemsPortalApiHandler()
19-
self.battery_capacity = sems_portal_api_handler.get_battery_capacity()
17+
18+
self.sems_portal_api_handler = SemsPortalApiHandler()
19+
self.battery_capacity = None
20+
self.update_battery_capacity()
21+
22+
def update_battery_capacity(self) -> None:
23+
battery_capacity = self.sems_portal_api_handler.get_battery_capacity()
24+
25+
if self.battery_capacity is None:
26+
self.log.info(f"The battery capacity is {battery_capacity}")
27+
self.battery_capacity = battery_capacity
28+
return
29+
30+
if battery_capacity != self.battery_capacity:
31+
self.log.info(f"The battery capacity was updated from {self.battery_capacity} to {battery_capacity}")
32+
self.battery_capacity = battery_capacity
2033

2134
def connect(self) -> None:
2235
"""

source/inverter_charge_controller.py

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def _do_iteration(self, current_energy_rate: EnergyRate) -> EnergyRate:
126126
"Waiting is over, now is the a price minimum. Checking what has to be done to reach the next minimum..."
127127
)
128128

129+
self.inverter.update_battery_capacity()
130+
129131
timestamp_now = TimeHandler.get_time()
130132

131133
next_price_minimum = self.tibber_api_handler.get_next_price_minimum()

0 commit comments

Comments
 (0)