OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Using MQTT to log data Reply To: Using MQTT to log data

#34709

Ian
Participant

The MQTT plugin is ready for wider testing. You will need the Blinker Test version (see https://opensprinkler.com/forums/topic/using-mqtt-to-log-data/page/2/#post-34412) for instructions – at this stage I am not up to date enough with Git to upload it to the repository, so you will have to use the attached files.

To use it, you need the files mqtt.py and notify_change.py installed in your /home/pi/OSPi/plugins directory, and the mqtt.html file in your /home/pi/OSPi/templates directory. The mqtscfile.dat, mqtlgfile.dat and mqtzcfile.dat are optional and if used should be placed in your /home/pi/OSPi/data directory. The attached notify_change.py file replaces the one provided in the Blinker test branch. The mqtt.py module is new. If you don’t want to install the .dat files, just change the message specification for the zone change, station name change and logged in events so they don’t use the “file” option.

The mqtt.py and notify_change.py files need to be made executable to enable the plugin. These files are attached, but due to forum restrictions I have had to name them mqtt.py.txt and notify_change.py.txt. You will need to rename them before using them.

When using it for the first time use the plugins menu item to go to the MQTT configuration screen. Enter the host address and port of your MQTT broker here as a minimum. The attached word document should be self explanatory, and replaces the version I provided earlier.

I am working on a Node Red application that will process these MQTT messages. In the interim period until it is finished, there are some options for testing described in the documentation. The simplest is to use Node Red to subscribe to the topics you define and send the message to email.

NB: Apparently I can only attach 4 files, I will attach the optional .dat files in a separate post.