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



Thanks Dan. I agree this would be good to have as standard functionality. I will update my plugin to reflect this new capability.  My plugin will now simply be a configuration plugin that enables different messages to MQTT and allowing the user to specify the topics for these messages. My understanding is that would be modified to send the MQTT message  (instead of printing on the console or perhaps as well as? What do you think?).  I think that it is possible to send the whole of gv in the message body together with a time stamp. I will also develop some Node-red flows that initialise global variables corresponding to items in gv, and update them when they change.

The topics I will have as default will be something like OSPI/login, OSPI/zones-changed, OSPI/controller-changed, OSPI/options-changed, OSPI/reboot, OSPI/station-names-changed, OSPI/program-changed, OSPI/programs-deleted, OSPI/programs-toggled. Users can changed them as they wish. The Node-red flows will need to incorporate some mechanism to notify when  the global variables change, and this would then trigger any user defined flows to process the change.

Once we have tested all this  we need to provide documentation for plugin developers so they can incorporate similar functionality. eg my plugin would need to have a mechanism for notifying changes to the Topic names, and provide global variables in Node-red that correspond to these variables. Other plugins would need to do the same.

From a performance perspective, changes would be very infrequent (maybe daily, or bi-weekly) – a very significant improvement over the polling approach. I am confident that there will be some easy way to get the updated gv values from Node-red to Android and IOS apps such as the mobile OSPi app.

munnecke: your wish to have a record of changes to your system could then simply be achieved by archiving the updates to gv to file every time one of these messages arrived. You would need to develop your own application to play back/ recover these changes from the archive.

Dan – I think MQTT is getting more and more acceptance in this whole home automation world. So by placing the core OSPi variables in MQTT, it open up OSPi. Some  users may not want to use Node-red, and that is OK as they can get the data directly from the MQTT broker. If an alternative emerges in the future to MQTT it would be trivial to allow it as an option in my plugin.

I think that you would be better off using MQTT to send data from your arduino  rather than Modbus. (I have 35 years experience in the SCADA field – this is much easier!)