Page 1 of 1

Node Red MQTT set not working...ish

Posted: 12 Sep 2020, 23:56
by cataliz3er
Hey there!
Managed to setup Node Red and I'm getting the input events, but when I try to set an output via MQTT it turns on briefly then back off.
I've uploaded a video of the behavior here:
https://www.youtube.com/watch?v=bfN-GiTGU00

The Red Lamp (O_2) is connected directly to the input in the main loop of the program.
Screenshot 2020-09-13 005101.png
Screenshot 2020-09-13 005101.png (38.46 KiB) Viewed 2715 times
The Green one (O_3) is supposed to be toggled by MQTT. It is marked as exported in PiCtory.
Screenshot 2020-09-13 004957.png
Screenshot 2020-09-13 004957.png (56.74 KiB) Viewed 2715 times
What am I doing wrong?

Thanks in advance!

Re: Node Red MQTT set not working...ish

Posted: 13 Sep 2020, 08:36
by RevPiModIO
Hi cataliz3er!

If you are using RevPiModIO in your python program, it takes the complete control of the process image! So it forces the io states to the process image, which are set in the program! If you use MQTT or other programs parallel to the python program to set outputs, your python program will override the outputs, which are set from outside of it.

In your example: The MQTT System set output O_3 and the python program will switch it back to the value which is defined in the Python program (false).

If you want to change that, just add “shared_procimg=True” to your RevPiModIO(...) object in your Python program. Then it will sync the outputs and your system will work!

Sven