chinezbrun / pytes_serial

Read RS232 serial port of PYTES and PYLONTECH LiFePo4 batteries, send data to MQTT, JSON and MariaDB ,There is a build in integration with Home Assistant.
GNU Affero General Public License v3.0
17 stars 3 forks source link
assistant home-assistant homeassistant integration mqtt pylontech pytes pytes-home-assistant pytes-homeassistant

PYTES E-BOX 48100R / PYLONTECH to Home Assistant / MariaDB

Program is reading RS232 serial port of PYTES and PYLONTECH LiFePo4 batteries.

How does this software work?

"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:

You have more examples for better understanding of what program does.

Installation and Execution

Serial cable must be connected to battery 1 (master).

  1. copy current repository

  2. optional: a. if you want to use MariaDB:

    • MariaDB database must be installed (MariaDB documentaion is out of this project scope)
    • use sql/pytes_mariadb.sql to import required database and tables

    b. if you want to use MQTT / MQTT integration in Home Assistant:

    • MQTT broker must be installed (MQTT documentation is out of this project scope)
    • if you use Home Assistant, make sure that MQTT auto discovery is set true and sensors will be auto discovered when program will start
  3. 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)

  4. make sure that all required pyton modules are installed see requirements

  5. go to the folder where the program is located (i.e cd /home/pi/Documents/pytes)

  6. 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

Thanks to valimircea-popescu for conducting the testing on Pylontech batteries.