Skip to content

Commit

Permalink
Merge pull request #789 from mr-manuel/dev
Browse files Browse the repository at this point in the history
Changes 2023.08.27
mr-manuel authored Aug 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents b4b9552 + 4e93d6a commit 0131221
Showing 4 changed files with 66 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
* Changed: Improved battery voltage handling in linear absorption mode by @ogurevich
* Changed: Improved driver reinstall when multiple Bluetooth BMS are enabled by @mr-manuel
* Changed: Improved Jkbms_Ble driver by @seidler2547 & @mr-manuel
* Changed: Make CCL and DCL limiting messages more clear by @mr-manuel
* Changed: Reduce the big inrush current if the CVL jumps from Bulk/Absorbtion to Float https://github.com/Louisvdw/dbus-serialbattery/issues/659 by @Rikkert-RS & @ogurevich
* Changed: Time-to-Go and Time-to-SoC use the current average of the last 5 minutes for calculation by @mr-manuel
* Changed: Time-to-SoC calculate only positive points by @mr-manuel
66 changes: 49 additions & 17 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
@@ -564,33 +564,48 @@ def manage_charge_voltage_step(self) -> None:

def manage_charge_current(self) -> None:
# Manage Charge Current Limitations
charge_limits = {utils.MAX_BATTERY_CHARGE_CURRENT: "Config Limit"}
charge_limits = {utils.MAX_BATTERY_CHARGE_CURRENT: "Max Battery Charge Current"}

# if values are not the same, then the limit was read also from the BMS
if utils.MAX_BATTERY_CHARGE_CURRENT != self.max_battery_charge_current:
charge_limits.update({self.max_battery_charge_current: "BMS Limit"})
# if BMS limit is lower then config limit and therefore the values are not the same,
# then the limit was also read from the BMS
if utils.MAX_BATTERY_CHARGE_CURRENT > self.max_battery_charge_current:
charge_limits.update({self.max_battery_charge_current: "BMS Settings"})

if utils.CCCM_CV_ENABLE:
tmp = self.calcMaxChargeCurrentReferringToCellVoltage()
if self.max_battery_charge_current != tmp:
if tmp in charge_limits:
charge_limits.update({tmp: charge_limits[tmp] + ", Cell Voltage"})
# do not add string, if global limitation is applied
if charge_limits["tmp"] != "Max Battery Charge Current":
charge_limits.update(
{tmp: charge_limits[tmp] + ", Cell Voltage"}
)
else:
pass
else:
charge_limits.update({tmp: "Cell Voltage"})

if utils.CCCM_T_ENABLE:
tmp = self.calcMaxChargeCurrentReferringToTemperature()
if self.max_battery_charge_current != tmp:
if tmp in charge_limits:
charge_limits.update({tmp: charge_limits[tmp] + ", Temp"})
# do not add string, if global limitation is applied
if charge_limits["tmp"] != "Max Battery Charge Current":
charge_limits.update({tmp: charge_limits[tmp] + ", Temp"})
else:
pass
else:
charge_limits.update({tmp: "Temp"})

if utils.CCCM_SOC_ENABLE:
tmp = self.calcMaxChargeCurrentReferringToSoc()
if self.max_battery_charge_current != tmp:
if tmp in charge_limits:
charge_limits.update({tmp: charge_limits[tmp] + ", SoC"})
# do not add string, if global limitation is applied
if charge_limits["tmp"] != "Max Battery Charge Current":
charge_limits.update({tmp: charge_limits[tmp] + ", SoC"})
else:
pass
else:
charge_limits.update({tmp: "SoC"})

@@ -628,35 +643,52 @@ def manage_charge_current(self) -> None:
#####

# Manage Discharge Current Limitations
discharge_limits = {utils.MAX_BATTERY_DISCHARGE_CURRENT: "Config Limit"}

# if values are not the same, then the limit was read also from the BMS
if utils.MAX_BATTERY_DISCHARGE_CURRENT != self.max_battery_discharge_current:
discharge_limits.update({self.max_battery_discharge_current: "BMS Limit"})
discharge_limits = {
utils.MAX_BATTERY_DISCHARGE_CURRENT: "Max Battery Discharge Current"
}

# if BMS limit is lower then config limit and therefore the values are not the same,
# then the limit was also read from the BMS
if utils.MAX_BATTERY_DISCHARGE_CURRENT > self.max_battery_discharge_current:
discharge_limits.update(
{self.max_battery_discharge_current: "BMS Settings"}
)

if utils.DCCM_CV_ENABLE:
tmp = self.calcMaxDischargeCurrentReferringToCellVoltage()
if self.max_battery_discharge_current != tmp:
if tmp in discharge_limits:
discharge_limits.update(
{tmp: discharge_limits[tmp] + ", Cell Voltage"}
)
# do not add string, if global limitation is applied
if discharge_limits["tmp"] != "Max Battery Discharge Current":
discharge_limits.update(
{tmp: discharge_limits[tmp] + ", Cell Voltage"}
)
else:
pass
else:
discharge_limits.update({tmp: "Cell Voltage"})

if utils.DCCM_T_ENABLE:
tmp = self.calcMaxDischargeCurrentReferringToTemperature()
if self.max_battery_discharge_current != tmp:
if tmp in discharge_limits:
discharge_limits.update({tmp: discharge_limits[tmp] + ", Temp"})
# do not add string, if global limitation is applied
if discharge_limits["tmp"] != "Max Battery Discharge Current":
discharge_limits.update({tmp: discharge_limits[tmp] + ", Temp"})
else:
pass
else:
discharge_limits.update({tmp: "Temp"})

if utils.DCCM_SOC_ENABLE:
tmp = self.calcMaxDischargeCurrentReferringToSoc()
if self.max_battery_discharge_current != tmp:
if tmp in discharge_limits:
discharge_limits.update({tmp: discharge_limits[tmp] + ", SoC"})
# do not add string, if global limitation is applied
if discharge_limits["tmp"] != "Max Battery Discharge Current":
discharge_limits.update({tmp: discharge_limits[tmp] + ", SoC"})
else:
pass
else:
discharge_limits.update({tmp: "SoC"})

36 changes: 15 additions & 21 deletions etc/dbus-serialbattery/dbushelper.py
Original file line number Diff line number Diff line change
@@ -636,27 +636,21 @@ def publish_dbus(self):

# Update TimeToGo item
if utils.TIME_TO_GO_ENABLE:
if self.battery.current_avg is not None:
# Update TimeToGo item, has to be a positive int since it's used from dbus-systemcalc-py
self._dbusservice["/TimeToGo"] = (
abs(
int(
self.battery.get_timeToSoc(
# switch value depending on charging/discharging
utils.SOC_LOW_WARNING
if self.battery.current_avg < 0
else 100,
crntPrctPerSec,
True,
)
)
)
if self.battery.current_avg
and abs(self.battery.current_avg) > 0.1
else None
)
else:
self._dbusservice["/TimeToGo"] = None
# Update TimeToGo item, has to be a positive int since it's used from dbus-systemcalc-py
time_to_go = self.battery.get_timeToSoc(
# switch value depending on charging/discharging
utils.SOC_LOW_WARNING if self.battery.current_avg < 0 else 100,
crntPrctPerSec,
True,
)

# Check that time_to_go is not None and current is not near zero
self._dbusservice["/TimeToGo"] = (
abs(int(time_to_go))
if time_to_go is not None
and abs(self.battery.current_avg) > 0.1
else None
)

# Update TimeToSoc items
if len(utils.TIME_TO_SOC_POINTS) > 0:
2 changes: 1 addition & 1 deletion etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ def _get_list_from_config(


# Constants - Need to dynamically get them in future
DRIVER_VERSION = "1.0.20230723dev"
DRIVER_VERSION = "1.0.20230827dev"
zero_char = chr(48)
degree_sign = "\N{DEGREE SIGN}"

0 comments on commit 0131221

Please sign in to comment.