Program is reading RS232 serial port of PYTES and PYLONTECH LiFePo4 batteries.
"pwr" and "bat" commands are used. Program reads serial port with a specific freqvency, parsing the data and saving a JSON file that can be used in further automation.
Configurable OPTIONS:
These options can be activated / dezactivated in configuration file (pytes_serial.cfg)
When MQTT transmition is activated:
program has build-in integration with Home Assisant where the following sensors will be automatic created for each battery:"current", "voltage", "temperature", "soc", "status". The battery number is embeded at the end of each sensor (i.e current_1, current_2...).
When cell monitoring is activated an additional device will be created in Home Assistant with sufix "_cells" with all associated sensors. The battery and cell number is embeded at the end of each sensor ( i.e. voltage_102 means voltage for battery 1 cell 2). Basic statistics is implemented too. Therefore, additional sensors will be available for min, max and delta for cells voltage and temperature. (i.e. pytes_cells_voltage_max_1 means max cells voltage for battery 1)
If more sensors will be needed, they can be added manually as per Home Assistant documentation MQTT sensor and the example in docs folder here.
You have more examples for better understanding of what program does.
Serial cable must be connected to battery 1 (master).
copy current repository
optional: a. if you want to use MariaDB:
b. if you want to use MQTT / MQTT integration in Home Assistant:
reaname pyteys_serial.cfg.example in pyteys_serial.cfg and configure it as per your needs (do not remark or delete lines in sections just do the configuration)
make sure that all required pyton modules are installed see requirements
go to the folder where the program is located (i.e cd /home/pi/Documents/pytes)
execute pytes_serial.sh to have a separate terminal instance (works for Linux/Raspberry) or python3 pytes_serial.py directly from console. if you need setup an autostart of the program on reboot more info here
A lighter version written in Micropython for ESP32 is available here:pytes_esp
enjoy