Skip to content

Commit

Permalink
changed battery disconnect behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Dec 17, 2023
1 parent 0e97d9c commit efc0868
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions etc/dbus-serialbattery/dbushelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, battery):
self.settings = None
self.error = {"count": 0, "timestamp_first": None, "timestamp_last": None}
self.block_because_disconnect = False
self.cell_voltages_good = False
self._dbusservice = VeDbusService(
"com.victronenergy.battery."
+ self.battery.port[self.battery.port.rfind("/") + 1 :],
Expand Down Expand Up @@ -620,16 +621,32 @@ def publish_battery(self, loop):
)

# if the battery did not update in 10 second, it's assumed to be offline
if time_since_first_error >= 10:
if time_since_first_error >= 10 and self.battery.online:
self.battery.online = False

# check if the cell voltages are good to go for some minutes
self.cell_voltages_good = (
True
if self.battery.get_min_cell_voltage() > 3.25
and self.battery.get_max_cell_voltage() < 3.35
else False
)

# reset the battery values
self.battery.init_values()

# block charge/discharge
if utils.BLOCK_ON_DISCONNECT:
self.block_because_disconnect = True

# if the battery did not update in 60 second, it's assumed to be completely failed
if time_since_first_error >= 60:
if time_since_first_error >= 60 and (
utils.BLOCK_ON_DISCONNECT or not self.cell_voltages_good
):
loop.quit()

# if the cells are between 3.2 and 3.3 volt we can continue for some time
if time_since_first_error >= 60 * 20 and not utils.BLOCK_ON_DISCONNECT:
loop.quit()

# This is to mannage CVCL
Expand Down

0 comments on commit efc0868

Please sign in to comment.