Multiple Flows "Execute" After I Deploy

Hey all, I'm a new Node-Red user and have had some guidance from a friend to get me going. I'm running the latest v8 version of Node-Red, Mosquitto Eclipse MQTT, and Homeseer (for my Z-wave devices). I've searched the web and this forum and I can't seem to find (or perhaps understand) the help I'm looking for.

My issue is that after I make certain changes to an event driven flow and click Deploy, my debug shows that certain lights are immediately turned off, and a couple turned on, and they're from multiple flows. And sure enough, I check the rooms affected and their lights have been turned on/off. I'm not sure what exactly triggers the Deploy to execute the things in the flows because they're all event driven and it doesn't happen every time I make an update. I created a simple flow with a Trigger --> Change --> MQTT Publish to unlock my back door. If I delete a wire and add it back going from the Change to the MQTT Publish and then hit Deploy, it will execute as I mentioned above.

I have about 4 or so flows created to manage lighting upstairs, downstiars, and a flow to turn on my theater room and all equipment. Individually, the flows work great as in when an event is triggered, the flows do what they're designed to do. I don't know if I'm not understanding what Deploy does precisely or if my flows are designed incorrectly but any light that can be shed would be greatly appreciated.

Here's an example of a flow to control the upstairs lights. I have a virtual device (Upstairs Lights) that changes the state (on/off) of my physical switches in the bedrooms/hallway when triggered.

image

Node-RED is on version 0.19.5 see https://nodered.org
Mosquito is on v1.5.4 or v.1.5.5

How have you configured your MQTT-IN node?
What is the QoS set as? (read the Info panel on the Right Hand Side)

Thanks for the reply, ukmoose. I'm running Node Red 0.19.5 (V8) and Mosquitto 1.5.5. The QoS of most of my MQTT-in's are 2 but I noticed a couple of them are 0. I'm seeing that QoS 0 delivers at most once, 1 delivers at least once, and 2 delivers only once. I don't recall setting them to QoS 2, but my understanding of QoS is very limited. When dealing with home use and light switches, which QoS is best? Thanks!

There’s a great intro to MQTT here https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt/ which is well worth a read

Thanks for the link. I'll certainly read the MQTT essentials. In the meantime, any other suggestions or pointers as to what might be causing this issue are appreciated.

Nothing will happen unless something triggers a message. Look at the debug node on the MQTT In node and see what appears there when you deploy. It should send messages for any retained topics.

Hey Colin, I just edited the flows so that only the MQTT in for each flow was active and had a debug (deleted the wire going to the rest of the flow) and pared down 30 debug results to one debug result per flow (3) when I click Deploy. Debug is showing that a 0 (off) is being sent to each flow. I’m not sure where the 0 is coming from. I have no triggers, just the events. I didn’t mention that I also have Home Assistant in the mix and the node installed in NR but none of the flows are using it. Not sure that’s important. Thx for the suggestion. I now see that that 0 is what’s triggering the flows. Just not sure how it’s getting sent in.

The most likely reason is that the topic for each of those was last written to with value 0 with the Retain flag set. The retain flag tells mosquitto to remember the latest value for the topic and when a client connects (as happens after a deploy) send the client that value. If that is the cause then probably the best solution is to make sure that the current value is written to the topic each time it changes. Then when you deploy it will restore the lights to their previous setting. Watch out for an MQTT loop though, if you have the same topic for an MQTT In going to an MQTT Out, which then comes back in via the MQTT out etc. An RBE node can often be helpful in avoiding that.
[Edit] If you use mosquitto_sub on the command line to subscribe with that topic you will see whether you get a retained value immediately.

I decided to backup my flows and then kill them all. I only added an MQTT in and a debug and it still received 0. At my wit's end, I decided to turn everything off and then on again (so I thought): Node Red, Home Assistant, and HomeSeer. I still got a 0 in NR. Then (duh), it occurred to me to stop and start the MQTT docker. After I did that, I am no longer receive a 0. It's too early to tell if it's resolved, but I'm no longer able to duplicate the issue whereas it was quite easy to reproduce pre-reboots. I'll post back in a few days whether it has indeed stopped. Thanks to Colin and ukmoose for the help and direction!

It is possible that you had at some point written the value 0 with the retain flag set, but in the broker you had not enabled persistent memory. So all the time the broker was running it remembered it, but once you restarted it forgot again.