Comments (3)
Glad you got it working. Back in the day I ran my scripts as system services using systemd. It also would restart the script if ever failed.
from bmspace.
To address the second part of this issue I am running bms.py in screen, in a while-true loop. This restarts the script whenever the mqtt server disappears, which makes the script crash.
~/bmspace $ while true; do python bms.py; sleep 10; done;
I believe the correct way to start and restart the script would be via systemd, but otherwise a docker container (docker compose script) with the restart unless stopped flag should work too.
from bmspace.
I changed my script to run in Docker.
Installed Docker on RaspberryPi
https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
https://docs.docker.com/engine/install/linux-postinstall/
sudo usermod -aG docker ${USER}
log out, log in
docker run hello-world
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
https://docs.docker.com/config/containers/logging/json-file/
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
sudo reboot
Build image and run container
docker compose build
docker compose up -d
Dockerfile
FROM python:3.9-alpine
ENV WORK_DIR=workdir \
HASSIO_DATA_PATH=/data
RUN mkdir -p ${WORK_DIR}
WORKDIR /${WORK_DIR}
COPY requirements.txt .
# install python libraries
RUN pip3 install -r requirements.txt
# Copy code
COPY bms.py constants.py run.sh ./
RUN chmod a+x run.sh
CMD [ "sh", "./run.sh" ]
docker-compose.yaml
version: '3'
services:
bmspace:
build:
context: .
restart: unless-stopped
privileged: true
volumes:
- ./config.yaml:/workdir/config.yaml
- /dev:/dev
from bmspace.
Related Issues (20)
- Reading 2nd pack does not work HOT 4
- Enersol Pace based Battery not reading correctly on 2 pack HOT 8
- Allith 10kW LifePo4 runs too HOT 1
- No config file found (docker container) HOT 5
- Error parsing BMS analog data: Cannot read multiple packs HOT 2
- division by zero in BMS analog data HOT 9
- Every few days script stops with errors HOT 6
- Numberin of packs and cell with 2 digits would help sorting HOT 5
- Gobel P200 Pace BMS via Gobel Rs232-USB Adapter on Victron Cerbo? HOT 1
- Working with Joyvoit BW5KW HOT 1
- Sporadic wrong byte_index when reading multiple packs HOT 4
- Hardware Info and more documentation HOT 9
- USB to Serial connection error HOT 2
- A bit description on the returned values HOT 2
- Not reading multiple packs , only the first one HOT 6
- paho.mqtt HOT 4
- The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1 HOT 3
- Hubble AM5 HOT 2
- Confirm Sunsynk 10.65kWh HOT 2
- Error When Read Multiple Pack HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bmspace.