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

#34345

Ian
Participant

Thanks Dan.

I’m glad it worked for you.

I use Winscp and Putty, but it never occurred to use it to copy the JSON file!

I noticed that the Node-red application doesn’t work too well if you start the sprinklers first, then Deploy the application!  However as I said, I will treat this as a demonstration, and learning exercise. Although it would be possible to finish it off so it handles all these unusual cases and errors, I think polling OSPi every second for this data is likely to cause problems.

I assume a plugin that gets imported into the main application runs in a manner similar to a separate “thread” but with access to the variables of the main program (provided I access them as shown in the documentation!). So I can write a plugin that monitors the variables I am interested in, and publish them to MQTT when they change, and not worry too much what the main program is doing.

I will of course also need to get some configuration data from a web page. (MQTT broker address for example, and an MQTT enable flag for each topic..

At this stage my thinking is to mirror the API calls. eg I will publish to topic OSPI/jc all the variables that the http://host/jc?pw=password call would retrieve. This will make it easier in Node-red to initialise variables (although the retain feature of MQTT may make this unnecessary!).  At the early stage I will concentrate on the jo, jn, and js calls because they are the ones I need to log the data to Emoncms.

Regards

Ian-in-WA   (Western Australia – hence the times of posts!)