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

Improvements and fixes #587

Merged
merged 17 commits into from
Apr 27, 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
9 changes: 1 addition & 8 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
[flake8]
max-line-length = 120
exclude =
./etc/dbus-serialbattery/ant.py,
./etc/dbus-serialbattery/battery_template.py,
./etc/dbus-serialbattery/daly.py,
./etc/dbus-serialbattery/dbus-serialbattery.py,
#./etc/dbus-serialbattery/dbus-serialbattery.py,
./etc/dbus-serialbattery/dbushelper.py,
./etc/dbus-serialbattery/ecs.py,
./etc/dbus-serialbattery/lifepower.py,
./etc/dbus-serialbattery/lltjbd.py,
./etc/dbus-serialbattery/minimalmodbus.py,
./etc/dbus-serialbattery/mnb.py,
./etc/dbus-serialbattery/renogy.py,
./etc/dbus-serialbattery/revov.py,
./etc/dbus-serialbattery/sinowealth.py,
./etc/dbus-serialbattery/test_max17853.py,
./etc/dbus-serialbattery/util_max17853.py,
./velib_python
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
--exclude restartservice.sh \
--exclude revov.py \
--exclude test_max17853.py \
--exclude util_max17853.py \
etc/dbus-serialbattery/

- name: Release
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# VS Code
.vscode/

# Custom for this repo
venus-data.tar.gz
BMS-trials
Expand All @@ -161,4 +164,4 @@ BMS-trials
etc/dbus-serialbattery/config.ini

# Local Clone of velib_python
velib_python
velib_python
108 changes: 57 additions & 51 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,60 @@

## v1.0.0-jkbms_ble

* Added: Balancing status for JKBMS
* Added: Balancing switch status for JKBMS
* Added: Balancing switch status to the GUI -> SerialBattery -> IO
* Added: Charge Mode display
* Added: Choose how battery temperature is assembled (mean temp 1 & 2, only temp 1 or only temp 2)
* Added: Create empty `config.ini` for easier user usage
* Added: Cronjob to restart Bluetooth service every 12 hours
* Added: Driver uninstall script
* Added: Fix for Venus OS >= v3.00~14 showing unused items https://github.com/Louisvdw/dbus-serialbattery/issues/469
* Added: HighInternalTemperature alarm (MOSFET) for JKBMS
* Added: Install needed components automatically after a Venus OS upgrade
* Added: JKBMS - MOS temperature https://github.com/Louisvdw/dbus-serialbattery/pull/440
* Added: JKBMS BLE - Balancing switch status
* Added: JKBMS BLE - Capacity
* Added: JKBMS BLE - Cell imbalance alert
* Added: JKBMS BLE - Charging switch status
* Added: JKBMS BLE - Discharging switch status
* Added: JKBMS BLE - MOS temperature
* Added: JKBMS BLE - Show if balancing is active and which cells are balancing
* Added: Post install notes
* Added: Script to install directly from repository
* Added: Show charge mode (absorption, bulk, ...) in Parameters page
* Added: Show charge/discharge limitation reason
* Added: Show specific TimeToSoC points in GUI, if 0%, 10%, 20%, 80%, 90% and/or 100% are selected
* Added: Show TimeToGo in GUI only, if enabled
* Added: Temperature name for temperature sensor 1 & 2. This allows to see which sensor is low and high (e.g. battery and cable)
* Changed: `reinstalllocal.sh` to recreate `/data/conf/serial-starter.d` if deleted by `disabledriver.sh` --> to check if the file `conf/serial-starter.d` could now be removed from the repository
* Changed: Added QML to `restoregui.sh`
* Changed: Bash output
* Changed: Default config file
* Added missing descriptions to make it much clearer to understand
* Changed name from `default_config.ini` to `config.default.ini` https://github.com/Louisvdw/dbus-serialbattery/pull/412#issuecomment-1434287942
* Changed TimeToSoc default value `TIME_TO_SOC_VALUE_TYPE` from `Both seconds and time string "<seconds> [<days>d <hours>h <minutes>m <seconds>s]"` to `1 Seconds`
* Changed TimeToSoc description
* Changed value positions, added groups and much clearer descriptions
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/239
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/311
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/351
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/421
* Changed: Fixed black lint errors
* Changed: Fixed cell balancing background for cells 17-24
* Changed: Fixed Time-To-Go is not working, if `TIME_TO_SOC_VALUE_TYPE` is set to other than `1` https://github.com/Louisvdw/dbus-serialbattery/pull/424#issuecomment-1440511018
* Changed: Logging to get relevant data
* Changed: Moved ble part to `installble.sh`
* Changed: Optimized installation scripts
* Changed: Serial-Starter file is now created from `reinstalllocal.sh`. Fixes also https://github.com/Louisvdw/dbus-serialbattery/issues/520
* Changed: Separate Time-To-Go and Time-To-SoC activation
* Changed: Temperature alarm changed in order to not trigger all in the same condition for JKBMS
* Changed: Time-To-Soc repetition from cycles to seconds. Minimum value is every 5 seconds. This prevents CPU overload and ensures system stability. Renamed `TIME_TO_SOC_LOOP_CYCLES` to `TIME_TO_SOC_RECALCULATE_EVERY`
* Changed: Time-To-Soc string from `days, HR:MN:SC` to `<days>d <hours>h <minutes>m <seconds>s` (same as Time-To-Go)
* Changed: Uninstall also installed Bluetooth modules on uninstall.
* Added: Balancing status for JKBMS by @mr-manuel
* Added: Balancing switch status for JKBMS by @mr-manuel
* Added: Balancing switch status to the GUI -> SerialBattery -> IO by @mr-manuel
* Added: Charge Mode display by @mr-manuel
* Added: Choose how battery temperature is assembled (mean temp 1 & 2, only temp 1 or only temp 2) by @mr-manuel
* Added: Config file by @ppuetsch
* Added: Create empty `config.ini` for easier user usage by @mr-manuel
* Added: Cronjob to restart Bluetooth service every 12 hours by @mr-manuel
* Added: Driver uninstall script by @mr-manuel
* Added: Fix for Venus OS >= v3.00~14 showing unused items https://github.com/Louisvdw/dbus-serialbattery/issues/469 by @mr-manuel
* Added: HighInternalTemperature alarm (MOSFET) for JKBMS by @mr-manuel
* Added: Install needed components automatically after a Venus OS upgrade by @mr-manuel
* Added: JKBMS - MOS temperature https://github.com/Louisvdw/dbus-serialbattery/pull/440 by @mr-manuel
* Added: JKBMS BLE - Balancing switch status by @mr-manuel
* Added: JKBMS BLE - Capacity by @mr-manuel
* Added: JKBMS BLE - Cell imbalance alert by @mr-manuel
* Added: JKBMS BLE - Charging switch status by @mr-manuel
* Added: JKBMS BLE - Discharging switch status by @mr-manuel
* Added: JKBMS BLE - MOS temperature by @mr-manuel
* Added: JKBMS BLE - Show if balancing is active and which cells are balancing by @mr-manuel
* Added: Post install notes by @mr-manuel
* Added: Script to install directly from repository by @mr-manuel
* Added: Show charge mode (absorption, bulk, ...) in Parameters page by @mr-manuel
* Added: Show charge/discharge limitation reason by @mr-manuel
* Added: Show specific TimeToSoC points in GUI, if 0%, 10%, 20%, 80%, 90% and/or 100% are selected by @mr-manuel
* Added: Show TimeToGo in GUI only, if enabled by @mr-manuel
* Added: Support for HLPdata BMS4S https://github.com/Louisvdw/dbus-serialbattery/pull/505 by @peterohman
* Added: Support for Seplos BMS https://github.com/Louisvdw/dbus-serialbattery/pull/530 by @wollew
* Added: Temperature name for temperature sensor 1 & 2. This allows to see which sensor is low and high (e.g. battery and cable) by @mr-manuel
* Changed: `reinstalllocal.sh` to recreate `/data/conf/serial-starter.d` if deleted by `disabledriver.sh` --> to check if the file `conf/serial-starter.d` could now be removed from the repository by @mr-manuel
* Changed: Added QML to `restoregui.sh` by @mr-manuel
* Changed: Bash output by @mr-manuel
* Changed: Default config file by @mr-manuel
* Added missing descriptions to make it much clearer to understand by @mr-manuel
* Changed name from `default_config.ini` to `config.default.ini` https://github.com/Louisvdw/dbus-serialbattery/pull/412#issuecomment-1434287942 by @mr-manuel
* Changed TimeToSoc default value `TIME_TO_SOC_VALUE_TYPE` from `Both seconds and time string "<seconds> [<days>d <hours>h <minutes>m <seconds>s]"` to `1 Seconds` by @mr-manuel
* Changed TimeToSoc description by @mr-manuel
* Changed value positions, added groups and much clearer descriptions by @mr-manuel
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/239 by @mr-manuel
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/311 by @mr-manuel
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/351 by @mr-manuel
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/397 by @transistorgit
* Changed: Fix for https://github.com/Louisvdw/dbus-serialbattery/issues/421 by @mr-manuel
* Changed: Fixed black lint errors by @mr-manuel
* Changed: Fixed cell balancing background for cells 17-24 by @mr-manuel
* Changed: Fixed Time-To-Go is not working, if `TIME_TO_SOC_VALUE_TYPE` is set to other than `1` https://github.com/Louisvdw/dbus-serialbattery/pull/424#issuecomment-1440511018 by @mr-manuel
* Changed: Improved JBD BMS soc calculation https://github.com/Louisvdw/dbus-serialbattery/pull/439 by @aaronreek
* Changed: Logging to get relevant data by @mr-manuel
* Changed: Moved ble part to `installble.sh` by @mr-manuel
* Changed: Optimized installation scripts by @mr-manuel
* Changed: Removed wildcard imports from several BMS drivers and fixed black lint errors by @mr-manuel
* Changed: Serial-Starter file is now created from `reinstalllocal.sh`. Fixes also https://github.com/Louisvdw/dbus-serialbattery/issues/520 by @mr-manuel
* Changed: Separate Time-To-Go and Time-To-SoC activation by @mr-manuel
* Changed: Temperature alarm changed in order to not trigger all in the same condition for JKBMS by @mr-manuel
* Changed: Time-To-Soc repetition from cycles to seconds. Minimum value is every 5 seconds. This prevents CPU overload and ensures system stability. Renamed `TIME_TO_SOC_LOOP_CYCLES` to `TIME_TO_SOC_RECALCULATE_EVERY` by @mr-manuel
* Changed: Time-To-Soc string from `days, HR:MN:SC` to `<days>d <hours>h <minutes>m <seconds>s` (same as Time-To-Go) by @mr-manuel
* Changed: Uninstall also installed Bluetooth modules on uninstall. by @mr-manuel
24 changes: 13 additions & 11 deletions etc/dbus-serialbattery/ant.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from battery import Protection, Battery, Cell
from utils import *
from struct import *
from battery import Battery
from utils import read_serial_data, logger
import utils
from struct import unpack_from


class Ant(Battery):
Expand All @@ -25,17 +26,18 @@ def test_connection(self):
result = False
try:
result = self.read_status_data()
except:
pass
except Exception as err:
logger.error(f"Unexpected {err=}, {type(err)=}")
result = False

return result

def get_settings(self):
# After successful connection get_settings will be call to set up the battery.
# Set the current limits, populate cell count, etc
# Return True if success, False for failure
self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
self.version = "ANT BMS V2.0"
logger.info(self.hardware_version)
return True
Expand All @@ -59,8 +61,8 @@ def read_status_data(self):
self.current = 0.0 if current == 0 else current / -10

self.cell_count = unpack_from(">b", status_data, 123)[0]
self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count
self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count

cell_max_no, cell_max_voltage, cell_min_no, cell_min_voltage = unpack_from(
">bhbh", status_data, 115
Expand Down Expand Up @@ -95,9 +97,9 @@ def read_status_data(self):
)
self.protection.voltage_cell_low = (
2
if self.cell_min_voltage < MIN_CELL_VOLTAGE - 0.1
if self.cell_min_voltage < utils.MIN_CELL_VOLTAGE - 0.1
else 1
if self.cell_min_voltage < MIN_CELL_VOLTAGE
if self.cell_min_voltage < utils.MIN_CELL_VOLTAGE
else 0
)
self.protection.temp_high_charge = (
Expand Down
8 changes: 6 additions & 2 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Protection(object):
They are of type integer, 2 represents an Alarm, 1 a Warning, 0 if everything is fine
"""

ALARM = 2
WARNING = 1
OK = 0

def __init__(self):
self.voltage_high: int = None
self.voltage_low: int = None
Expand Down Expand Up @@ -828,8 +832,8 @@ def log_settings(self) -> None:
)
logger.info(f"> LINEAR LIMITATION ENABLE: {utils.LINEAR_LIMITATION_ENABLE}")
logger.info(
f"> MAX BATTERY CHARGE CURRENT: {utils.MAX_BATTERY_CHARGE_CURRENT}V | "
+ f"MAX BATTERY DISCHARGE CURRENT: {utils.MAX_BATTERY_DISCHARGE_CURRENT}V"
f"> MAX BATTERY CHARGE CURRENT: {utils.MAX_BATTERY_CHARGE_CURRENT}A | "
+ f"MAX BATTERY DISCHARGE CURRENT: {utils.MAX_BATTERY_DISCHARGE_CURRENT}A"
)
logger.info(f"> CVCM: {utils.CVCM_ENABLE}")
logger.info(
Expand Down
18 changes: 10 additions & 8 deletions etc/dbus-serialbattery/battery_template.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from battery import Protection, Battery, Cell
from utils import *
from struct import *
from utils import is_bit_set, read_serial_data, logger
import utils
from struct import unpack_from


class BatteryTemplate(Battery):
Expand All @@ -20,8 +21,9 @@ def test_connection(self):
result = False
try:
result = self.read_status_data()
except:
pass
except Exception as err:
logger.error(f"Unexpected {err=}, {type(err)=}")
result = False

return result

Expand All @@ -32,10 +34,10 @@ def get_settings(self):

# Uncomment if BMS does not supply capacity
# self.capacity = BATTERY_CAPACITY
self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT
self.max_battery_voltage = MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = MIN_CELL_VOLTAGE * self.cell_count
self.max_battery_charge_current = utils.MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count
return True

def refresh_data(self):
Expand Down
Loading