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

#34421

Dan in CA
Participant

The functions in the notify_change.py plugin are really just stubs. They print a message to the console in order to demonstrate that they work. They can/should be extended to send messages to an MQTT broker, do data manipulation etc. The python-mosquitto client modules seem like they could work here.

The blinker signals can also include a data payload. When a user performs an action such as selecting an option, the UI sends a GET request with a query string containing the selected option to a URL which triggers some processing. The blinker signal from such an event could include a Python dictionary object containing the elements of the query string, providing more specific data about the change. I ‘m just learning abut MQTT but it seems like sending the entire contents of the gv.sd dictionary with each change is a bit of overkill. It would require further processing to figure out what the change actually was was.

This new signalling feature will certainly make writing plugins a lot easier and eliminate most of the looping/polling that is now necessary to get data about the state of the system. It has the potential to enhance performance by eliminating HTTP REST calls:

https://mobilebit.wordpress.com/2013/05/03/rest-is-for-sleeping-mqtt-is-for-mobile/

Ian,

The idea of using MQTT for the sensor network crossed my mind but there are some reasons I want to at least try modprobe. There is a separate thread on that so I won’t go into it here.

https://opensprinkler.com/forums/topic/who-accept-a-challenge-to-write-plugin-with-soil-moisture/

Dan