Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes 2023.06.20 #726

Merged
merged 18 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v1.0.x
* Added: Bluetooth: Show signal strength of BMS in log by @mr-manuel
* Added: Create unique identifier, if not provided from BMS by @mr-manuel
* Added: Daly BMS: Auto reset SoC when changing to float (can be turned off in the config file) by @transistorgit
* Added: Exclude a device from beeing used by the dbus-serialbattery driver by @mr-manuel
* Added: Implement callback function for update by @seidler2547
* Added: JKBMS BLE - Show last five characters from the MAC address in the custom name (which is displayed in the device list) by @mr-manuel
Expand All @@ -12,13 +13,14 @@
* Changed: Fix daly readsentence by @transistorgit
* Changed: Fix Sinowealth not loading https://github.com/Louisvdw/dbus-serialbattery/issues/702 by @mr-manuel
* Changed: Fixed error in `reinstall-local.sh` script for Bluetooth installation by @mr-manuel
* Changed: Fixed meaningless Time to Go values by @transistorgit
* Changed: Fixed typo in `config.ini` sample by @hoschult
* Changed: For BMS_TYPE now multiple BMS can be specified by @mr-manuel
* Changed: Improved battery error handling on connection loss by @mr-manuel
* 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: 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
* 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
* Removed: Cronjob to restart Bluetooth service every 12 hours by @mr-manuel


Expand Down
23 changes: 22 additions & 1 deletion etc/dbus-serialbattery/bms/daly.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, port, baud, address):
self.trigger_force_disable_discharge = None
self.trigger_force_disable_charge = None
self.cells_volts_data_lastreadbad = False
self.last_charge_mode = self.charge_mode

# command bytes [StartFlag=A5][Address=40][Command=94][DataLength=8][8x zero bytes][checksum]
command_base = b"\xA5\x40\x94\x08\x00\x00\x00\x00\x00\x00\x00\x00\x81"
Expand Down Expand Up @@ -174,13 +175,26 @@ def refresh_data(self):

self.write_charge_discharge_mos(ser)

if utils.AUTO_RESET_SOC:
self.update_soc(ser)

except OSError:
logger.warning("Couldn't open serial port")

if not result: # TROUBLESHOOTING for no reply errors
logger.info("refresh_data: result: " + str(result))
return result

def update_soc(self, ser):
if self.last_charge_mode is not None and self.charge_mode is not None:
if not self.last_charge_mode.startswith(
"Float"
) and self.charge_mode.startswith("Float"):
# we just entered float mode, so the battery must be full
self.soc_to_set = 100
self.write_soc_and_datetime(ser)
self.last_charge_mode = self.charge_mode

def read_status_data(self, ser):
status_data = self.request_data(ser, self.command_status)
# check if connection success
Expand Down Expand Up @@ -229,7 +243,10 @@ def read_soc_data(self, ser):
)
if crntMinValid < current < crntMaxValid:
self.voltage = voltage / 10
self.current = current
# apply exponential smoothing on the flickering current measurement
self.current = (0.1 * current) + (
0.9 * (0 if self.current is None else self.current)
)
self.soc = soc / 10
return True

Expand Down Expand Up @@ -614,6 +631,10 @@ def force_discharging_off_callback(self, path, value):
return False

def write_charge_discharge_mos(self, ser):
# wait shortly, else the Daly is not ready and throws a lot of no reply errors
# if you see a lot of errors, try to increase in steps of 0.005
sleep(0.020)

if (
self.trigger_force_disable_charge is None
and self.trigger_force_disable_discharge is None
Expand Down
5 changes: 5 additions & 0 deletions etc/dbus-serialbattery/config.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ EXCLUDED_DEVICES =
; /dev/ttyUSB0:My first battery,/dev/ttyUSB1:My second battery
CUSTOM_BATTERY_NAMES =

; Auto reset SoC
; If on, then SoC is reset to 100%, if the value switches from absorption to float voltage
; Currently only working for Daly BMS
AUTO_RESET_SOC = True

; Publish the config settings to the dbus path "/Info/Config/"
PUBLISH_CONFIG_VALUES = 1

Expand Down
28 changes: 1 addition & 27 deletions etc/dbus-serialbattery/dbushelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,6 @@ def setup_instance(self):
0,
0,
],
# 'CellVoltageMin': [path + '/CellVoltageMin', 2.8, 0.0, 5.0],
# 'CellVoltageMax': [path + '/CellVoltageMax', 3.45, 0.0, 5.0],
# 'CellVoltageFloat': [path + '/CellVoltageFloat', 3.35, 0.0, 5.0],
# 'VoltageMaxTime': [path + '/VoltageMaxTime', 900, 0, 0],
# 'VoltageResetSocLimit': [path + '/VoltageResetSocLimit', 90, 0, 100],
# 'MaxChargeCurrent': [path + '/MaxCurrentCharge', 5, 0.0, 500],
# 'MaxDischargeCurrent': [path + '/MaxCurrentDischarge', 7, 0.0, 500],
# 'AllowDynamicChargeCurrent': [path + '/AllowDynamicChargeCurrent', 1, 0, 1],
# 'AllowDynamicDischargeCurrent': [path + '/AllowDynamicDischargeCurrent', 1, 0, 1],
# 'AllowDynamicChargeVoltage': [path + '/AllowDynamicChargeVoltage', 0, 0, 1],
# 'SocLowWarning': [path + '/SocLowWarning', 20, 0, 100],
# 'SocLowAlarm': [path + '/SocLowAlarm', 10, 0, 100],
# 'Capacity': [path + '/Capacity', '', 0, 500],
# 'EnableInvertedCurrent': [path + '/EnableInvertedCurrent', 0, 0, 1],
# 'CCMSocLimitCharge1': [path + '/CCMSocLimitCharge1', 98, 0, 100],
# 'CCMSocLimitCharge2': [path + '/CCMSocLimitCharge2', 95, 0, 100],
# 'CCMSocLimitCharge3': [path + '/CCMSocLimitCharge3', 91, 0, 100],
# 'CCMSocLimitDischarge1': [path + '/CCMSocLimitDischarge1', 10, 0, 100],
# 'CCMSocLimitDischarge2': [path + '/CCMSocLimitDischarge2', 20, 0, 100],
# 'CCMSocLimitDischarge3': [path + '/CCMSocLimitDischarge3', 30, 0, 100],
# 'CCMCurrentLimitCharge1': [path + '/CCMCurrentLimitCharge1', 5, 0, 100],
# 'CCMCurrentLimitCharge2': [path + '/CCMCurrentLimitCharge2', '', 0, 100],
# 'CCMCurrentLimitCharge3': [path + '/CCMCurrentLimitCharge3', '', 0, 100],
# 'CCMCurrentLimitDischarge1': [path + '/CCMCurrentLimitDischarge1', 5, 0, 100],
# 'CCMCurrentLimitDischarge2': [path + '/CCMCurrentLimitDischarge2', '', 0, 100],
# 'CCMCurrentLimitDischarge3': [path + '/CCMCurrentLimitDischarge3', '', 0, 100],
}

self.settings = SettingsDevice(get_bus(), settings, self.handle_changed_setting)
Expand Down Expand Up @@ -612,7 +586,7 @@ def publish_dbus(self):
)
)
)
if self.battery.current
if self.battery.current and abs(self.battery.current) > 0.1
else None
)

Expand Down
7 changes: 6 additions & 1 deletion etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _get_list_from_config(


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

Expand Down Expand Up @@ -298,6 +298,11 @@ def _get_list_from_config(
"DEFAULT", "CUSTOM_BATTERY_NAMES", lambda v: str(v)
)

# Auto reset SoC
# If on, then SoC is reset to 100%, if the value switches from absorption to float voltage
# Currently only working for Daly BMS
AUTO_RESET_SOC = "True" == config["DEFAULT"]["AUTO_RESET_SOC"]

# Publish the config settings to the dbus path "/Info/Config/"
PUBLISH_CONFIG_VALUES = int(config["DEFAULT"]["PUBLISH_CONFIG_VALUES"])

Expand Down