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

Update jkbms_ble from master #527

Merged
merged 2 commits into from
Apr 13, 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: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
max-line-length = 120
exclude =
./etc/dbus-serialbattery/ant.py,
./etc/dbus-serialbattery/battery.py,
./etc/dbus-serialbattery/battery_template.py,
./etc/dbus-serialbattery/daly.py,
./etc/dbus-serialbattery/dbus-serialbattery.py,
Expand All @@ -17,7 +16,8 @@ exclude =
./etc/dbus-serialbattery/sinowealth.py,
./etc/dbus-serialbattery/test_max17853.py,
./etc/dbus-serialbattery/util_max17853.py,
./velib_python
venv
extend-ignore:
# E203 whitespace fefore ':' conflicts with black code formatting. Will be ignored in flake8
# E203 whitespace before ':' conflicts with black code formatting. Will be ignored in flake8
E203
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto eol=lf
*.{sh,[sS][hH]} text eol=lf
*.{pyb} text eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
32 changes: 13 additions & 19 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,28 @@ on:
- '**'

jobs:
CodeQL:
analyse:
name: Analyze Using GitHub CodeQL
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.8.13"
- name: Clone velib_python and add it to PYTHONPATH for subsequent steps
run: |
git clone https://github.com/victronenergy/velib_python.git
echo PYTHONPATH=$PYTHONPATH:$(pwd)/velib_python >> $GITHUB_ENV
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
lint:
name: Check Code Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Execute black lint check
uses: psf/black@stable

- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: flake8 Lint
uses: py-actions/flake8@v2
- name: Execute black lint check
uses: psf/black@stable
- name: flake8 Lint
uses: py-actions/flake8@v2
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: build release archive
run: |
find . -type f -name "*.py" -exec chmod +x {} \;
find . -type f -name "*.sh" -exec chmod +x {} \;
find . -type f -name "run" -exec chmod +x {} \;
tar -czvf venus-data.tar.gz \
--mode='a+rwX' \
--exclude battery_template.py \
--exclude __pycache__ \
--exclude restartservice.sh \
--exclude revov.py \
--exclude test_max17853.py \
conf/serial-starter.d \
etc/dbus-serialbattery/
- name: Release
uses: softprops/action-gh-release@v1
with:
files: venus-data.tar.gz
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,7 @@ BMS-trials
.project
.pydevproject
*.prefs
etc/dbus-serialbattery/config.ini

# Local Clone of velib_python
velib_python
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ The driver will communicate with a Battery Management System (BMS) that support
If you find this driver helpful please considder supporting this project. You can buy me a Ko-Fi or get in contact if you would like to donate hardware.

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z73LCW1) or using [Paypal.me](https://paypal.me/innernet)

### Developer Remarks
To develop this project, install the requirements. This project makes use of velib_python which is pre-installed on
Venus-OS Devices under `/opt/victronenergy/dbus-systemcalc-py/ext/velib_python`. To use the python files locally,
`git clone` the [velib_python](https://github.com/victronenergy/velib_python) project to velib_python and add
velib_python to the `PYTHONPATH` environment variable.

#### How it works
* Each supported BMS needs to implement the abstract base class `Battery` from `battery.py`.
* `dbus-serialbattery.py` tries to figure out the correct connected BMS by looping through all known implementations of
`Battery` and executing its `test_connection()`. If this returns true, `dbus-serialbattery.py` sticks with this battery
and then periodically executes `dbushelpert.publish_battery()`. `publish_battery()` executes `Battery.refresh_data()` which
updates the fields of Battery. It then publishes those fields to dbus using `dbushelper.publish_dbus()`
* The Victron Device will be "controlled" by the values published on `/Info/` - namely:
* `/Info/MaxChargeCurrent `
* `/Info/MaxDischargeCurrent`
* `/Info/MaxChargeVoltage`
* `/Info/BatteryLowVoltage`
* `/Info/ChargeRequest` (not implemented in dbus-serialbattery)

For more details on the victron dbus interface see [the official victron dbus documentation](https://github.com/victronenergy/venus/wiki/dbus)
32 changes: 0 additions & 32 deletions buildfiles.lst

This file was deleted.

4 changes: 0 additions & 4 deletions create_build.sh

This file was deleted.

4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


class Ant(Battery):
def __init__(self, port, baud):
super(Ant, self).__init__(port, baud)
def __init__(self, port, baud, address):
super(Ant, self).__init__(port, baud, address)
self.type = self.BATTERYTYPE

command_general = b"\xDB\xDB\x00\x00\x00\x00"
Expand Down
Loading