High,
I have a switch button which controls a pump by sending an ON String or an OFF string. That works fine if I switch the button from ON to OFF by means of the Node-red panel.
Now I want to control this switch button by means of a Node-Red input message ON or OFF, and the switch should show its new state - either ON or OFF - on my Node-Red display.
What I have to do to obtain this behaviour?
Thanks,
Alf Italy
You can send a msg.payload in to the Switch node to force it to a particular state.
The type of msg.payload needs to match the On/Off Payload type.

Switch settings - note the type is Boolean

This is what is in the Inject node - note the type is Boolean

There is useful 'Help' information in the right-hand window pane.

High,
thanks for your prompt answer.
Since my payload messages are strings "PN" for pump on and "PF" for pump off. my MQTT input node should send "PN" and "PF"?
thanks, Alfitaly
high dynamicdave,
thanks again, I did as you described and it works, Thank you!!
Alfitaly