MQTT Infinite Loop - Suggestions

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
hrshukla
Posts: 4
Joined: Thursday 19 May 2016 22:07
Target OS: -
Domoticz version:
Contact:

MQTT Infinite Loop - Suggestions

Post by hrshukla »

Hi,

Sorry for the long post, but needed to explain my setup in a bit of detail.

This is the setup I have been playing with for the last few days: I have a Beagleboard Black connected to an Arduino with a RF433 transceiver (a Kickstarter device back in the day called Ninjablocks) - that can receive data from 433MHz sensors and can also trigger actuators. Both, received data and data to be transmitted is written to and read from it's serial console (/dev/ttyO1). I have a Node-Red flow that reads data from the serial console, and sends it to MQTT in the required Domoticz format ; Domoticz reads it from here and updates the appropriate virtual devices (via 'domoticz/in'). In the other direction, anything on 'domoticz/out' gets read by the Node-red flow, and similarly gets written to the Ninjablock's serial console (if an RF433 actuator, discarded if not), and Ninjablocks does the needful.

Everything works as expected.. well almost.. For sensors, there are no issues. When it comes to actuators, it goes into a never ending loop. Example, say I press a virtual device 'Doorbell' in Domoticz. This triggers the domoticz/out, ends up in the Ninja's serial console as described above, the RF433 on the Ninja transmits the code and actuates the doorbell. The transmission itself however gets recorded as another signal, gets passed back to domoticz/in, then to domoticz/out, and ends up in the ninjablocks again. This goes on forever, and the doorbell keeps ringing!

I can see the problem here, but have run out of ideas to solve it. One thing I have tried is pass an 'svalue='ninja', so I can recognise it in the Node-red flow and filter it out just like I filter out sensors. However, looks like Domoticz drops this svalue and replaces it with a 'svalue = 0' when sending it through 'domoticz/out'.

Anyone else have any other ideas I could try - in Domoticz or in Node-Red ??

Many thanks,

Himanshu
mirage
Posts: 3
Joined: Monday 24 November 2014 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: MQTT Infinite Loop - Suggestions

Post by mirage »

Hi,
There's quite a lot of threads regarding this issue elsewhere in the forum. You may already have a solution to your infinite loop problem. I'm also struggling with this as also use mqtt and domoticz. The best solution is to poll for the status of a switch before activating it in domoticz. You could do this in node red before sending into domoticz/in. I am toying with this solution:
I create a dummy text sensor in domoticz.
Then in node red instead of activating a switch directly in domoticz/in I send a message to the text switch containing the switch id and state. Then in lua I write the code to extract the switch and state and to only activate if it had changed.

This both breaks the loop and also makes the node red side simple as you only need a single flow for all switches because the rest of the work is done in lua.
I haven't tested this approach yet!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest