Execute script when changing topic"s value

Hi. Start doing my baby steps with node red and i am looking on how to achieve a task. My setup has a raspberry that runs mqtt broker and node-red. On mqtt there are some topics and each topic has values either 0 or 1 and some other topics have open or closed values. I would like topic home/alarm/door when value is 0 to execute the script /home/pi/scripts/doors_zero.sh and when 1 the doots_one.sh on the same folder

While on topic office/door when value is closed the execute /home/pi/scripts/office_closed.sh and when value is open execute the office_open.sh

I would any help available since i am newbie with node -red , please

so look at the MQTT input node to subscribe to your topic. You can then use a switch node to direct a flow based on the value you get from your MQTT topic.

Take a look at the exec node to be able to execute script.

Add debug nodes along the flow so you can see and hopefully understand what is happening

The more node-red way would be to replace your scripts with node-red replacements of course. Get it working with the scripts first though since you (presumably) know that they work.

I know people dont want to hear this (re-do your scripts in node-red) however @Colin is on the money here. You will not only learn (node-red) but will get a more stable solution launching scripts is unnecessary overhead and flakey at best IMO)

I am not sure I would go that far. There is no reason why a script should be flaky any more than a node-red implementation.

I'm referring more to the reliability of getting responses back. The problems people have reading stdout etc.

It can be fiddly getting it to work I agree, but once going it should be fine. I assumed by flaky that you meant unreliable.