Skip to main content

Pylon Battery statistics to MQTT exporter

Project description

pylon2mqtt

pylon2mqtt can periodically poll data from a Pylon Battery debug interface and publish to MQTT. It should run on Linux and Windows but since most people will likely run this on something like a Raspberry Pi, only instructions for Linux are shown here.

Required Hardware

You will need some sort of serial connection to the Pylontech battery. You can either build your own or buy a premade cable that embeds a USB->RS232 chip on one side and the custom RJ45 pinout on the other.

Installing

Get it from PyPI (you might want to do this in a virtualenv):

$ pip install pylon2mqtt

You should then have the pylon2mqtt CLI on your path.

Setting Up

First, it's probably a good idea to test if it works at all. Assuming your serial adapter is /dev/ttyUSB0, run:

$ pylon2mqtt test -s /dev/ttyUSB0

which should spit out values for all connected batteries. After confirming the basics work, you can give exporting to MQTT a try:

$ pylon2mqtt run -s /dev/ttyUSB0 -h mymqtthost.example.org

once you have it working with the desired flags, you can generate a systemd unit. Just replace run with generate-systemd and you'll get a systemd unit file that should use the right virtualenv/interpreter and set the flags you specified:

$ pylon2mqtt generate-systemd -s /dev/ttyUSB0 -h mymqtthost.example.org

Dealing with multiple serial adapters

If you have multiple USB->serial adapters plugged in, it might be a good idea to get a stable device symlink for it to avoid confusion. Use the following command to generate a udev rule to create a symlink:

$ pylon2mqtt generate-udev-rule -s /dev/ttyUSB0 

put the output into a rules file in /etc/udev/rules.d/ and then use the symlink instead of ttyUSB0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylon2mqtt-0.2.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylon2mqtt-0.2.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file pylon2mqtt-0.2.0.tar.gz.

File metadata

  • Download URL: pylon2mqtt-0.2.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for pylon2mqtt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b9c0b10fbf09163e903fd9be93335cf6c8128d73c5774c9bf012ae9cc334be62
MD5 ed9380df325b5e5ed54d98b678388ac8
BLAKE2b-256 b0547b2d6ac8b7d3ac487aa56e1d6b8e28eb3ac3203662d78d739ec3354dbd0b

See more details on using hashes here.

File details

Details for the file pylon2mqtt-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pylon2mqtt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baa90d6db629d46c6a7d52d744b847e1c0b234766226ff0b9509a3f04b086045
MD5 740ae3d19db738a8d939452a61b9e8e2
BLAKE2b-256 25b1590e889f58639001d07852f80fe8d1cafc71e22643f0dd82f42b659ee2c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page