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.05.18 #649

Merged
merged 427 commits into from
May 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
427 commits
Select commit Hold shift + click to select a range
2ffa358
Added: Show specific TimeToSoC points in GUI
mr-manuel Apr 26, 2023
6c710b1
Added: Show specific TimeToSoC points in GUI
mr-manuel Apr 26, 2023
f7682fe
fix black lint error
mr-manuel Apr 26, 2023
5a16cbd
fix black lint error
mr-manuel Apr 26, 2023
964ec17
Some improvement and fixes
mr-manuel Apr 26, 2023
1e6d410
Improved JBD BMS soc calculation
mr-manuel Apr 27, 2023
922b82c
Fix for #397
mr-manuel Apr 27, 2023
23356f6
small fixes
mr-manuel Apr 27, 2023
4bd257f
sort bms imports
mr-manuel Apr 27, 2023
c56a9d1
Add support for HLPdata BMS4S
mr-manuel Apr 27, 2023
314bb93
Add support for Seplos BMS
mr-manuel Apr 27, 2023
aceeac9
change flake8 settings
mr-manuel Apr 27, 2023
64a08f4
fix black lint errors
mr-manuel Apr 27, 2023
31647db
removed wildcard imports
mr-manuel Apr 27, 2023
8d3f25e
fixed black lint errors
mr-manuel Apr 27, 2023
a4a3efb
change flake8 settings
mr-manuel Apr 27, 2023
4a26d0d
remove wildcard import and fix black lint errors
mr-manuel Apr 27, 2023
564d4ed
removed wildcard import
mr-manuel Apr 27, 2023
41cdadb
fixed black lint check
mr-manuel Apr 27, 2023
51f5241
removed wildcard import, fixed black lint errors
mr-manuel Apr 27, 2023
440b113
config changes
mr-manuel Apr 27, 2023
a286645
removed wildcard import, fixed black lint errors
mr-manuel Apr 27, 2023
b7ddfa4
remove old log message in handle_changed_setting()
mr-manuel Apr 27, 2023
bc91973
remove old log message in handle_changed_setting()
mr-manuel Apr 27, 2023
808359b
simplified condition for Time-To-Go/Soc
mr-manuel Apr 27, 2023
83668b6
simplified condition for Time-To-Go/Soc
mr-manuel Apr 27, 2023
e7766bc
Merge branch 'master' into master
mr-manuel Apr 27, 2023
5001d03
remove duplicated and incorrect log message on handle_changed_setting
mr-manuel Apr 27, 2023
ed4d57b
Improvements and fixes
mr-manuel Apr 27, 2023
d54581e
fix renogy import
mr-manuel Apr 27, 2023
aee71f0
fix renogy import
mr-manuel Apr 27, 2023
362916c
Merge pull request #588 from mr-manuel/jkbms_ble
mr-manuel Apr 27, 2023
9e358fa
added BMS info and cleanup
mr-manuel Apr 28, 2023
51fb746
added BMS info and cleanup
mr-manuel Apr 28, 2023
09034a1
moved BMS to subfolder
mr-manuel Apr 28, 2023
a0918ee
moved BMS to subfolder
mr-manuel Apr 28, 2023
eaa6e3b
moved BMS to subfolder
mr-manuel Apr 28, 2023
8f7d705
corrected installble to run correct script
mr-manuel Apr 28, 2023
89cfe0a
Added self.unique_identifier to the battery class
mr-manuel Apr 28, 2023
3a62eed
Added self.unique_identifier to the battery class
mr-manuel Apr 28, 2023
d882937
changed ble service name
mr-manuel Apr 28, 2023
cc82d7b
fix small errors
mr-manuel Apr 28, 2023
0aed855
Changes 2023.04.28
mr-manuel Apr 28, 2023
d3a72d6
read installed capacity at startup
transistorgit Apr 28, 2023
b113bff
Merge pull request #594 from transistorgit/daly_capacity
mr-manuel Apr 28, 2023
9cea902
disable ANT BMS by default
mr-manuel Apr 29, 2023
49694b6
fix cell voltage header parser
transistorgit Apr 29, 2023
3a583ed
rework daly receive routine
transistorgit Apr 29, 2023
554c01d
improve read cell voltages - only work on sufficient data, drop only …
transistorgit Apr 29, 2023
e8ad26d
allow read_soc to also retry serial transmission
transistorgit Apr 29, 2023
93a4e98
add daly cell balance state info. cells are red only if unbalanced now
transistorgit Apr 29, 2023
fdd0bd1
bump version
mr-manuel Apr 29, 2023
ec04969
typo
mr-manuel Apr 29, 2023
ae1e447
Fixes
mr-manuel Apr 29, 2023
878014b
Merge branch 'Louisvdw:jkbms_ble' into jkbms_ble
transistorgit Apr 29, 2023
d1238e0
moved read_serialport_data() to daly.py
transistorgit May 1, 2023
62422de
revert read_serialport_data() to the state before my changes
transistorgit May 1, 2023
a3915cb
fix connection log startup message.
transistorgit May 1, 2023
4d4d256
Revert utils.py changes, improved Daly driver
mr-manuel May 1, 2023
3153962
black reformatting
transistorgit May 1, 2023
eb7f328
added linear voltage recalculation interval
mr-manuel May 1, 2023
157532b
revert Daly adaption
mr-manuel May 1, 2023
aba26a9
replaced penalty voltage calculation
mr-manuel May 1, 2023
dac8766
flake config change
mr-manuel May 1, 2023
ec4a334
flake config change
mr-manuel May 1, 2023
31a1e53
added linear voltage recalculation interval
mr-manuel May 1, 2023
295efd1
replaced penalty voltage calculation
mr-manuel May 1, 2023
f95dc05
fix black lint errors
mr-manuel May 1, 2023
17acb70
updated changelog
mr-manuel May 1, 2023
509e0bb
disabled ANT BMS by default
mr-manuel May 1, 2023
52fdc4a
updated config.default.ini
mr-manuel May 1, 2023
3339fb1
fix typo
mr-manuel May 1, 2023
d820050
Changes 2023.05.01
mr-manuel May 1, 2023
912cd74
update nightly install script
mr-manuel May 1, 2023
4de2ae5
update nightly install script
mr-manuel May 1, 2023
93caa23
Removed line
mr-manuel May 1, 2023
fce00b9
fixed error in HLPdataBMS4S
mr-manuel May 1, 2023
10972b9
fixed wrong variable assignment
mr-manuel May 2, 2023
9e4b069
fixed wrong variable assignment
mr-manuel May 2, 2023
80e2c67
updated battery template
mr-manuel May 2, 2023
a225059
updated battery template
mr-manuel May 2, 2023
70658e9
Fix for #450
mr-manuel May 2, 2023
fbfdcc7
Read charge/discharge limit JKBMS
mr-manuel May 2, 2023
5c9d30a
updated battery template
mr-manuel May 2, 2023
6a9ee0a
Progress with config limits reason
mr-manuel May 2, 2023
ebfb5bc
updated CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT default value
mr-manuel May 2, 2023
1d82436
Changes 2023.05.02
mr-manuel May 2, 2023
f44157a
added SoC round for LLT/JBD
mr-manuel May 2, 2023
da3fa07
fixed log typo
mr-manuel May 2, 2023
faeede5
updated nightly script
mr-manuel May 2, 2023
58b06b7
Fix for #450
mr-manuel May 2, 2023
163a4c9
Read charge/discharge limit JKBMS
mr-manuel May 2, 2023
cf46dab
reworked installation procedure
mr-manuel May 2, 2023
58dc5da
Merge branch 'master' into pr/468
mr-manuel May 2, 2023
b9f24cc
updated release workflow
mr-manuel May 2, 2023
7a584bd
Merge branch 'master' of https://github.com/mr-manuel/venus-os_dbus-s…
mr-manuel May 2, 2023
1e67d5b
updated readme
mr-manuel May 2, 2023
9907912
Merge branch 'Louisvdw:jkbms_ble' into jkbms_ble
mr-manuel May 2, 2023
94b1a21
Merge branch 'master' into jkbms_ble
mr-manuel May 2, 2023
93cb3f0
Merge branch 'jkbms_ble' of https://github.com/mr-manuel/venus-os_dbu…
mr-manuel May 2, 2023
41c77a8
deploy to github pages only
mr-manuel May 2, 2023
83ea14e
cleanup
mr-manuel May 2, 2023
557b9ac
Merge branch 'master' of into jkbms_ble
mr-manuel May 2, 2023
335a0e7
GitHub pages config change
mr-manuel May 2, 2023
632c5ac
GitHub pages config change
mr-manuel May 2, 2023
9f1da97
cleanup
mr-manuel May 2, 2023
74b459a
Renamed scripts for better reading #532
mr-manuel May 3, 2023
dff74d7
update docusaurus dependencies
mr-manuel May 3, 2023
645cd92
Renamed scripts for better reading #532
mr-manuel May 3, 2023
19a62bc
update docusaurus dependencies
mr-manuel May 3, 2023
c615a61
change sh with bash
mr-manuel May 3, 2023
a1972c8
Merge branch 'master' into jkbms_ble
mr-manuel May 3, 2023
43368fe
limitation reason cleanup
mr-manuel May 3, 2023
cf88e22
limitation reason cleanup
mr-manuel May 3, 2023
ad2855d
changed default config settings
mr-manuel May 3, 2023
1f7b11d
changed default config settings
mr-manuel May 3, 2023
2c9d3dd
Merge branch 'jkbms_ble' into jkbms_ble
mr-manuel May 3, 2023
9fcf1a5
Changes 2023.05.03
mr-manuel May 3, 2023
66f982a
removed testing line
mr-manuel May 3, 2023
524321c
Cleanup duplicated files
mr-manuel May 3, 2023
ff1b143
Cleanup
mr-manuel May 3, 2023
12ec57e
MOSFET temperature was displayed twice after merge
mr-manuel May 3, 2023
c283067
small typo fixes
mr-manuel May 3, 2023
84556e8
updated changelog
mr-manuel May 3, 2023
7ea6317
updated changelog
mr-manuel May 3, 2023
56fecf3
Small fixes
mr-manuel May 3, 2023
bbb7b1b
fix disconnection behaviour: on disconnect, show '---' after 10s and …
transistorgit May 3, 2023
1514206
fix merge conflicts
transistorgit May 3, 2023
d647b1e
fix flake errors
transistorgit May 3, 2023
f496103
Merge pull request #4 from transistorgit/jkbms_ble
mr-manuel May 4, 2023
8ed42ae
small fix
mr-manuel May 4, 2023
32079a9
fix disconnection behaviour & small fixes
mr-manuel May 4, 2023
c93c7ac
fixed file permission
mr-manuel May 4, 2023
77fc212
Added: apply max voltage if CVCM_ENABLE is False
mr-manuel May 4, 2023
9acfb15
fixed type error
mr-manuel May 4, 2023
7e1ada1
Added: BMS disconnect behaviour
mr-manuel May 4, 2023
2b32e11
Changed: Remove wildcard import from dbushelper.py
mr-manuel May 4, 2023
cd8c22a
small fixes
mr-manuel May 4, 2023
2c20991
Added: apply max voltage if CVCM_ENABLE is False
mr-manuel May 4, 2023
28395bc
Added: BMS disconnect behaviour
mr-manuel May 4, 2023
47fe42c
Changed: Remove wildcard import from dbushelper.py
mr-manuel May 4, 2023
8a37bf2
Changes 2023.05.04
mr-manuel May 4, 2023
1ad0f13
flake8 changes
mr-manuel May 4, 2023
1e93047
copied lltjbd_ble from idstein:jdb_ble
mr-manuel May 4, 2023
497fa2b
Added and adapted LltJbd_Ble
mr-manuel May 4, 2023
e25eff1
small changes
mr-manuel May 4, 2023
5e4d375
Merge branch 'jkbms_ble' of https://github.com/mr-manuel/venus-os_dbu…
mr-manuel May 4, 2023
b05053d
read production date and append to hardware version
transistorgit May 4, 2023
0135916
Set SOC nightly. Button is working, next is send command to bms
transistorgit May 4, 2023
62d8afd
Added: Show additional data in device page
mr-manuel May 5, 2023
94fc423
Added: JKBMS unique identifier & fixed data length
mr-manuel May 5, 2023
f79ce83
Added: JKBMS BLE unique identifier
mr-manuel May 5, 2023
2e8e7fc
Added: Jkbms_Ble connection_name()
mr-manuel May 5, 2023
61571be
read production date and append to hardware version
mr-manuel May 5, 2023
6c4c545
Added: Daly unique identifier
mr-manuel May 5, 2023
a22cde9
Added: JKBMS BLE serial number, user defined field
mr-manuel May 5, 2023
a6b6465
Added: Show additional data in device page
mr-manuel May 5, 2023
63433a1
Added: JKBMS unique identifier & fixed data length
mr-manuel May 5, 2023
6897900
move config.ini before update
mr-manuel May 5, 2023
082bbeb
read production date by @tranistorgit
mr-manuel May 5, 2023
aff297e
Changes 2023.05.05
mr-manuel May 5, 2023
fe77013
read out daly battery code and use as unique id
transistorgit May 5, 2023
f0e4270
moved production date and added custom field
mr-manuel May 5, 2023
16b0e70
Merge pull request #6 from transistorgit/daly_battery_code
mr-manuel May 5, 2023
8953689
clean battery code
mr-manuel May 5, 2023
8dafe69
Merge branch 'Louisvdw:master' into master
mr-manuel May 6, 2023
e794363
Daly read_capacity change
mr-manuel May 6, 2023
8aeebb1
Daly try to fix no reply
mr-manuel May 6, 2023
a51c975
Improvements by @transistorgit
mr-manuel May 6, 2023
ff205b8
changed value
mr-manuel May 6, 2023
7346758
set SOC (and date time) on button press.
transistorgit May 6, 2023
a480158
Merge branch 'jkbms_ble' into set_daly_soc
transistorgit May 6, 2023
991b1db
fix battery code parser
transistorgit May 6, 2023
80d7194
format fix
transistorgit May 6, 2023
46855e2
format fix
transistorgit May 6, 2023
11696e8
fix extra long serial timeouts
transistorgit May 6, 2023
115521d
Merge branch 'Louisvdw:master' into master
mr-manuel May 6, 2023
0fc9589
Changed: Merged all install files into one
mr-manuel May 6, 2023
f45d4db
Merge branch 'master' of https://github.com/mr-manuel/venus-os_dbus-s…
mr-manuel May 6, 2023
76b8410
updated install docs for nightly build
mr-manuel May 6, 2023
c980e3b
Small fixes
mr-manuel May 6, 2023
a8703c3
Merge pull request #7 from transistorgit/set_daly_soc
mr-manuel May 6, 2023
d908a21
changed config backup
mr-manuel May 6, 2023
6a06313
updated config file
mr-manuel May 6, 2023
c22e174
updated changelog
mr-manuel May 6, 2023
cb050e2
Changes 2023.05.06
mr-manuel May 6, 2023
20d83e2
debug daly
mr-manuel May 7, 2023
12b0a4c
Merge branch 'jkbms_ble' of https://github.com/mr-manuel/venus-os_dbu…
mr-manuel May 7, 2023
1a11eaa
changed release workflow
mr-manuel May 7, 2023
eb7a8cf
changed release workflow
mr-manuel May 7, 2023
910d228
changed release workflow
mr-manuel May 7, 2023
bbcd135
changed release workflow
mr-manuel May 7, 2023
a88d704
Updated from master
mr-manuel May 7, 2023
2f047a9
fix blank screen, debug daly
mr-manuel May 7, 2023
944feda
make Reset SoC a spin box
transistorgit May 7, 2023
ecb586d
Merge pull request #8 from transistorgit/set_daly_soc
mr-manuel May 7, 2023
13a9f41
Changes 2023.05.07
mr-manuel May 7, 2023
b83f5bf
fix possible read_capacity problem
transistorgit May 7, 2023
6816441
Merge pull request #9 from transistorgit/set_daly_soc
mr-manuel May 7, 2023
e5880bd
Daly read_balance_state() add missing return
mr-manuel May 7, 2023
f167eb0
Daly advanced troubleshooting
mr-manuel May 7, 2023
93bbbfe
Merge branch 'jkbms_ble' of https://github.com/mr-manuel/venus-os_dbu…
mr-manuel May 7, 2023
a74cd5d
Changed: Improved Daily stability by a lot
mr-manuel May 8, 2023
8185918
fixes for disable and uninstall
mr-manuel May 8, 2023
b3cd424
optimized USB install method
mr-manuel May 8, 2023
4a92378
updated changelog
mr-manuel May 8, 2023
80a10c4
added missing qml to restore-gui.sh
mr-manuel May 8, 2023
6250836
Changes 2023.05.08
mr-manuel May 8, 2023
a5ae224
optimized USB install method
mr-manuel May 8, 2023
f721682
Daly improvements
mr-manuel May 8, 2023
043a4a2
moved production date and added custom field
mr-manuel May 8, 2023
9db0847
Merge branch 'Louisvdw:master' into master
mr-manuel May 8, 2023
3eb5e57
Merge branch 'Louisvdw:master' into master
mr-manuel May 8, 2023
b7c14ea
changed jkbms_ble to dev
mr-manuel May 8, 2023
5bd3bc3
changed order
mr-manuel May 8, 2023
cc98244
final daly 'broken packages handling'
transistorgit May 8, 2023
777b18d
Merge branch 'pr/10' into dev
mr-manuel May 8, 2023
4256c47
Last changes for daly read problem
mr-manuel May 8, 2023
9d0fe6b
change version in utils based on GitHub tag
mr-manuel May 9, 2023
53349c9
test automatic release version change
mr-manuel May 9, 2023
47a3d16
Merge branch 'dev' of https://github.com/mr-manuel/venus-os_dbus-seri…
mr-manuel May 9, 2023
a2e988c
Added: Configure voltage drop
mr-manuel May 9, 2023
c543e75
test automatic release version change
mr-manuel May 9, 2023
cc7e35e
fix Daly alarms
mr-manuel May 10, 2023
53daa76
fixes small errors in bash files
mr-manuel May 10, 2023
98e8286
fix missing driver name in restart-driver.sh
transistorgit May 11, 2023
04befba
linear mode, allow max voltage on soc thesshold
mr-manuel May 12, 2023
55d7130
Daly added one retry if failed
mr-manuel May 12, 2023
d30e0ca
fixed LLT/JBD cell balancing display
mr-manuel May 12, 2023
72a4017
rename tar after USB install
mr-manuel May 12, 2023
251a2f8
Merge branch 'jkbms_ble' of github.com:transistorgit/dbus-serialbatte…
transistorgit May 15, 2023
5c134be
add force buttons
transistorgit May 15, 2023
15cde94
force buttons working
transistorgit May 15, 2023
07af17e
fixed removing entries
mr-manuel May 15, 2023
2e68714
implement force charge/discharge
transistorgit May 15, 2023
880d779
little bit cleaner soc preset
transistorgit May 15, 2023
6d300d4
Merge pull request #1 from transistorgit/fix-restart-driver.sh
transistorgit May 16, 2023
10a921f
Merge branch 'dev' into jkbms_ble
transistorgit May 16, 2023
f747ba0
Merge branch 'Louisvdw:dev' into dev
mr-manuel May 16, 2023
cb0e53d
use existing serial read/write function
transistorgit May 16, 2023
219e3b7
add stop balancong switch
transistorgit May 16, 2023
3abd689
use existing serial read/write function
transistorgit May 16, 2023
2c6e298
Merge branch 'jkbms_ble' of github.com:transistorgit/dbus-serialbatte…
transistorgit May 16, 2023
8f8f587
Changed: Get bg colors from MbStyle for dark mode
mr-manuel May 17, 2023
f80f826
Merge branch 'dev' of https://github.com/mr-manuel/venus-os_dbus-seri…
mr-manuel May 17, 2023
5496723
prevent short circuit evaluation
transistorgit May 17, 2023
194a8d5
Merge pull request #11 from transistorgit/jkbms_ble
mr-manuel May 18, 2023
1453003
fix merge errors
mr-manuel May 18, 2023
05bf2b8
added changelog info
mr-manuel May 18, 2023
09171fe
Fix #648
mr-manuel May 18, 2023
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
Prev Previous commit
Next Next commit
removed wildcard import, fixed black lint errors
mr-manuel committed Apr 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 51f524166ec3114dab7b59d2c7ab93abb0ecfcd0
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
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ jobs:
--exclude restartservice.sh \
--exclude revov.py \
--exclude test_max17853.py \
--exclude util_max17853.py \
etc/dbus-serialbattery/

- name: Release
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
@@ -161,4 +164,4 @@ BMS-trials
etc/dbus-serialbattery/config.ini

# Local Clone of velib_python
velib_python
velib_python
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):
@@ -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
@@ -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
@@ -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 = (
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):
@@ -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

@@ -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):
24 changes: 13 additions & 11 deletions etc/dbus-serialbattery/ecs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from battery import Protection, Battery, Cell
from utils import *
from struct import *
from utils import logger
import utils
import minimalmodbus


@@ -33,7 +33,7 @@ def test_connection(self):

# Trying to find Green Meter ID
try:
mbdev = minimalmodbus.Instrument(self.port, GREENMETER_ADDRESS)
mbdev = minimalmodbus.Instrument(self.port, utils.GREENMETER_ADDRESS)
mbdev.serial.parity = minimalmodbus.serial.PARITY_EVEN
tmpId = mbdev.read_register(0, 0)
if tmpId in range(self.GREENMETER_ID_500A, self.GREENMETER_ID_125A + 1):
@@ -52,7 +52,9 @@ def test_connection(self):

def find_LiPro_cells(self):
# test for LiPro cell devices
for cell_address in range(LIPRO_START_ADDRESS, LIPRO_END_ADDRESS + 1):
for cell_address in range(
utils.LIPRO_START_ADDRESS, utils.LIPRO_END_ADDRESS + 1
):
try:
mbdev = minimalmodbus.Instrument(self.port, cell_address)
mbdev.serial.parity = minimalmodbus.serial.PARITY_EVEN
@@ -74,11 +76,11 @@ def get_settings(self):
# Return True if success, False for failure

# Uncomment if BMS does not supply capacity
self.max_battery_charge_current = MAX_BATTERY_CHARGE_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT
self.cell_count = LIPRO_CELL_COUNT
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.cell_count = utils.LIPRO_CELL_COUNT
self.max_battery_voltage = utils.MAX_CELL_VOLTAGE * self.cell_count
self.min_battery_voltage = utils.MIN_CELL_VOLTAGE * self.cell_count
self.temp_sensors = 2

return self.read_status_data()
@@ -94,7 +96,7 @@ def refresh_data(self):

def read_status_data(self):
try:
mbdev = minimalmodbus.Instrument(self.port, GREENMETER_ADDRESS)
mbdev = minimalmodbus.Instrument(self.port, utils.GREENMETER_ADDRESS)
mbdev.serial.parity = minimalmodbus.serial.PARITY_EVEN

self.max_battery_discharge_current = abs(
@@ -120,7 +122,7 @@ def read_status_data(self):

def read_soc_data(self):
try:
mbdev = minimalmodbus.Instrument(self.port, GREENMETER_ADDRESS)
mbdev = minimalmodbus.Instrument(self.port, utils.GREENMETER_ADDRESS)
mbdev.serial.parity = minimalmodbus.serial.PARITY_EVEN

self.voltage = (
24 changes: 16 additions & 8 deletions etc/dbus-serialbattery/lifepower.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from battery import Protection, Battery, Cell
from utils import *
from struct import *
from battery import Battery, Cell
from utils import read_serial_data, logger
import utils
from struct import unpack_from
import re


@@ -24,14 +25,21 @@ def test_connection(self):
# call a function that will connect to the battery, send a command and retrieve the result.
# The result or call should be unique to this BMS. Battery name or version, etc.
# Return True if success, False for failure
return self.read_status_data()
result = False
try:
result = self.read_status_data()
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_current = MAX_BATTERY_CURRENT
self.max_battery_discharge_current = MAX_BATTERY_DISCHARGE_CURRENT
self.max_battery_current = utils.MAX_BATTERY_CURRENT
self.max_battery_discharge_current = utils.MAX_BATTERY_DISCHARGE_CURRENT
hardware_version = self.read_serial_data_eg4(self.command_hardware_version)
if hardware_version:
# I get some characters that I'm not able to figure out the encoding, probably chinese so I discard it
@@ -89,8 +97,8 @@ def read_status_data(self):

# Cells
self.cell_count = len(groups[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

self.cells = [Cell(True) for _ in range(0, self.cell_count)]
for i, cell in enumerate(self.cells):
43 changes: 27 additions & 16 deletions etc/dbus-serialbattery/lltjbd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- 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
import struct


class LltJbdProtection(Protection):
@@ -59,18 +61,22 @@ def __init__(self, port, baud, address):
LENGTH_POS = 3

def test_connection(self):
# call a function that will connect to the battery, send a command and retrieve the result.
# The result or call should be unique to this BMS. Battery name or version, etc.
# Return True if success, False for failure
result = False
try:
result = self.read_hardware_data()
except:
pass
except Exception as err:
logger.error(f"Unexpected {err=}, {type(err)=}")
result = False

return result

def get_settings(self):
self.read_gen_data()
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
return True

def refresh_data(self):
@@ -79,7 +85,7 @@ def refresh_data(self):
return result

def to_protection_bits(self, byte_data):
tmp = bin(byte_data)[2:].rjust(13, zero_char)
tmp = bin(byte_data)[2:].rjust(13, utils.zero_char)

self.protection.voltage_high = 2 if is_bit_set(tmp[10]) else 0
self.protection.voltage_low = 2 if is_bit_set(tmp[9]) else 0
@@ -92,7 +98,11 @@ def to_protection_bits(self, byte_data):

# Software implementations for low soc
self.protection.soc_low = (
2 if self.soc < SOC_LOW_ALARM else 1 if self.soc < SOC_LOW_WARNING else 0
2
if self.soc < utils.SOC_LOW_ALARM
else 1
if self.soc < utils.SOC_LOW_WARNING
else 0
)

# extra protection flags for LltJbd
@@ -107,17 +117,17 @@ def to_cell_bits(self, byte_data, byte_data_high):
for c in self.cells:
self.cells.remove(c)
# get up to the first 16 cells
tmp = bin(byte_data)[2:].rjust(min(self.cell_count, 16), zero_char)
tmp = bin(byte_data)[2:].rjust(min(self.cell_count, 16), utils.zero_char)
for bit in reversed(tmp):
self.cells.append(Cell(is_bit_set(bit)))
# get any cells above 16
if self.cell_count > 16:
tmp = bin(byte_data_high)[2:].rjust(self.cell_count - 16, zero_char)
tmp = bin(byte_data_high)[2:].rjust(self.cell_count - 16, utils.zero_char)
for bit in reversed(tmp):
self.cells.append(Cell(is_bit_set(bit)))

def to_fet_bits(self, byte_data):
tmp = bin(byte_data)[2:].rjust(2, zero_char)
tmp = bin(byte_data)[2:].rjust(2, utils.zero_char)
self.charge_fet = is_bit_set(tmp[1])
self.discharge_fet = is_bit_set(tmp[0])

@@ -138,28 +148,29 @@ def read_gen_data(self):
balance2,
protection,
version,
self.soc,
soc,
fet,
self.cell_count,
self.temp_sensors,
) = unpack_from(">HhHHHHhHHBBBBB", gen_data)
self.voltage = voltage / 100
self.current = current / 100
self.soc = 100 * capacity_remain / capacity
self.capacity_remain = capacity_remain / 100
self.capacity = capacity / 100
self.to_cell_bits(balance, balance2)
self.version = float(str(version >> 4 & 0x0F) + "." + str(version & 0x0F))
self.to_fet_bits(fet)
self.to_protection_bits(protection)
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

for t in range(self.temp_sensors):
temp1 = unpack_from(">H", gen_data, 23 + (2 * t))[0]
if t == 0:
self.to_temp("mos", kelvin_to_celsius(temp1 / 10))
self.to_temp("mos", utils.kelvin_to_celsius(temp1 / 10))
else:
self.to_temp(t, kelvin_to_celsius(temp1 / 10))
self.to_temp(t, utils.kelvin_to_celsius(temp1 / 10))

return True

4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/mnb.py
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
from battery import Protection, Battery, Cell
from struct import *

# from test_max17853 import *#{these two lines are mutually}
from util_max17853 import * # {exclusive. use test for testing}
# from test_max17853 import * #{these two lines are mutually}
# from util_max17853 import * # {exclusive. use test for testing}


class MNBProtection(Protection):
24 changes: 13 additions & 11 deletions etc/dbus-serialbattery/renogy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from battery import Protection, Battery, Cell
from utils import *
from battery import Battery, Cell
from utils import read_serial_data, unpack, unpack_from, logger
import utils
import struct


@@ -16,7 +17,8 @@ def __init__(self, port, baud, address):
LENGTH_CHECK = 4
LENGTH_POS = 2

# command bytes [Address field][Function code (03 = Read register)][Register Address (2 bytes)][Data Length (2 bytes)][CRC (2 bytes little endian)]
# command bytes [Address field][Function code (03 = Read register)]
# [Register Address (2 bytes)][Data Length (2 bytes)][CRC (2 bytes little endian)]
command_read = b"\x03"
# Core data = voltage, temp, current, soc
command_cell_count = b"\x13\x88\x00\x01" # Register 5000
@@ -44,21 +46,21 @@ def test_connection(self):
result = False
try:
result = self.read_gen_data()
except:
logger.exception("Unexpected exception encountered")
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.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
return True

def refresh_data(self):
@@ -203,7 +205,7 @@ def read_serial_data_renogy(self, command):
return False

start, flag, length = unpack_from("BBB", data)
checksum = unpack_from(">H", data, length + 3)
# checksum = unpack_from(">H", data, length + 3)

if flag == 3:
return data[3 : length + 3]
24 changes: 15 additions & 9 deletions etc/dbus-serialbattery/sinowealth.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, Cell
from utils import kelvin_to_celsius, read_serial_data, logger
import utils
from struct import unpack_from


class Sinowealth(Battery):
@@ -33,25 +34,30 @@ def __init__(self, port, baud, address):
LENGTH_POS = 0

def test_connection(self):
# call a function that will connect to the battery, send a command and retrieve the result.
# The result or call should be unique to this BMS. Battery name or version, etc.
# Return True if success, False for failure
result = False
try:
result = self.read_status_data()
result = result and self.read_remaining_capacity()
result = result and self.read_pack_config_data()
except:
pass
except Exception as err:
logger.error(f"Unexpected {err=}, {type(err)=}")
result = False

return result

def get_settings(self):
# hardcoded parameters, to be requested from the BMS in the future
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

if self.cell_count is None:
self.read_pack_config_data()

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

self.hardware_version = "Daly/Sinowealth BMS " + str(self.cell_count) + " cells"
logger.info(self.hardware_version)