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.3.0.tar.gz (17.7 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.3.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pylon2mqtt-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b4d2c0f48ef993bf4eb18040c70af0451d97a4b83aca037a943b6f54261ba84c
MD5 cc2ce44ffc9e9edca5969b0064dd38e9
BLAKE2b-256 72bcddddcb1cd0153d01f8d22bb3004597b65ee863963b23d6a264e0515feded

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylon2mqtt-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for pylon2mqtt-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2ba6bbc1cba50d7442d523887802ef5ae9000a01b55caa41eb6f94df8074bc
MD5 58f79557b850a59e29c4eaf0756c2146
BLAKE2b-256 68845d05bcd13ccb7aa5729038226eeb16cfe1125fcf89ad7be5ce30d9a26ecf

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