Switch with indicator

Hi Guys,

I use the PLC for my house. Between my PLC and Node Red I use Modbus communication. I would like to use special switch with indicator. I want to use PLC digital output as feedback at the switch. I would use the same switch to control the PLC output. When the PLC output changes, that changes the indicator of the switch. My problem is if the PLC output is controlled outside of Node Red. The status of the switch does not change.
Sorry for my English :wink:

Thanks, for the help!

Adam

I presume this is a node red dashboard switch you are talking about.
If so then to solve the problem you need to pickup the current PLC output state in node-red and feed it into the front of the switch, so the switch will change if the output changes.

Thanks for the reply. I've tried this solution before. It used at one PLC output. When I copied it, the others didn't work properly.

Well that is the only way to do it, you cannot make the switch follow the PLC output unless you know what the output is. The solution is to try again and find out what the problem was the first time.

Try again with a smaller simpler flow and if it doesn't work, share the flow so people have something to investigate for you

So this my simple flow:

[{"id":"e4e6562f.f1a698","type":"modbus-write","z":"350f034d.94afcc","name":"Mosok_vil_write","showStatusActivities":true,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"15002","quantity":"1","server":"4d5e1b27.37ea5c","x":1020,"y":80,"wires":[,]},{"id":"ec77ff58.f3d2","type":"ui_switch","z":"350f034d.94afcc","name":"","label":"Mosokonyha ","tooltip":"","group":"b7362e82.2a474","order":13,"width":"0","height":"0","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-power-off","oncolor":"green","offvalue":"false","offvalueType":"bool","officon":"fa-power-off","offcolor":"red","x":700,"y":80,"wires":[["e4e6562f.f1a698"]]},{"id":"7dece348.20398c","type":"modbus-read","z":"350f034d.94afcc","name":"Mosok_vilagitas","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"15002","quantity":"1","rate":"1","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"4d5e1b27.37ea5c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":220,"y":80,"wires":[,["d401976f.87f3b"]]},{"id":"d401976f.87f3b","type":"function","z":"350f034d.94afcc","name":" Decode array","func":"// The message returned from the read node is an\n// array as there could be multiple registers returned\n// This reads the first value in the array.\nm = msg.payload.data[0]\nreturn {payload: m};\n","outputs":1,"noerr":0,"x":420,"y":80,"wires":[["ec77ff58.f3d2"]]},{"id":"4d5e1b27.37ea5c","type":"modbus-client","z":"350f034d.94afcc","name":"Mester","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.1.144","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectTimeout":2000},{"id":"b7362e82.2a474","type":"ui_group","z":"350f034d.94afcc","name":"Foldszint vilagítas","tab":"ff28c5b9.5fd548","disp":true,"width":"6","collapse":false},{"id":"ff28c5b9.5fd548","type":"ui_tab","z":"350f034d.94afcc","name":"Mester u. 1/b.","icon":"fa-home","order":1,"disabled":false,"hidden":false}]

Unfortunately the flow is not importable. Please see this post for how to share the flow. You can edit the previous post to insert the backticks.

However before doing that put a debug node on the output of the first and second nodes and see what is coming from them.

[{"id":"e4e6562f.f1a698","type":"modbus-write","z":"350f034d.94afcc","name":"Mosok_vil_write","showStatusActivities":true,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"15002","quantity":"1","server":"4d5e1b27.37ea5c","x":1020,"y":80,"wires":[[],[]]},{"id":"ec77ff58.f3d2","type":"ui_switch","z":"350f034d.94afcc","name":"","label":"Mosokonyha ","tooltip":"","group":"b7362e82.2a474","order":13,"width":"0","height":"0","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-power-off","oncolor":"green","offvalue":"false","offvalueType":"bool","officon":"fa-power-off","offcolor":"red","x":700,"y":80,"wires":[["e4e6562f.f1a698"]]},{"id":"7dece348.20398c","type":"modbus-read","z":"350f034d.94afcc","name":"Mosok_vilagitas","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"Coil","adr":"15002","quantity":"1","rate":"1","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"4d5e1b27.37ea5c","useIOFile":false,"ioFile":"","useIOForPayload":false,"x":220,"y":80,"wires":[[],["d401976f.87f3b"]]},{"id":"d401976f.87f3b","type":"function","z":"350f034d.94afcc","name":" Decode array","func":"//   The message returned from the read node is an\n// array as there could be multiple registers returned\n//   This reads the first value in the array.\nm = msg.payload.data[0]\nreturn {payload: m};\n","outputs":1,"noerr":0,"x":420,"y":80,"wires":[["ec77ff58.f3d2"]]},{"id":"4d5e1b27.37ea5c","type":"modbus-client","z":"350f034d.94afcc","name":"Mester","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"192.168.1.144","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectTimeout":2000},{"id":"b7362e82.2a474","type":"ui_group","z":"350f034d.94afcc","name":"Foldszint vilagítas","tab":"ff28c5b9.5fd548","disp":true,"width":"6","collapse":false},{"id":"ff28c5b9.5fd548","type":"ui_tab","z":"350f034d.94afcc","name":"Mester u. 1/b.","icon":"fa-home","order":1,"disabled":false,"hidden":false}]

Note that you have specified that the switch sends the boolean values true and false. This means that you must make sure that the value you are passing it is also a boolean value true or false, otherwise the switch will not understand the value it is being sent.
So as suggested put debug nodes on the modbus read and the function node and check that they are sending the correct values.