Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Publishing #84

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

MQTT Publishing #84

wants to merge 4 commits into from

Conversation

capi
Copy link
Contributor

@capi capi commented Sep 6, 2023

Based on the initial example script by @jburdy in #66, improved a bit on the stability of the MQTT publishing and added a possibility to have the script "loop" forever, so that it can be used as part of a systemd service or a Docker deployment without the repeated overhead of starting up the Python runtime.

Note that the script will currently still "crash" while in --loop if anything goes wrong with reading the data. So it is sensible to have the calling service or wrapper re-start it in a loop. I personally use it in a Docker file like this:

version: "3.4"
services:
  solaredge-modbus-mqtt-publisher:
    image: cr.my.domain/solaredge_modbus:latest
    restart: unless-stopped
    entrypoint: [ "/bin/bash", "-c", "while true; do ./modbus-to-mqtt.py --loop --loop_delay 3 --mqttHost 192.168.38.1 --mqttBaseTopic solaredge/ 192.168.38.90 502; sleep 3; done" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants