Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Design thoughts about plugins
#1
Question 
As you might know I want to make the mqtt plugin more reliable on whether or not the mqtt broker is available. The problem (if one may speak of a problem Smile  ) is that when the broker is not available the plugin never ever attempt to connect to it on a later moment.

I would like to change this and make it more robust. There are however different approaches possible to do this. The job as such is easy, just try to connect once every x seconds until the broker is reachable.  My design thoughts are on which this should be done in a separate thread or, and this is unfortunately to my knowledge not (yet) possible, via a kind of trigger/heartbeat call from the framework to the plugin so that inside the plugin this could be handled.

Question; Is there a way to periodically get a trigger/heartbeat from the SIP framework (e.g. from the timer_loop) to wake-up the plugin to do "some work"?  With "some work" I not only mean to start the mqtt connection but also other things like reading lots of sensors om which the plugin can decide to alter the irrigation schema.

Please let me know if there are any thought on this.

Thanks,
--Gerard
Reply
#2
There is a system in place for SIP to communicate with plugins. It is done with the Blinker module which is included with SIP:
https://pythonhosted.org/blinker/

The current blinker signals are listed (with usage examples) in signaling_examples.py in the plugins directory. It would be trivial to add a "heartbeat" signal from the timing loop.

Another option might be to install an MQTT broker on the Pi:
https://xperimentia.com/2015/08/20/insta...ebsockets/

Dan
Reply
#3
Thanks Dan,

At the moment I have installed a broker on the Pi. But since it is broker number four in the house I want to reduce the number of brokers to only one well maintained and one for development and testing.

The blinker functionality I totally overlooked. I saw the word blinker and with the many hours a week I spend on Arduino I thought it was a blinking LED. Silly me. But it is definitely something I can and will use.

If someone is interested in the progress I can post updates.

--Gerard
Reply
#4
Yes. Please keep us up updated on your progress.

I have been using Arduinos to build sensor nodes for SIP. My favorite is the Micro which has 2 hardware serial ports.
Weather proof electrical junction boxes make really good inexpensive enclosures.

   


There are inexpensive rs-485 serial adapters that plug into a USB port on the Pi:
https://www.amazon.com/RS485-Converter-A...SB+adapter

It allows to connect many remote sensor nodes without even using any GPIO pins in the Pi.

Dan
Reply
#5
Nice!
Indeed the micro is great although uploading a new sketch can be easily made impossible and I had to rescue several times the 32U4 via SPI. So I keep a spare Nano as an SPI programmer :-)

So far I've implemented the heartbeat functionality and have the mqtt plugin working independent of the broker being online or offline during the start of, and while running SIP.
However the changes also have some effect on the MQTT zone broadcaster and MQTT Scheduler plugins. This was of course expected and they need some attention.

To be continued....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)