Skip to content

Commit

Permalink
Cvl fix (#353)
Browse files Browse the repository at this point in the history
* fix #334 missing CVL

* fix #325 restore GUI

* fix #339 negative temp

* Deprecate Revov driver - replaced by LifePower
  • Loading branch information
Louisvdw authored Dec 15, 2022
1 parent e2600ae commit 7b23900
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion buildfiles.lst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ etc/dbus-serialbattery/disabledriver.sh
etc/dbus-serialbattery/installlocal.sh
etc/dbus-serialbattery/installrelease.sh
etc/dbus-serialbattery/reinstalllocal.sh
etc/dbus-serialbattery/restoregui.sh
etc/dbus-serialbattery/installqml.sh
etc/dbus-serialbattery/qml/PageBattery.qml
etc/dbus-serialbattery/qml/PageBatteryCellVoltages.qml
Expand All @@ -26,6 +27,5 @@ etc/dbus-serialbattery/mnb.py
etc/dbus-serialbattery/jkbms.py
etc/dbus-serialbattery/sinowealth.py
etc/dbus-serialbattery/renogy.py
etc/dbus-serialbattery/revov.py
etc/dbus-serialbattery/ecs.py
etc/dbus-serialbattery/lifepower.py
18 changes: 9 additions & 9 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ def to_temp(self, sensor, value):

def manage_charge_voltage(self):
if LINEAR_LIMITATION_ENABLE:
return self.manage_charge_voltage_linear()
return self.manage_charge_voltage_step()
self.manage_charge_voltage_linear()
else:
self.manage_charge_voltage_step()

def manage_charge_voltage_linear(self):
foundHighCellVoltage = False
if CVCM_ENABLE:
foundHighCellVoltage = False
currentBatteryVoltage = 0
penaltySum = 0
for i in range(self.cell_count):
Expand All @@ -120,13 +121,12 @@ def manage_charge_voltage_linear(self):
if cv >= PENALTY_AT_CELL_VOLTAGE[0]:
foundHighCellVoltage = True
penaltySum += calcLinearRelationship(cv, PENALTY_AT_CELL_VOLTAGE, PENALTY_BATTERY_VOLTAGE)

self.voltage = currentBatteryVoltage # for testing
if foundHighCellVoltage:
self.control_voltage = currentBatteryVoltage - penaltySum
else:
self.control_voltage = MAX_CELL_VOLTAGE * self.cell_count
return penaltySum

if foundHighCellVoltage:
self.control_voltage = currentBatteryVoltage - penaltySum
else:
self.control_voltage = MAX_CELL_VOLTAGE * self.cell_count

def manage_charge_voltage_step(self):
voltageSum = 0
Expand Down
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/jkbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def read_status_data(self):
temp1 = unpack_from('>H', self.get_data(status_data, b'\x81', offset, 2))[0]
offset = cellbyte_count + 9
temp2 = unpack_from('>H', self.get_data(status_data, b'\x82', offset, 2))[0]
self.to_temp(1, temp1 if temp1 <= 100 else 100 - temp1)
self.to_temp(2, temp2 if temp2 <= 100 else 100 - temp2)
self.to_temp(1, temp1 if temp1 <= 100 else -(temp1 - 100))
self.to_temp(2, temp1 if temp2 <= 100 else -(temp2 - 100))

offset = cellbyte_count + 12
voltage = unpack_from('>H', self.get_data(status_data, b'\x83', offset, 2))[0]
Expand Down
11 changes: 11 additions & 0 deletions etc/dbus-serialbattery/restoregui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

#restore original backup
cp -f /opt/victronenergy/gui/qml/PageBattery.qml.backup /opt/victronenergy/gui/qml/PageBattery.qml

#stop gui
svc -d /service/gui
#sleep 1 sec
sleep 1
#start gui
svc -u /service/gui
3 changes: 1 addition & 2 deletions etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
{"bms" : "Lifepower"},
{"bms" : "Renogy", "address": b"\x30"},
{"bms" : "Renogy", "address": b"\xF7"},
# {"bms" : "Revov"},
{"bms" : "Ecs", "baud" : 19200},
# {"bms" : "MNB"},
]

# Constants - Need to dynamically get them in future
DRIVER_VERSION = 0.14
DRIVER_SUBVERSION = '1'
DRIVER_SUBVERSION = '2'
zero_char = chr(48)
degree_sign = u'\N{DEGREE SIGN}'

Expand Down

0 comments on commit 7b23900

Please sign in to comment.