How to Digital twin on my dashboard?

I'm reading in status of a device over modbus. That part works. So when I put my device into ready mode(not from the dash), my dash shows ready. But now I want to use the dash to put my device into ready mode. I understand that there may be some conflict of status. How is the flow supposed to look if I want to do this?

Right now I have this:

I'm reading a status from modbus, processing it and turning on an indicator.
But now instead of an indicator, I'd like it to be a slider switch on the dash to indicate the status. At the same time, I can toggle the switch on the dash to change the status of the device.

How do I do this?

[{"id":"5b452c81.cb87b4","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"bc532f5a.76fa1","type":"modbus-read","z":"5b452c81.cb87b4","name":"device","topic":"device","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"0","dataType":"Coil","adr":"0","quantity":"8","rate":"1","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"bf81420f.323c4","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":130,"y":360,"wires":[["9b608007.5066"],[]]},{"id":"9b608007.5066","type":"function","z":"5b452c81.cb87b4","name":"","func":"var x = [0,0,0,0,0,0,0,0];\nvar msg_o = [msg,msg,msg,msg,msg,msg,msg,msg]\n\nfor(i = 0; i <8; i++){\n    x[i] = msg.payload[i];\n    if(x[i] == true){\n        msg_o[i] = {payload:true}\n    } else{\n        msg_o[i] = { payload:false};\n    }\n}\n\n\nreturn msg_o;","outputs":8,"noerr":0,"initialize":"","finalize":"","x":340,"y":360,"wires":[[],["482dbfc8.8dcf"],[],[],[],[],[],[]]},{"id":"6d1d5f9.45a46a","type":"change","z":"5b452c81.cb87b4","name":"","rules":[{"t":"set","p":"message","pt":"msg","to":"Run","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":320,"wires":[["e066460a.da2f58","536a9d0d.c88af4"]]},{"id":"ad16c194.f3522","type":"change","z":"5b452c81.cb87b4","name":"","rules":[{"t":"set","p":"message","pt":"msg","to":"Standby","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":360,"wires":[["e066460a.da2f58","536a9d0d.c88af4"]]},{"id":"482dbfc8.8dcf","type":"switch","z":"5b452c81.cb87b4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":340,"wires":[["6d1d5f9.45a46a"],["ad16c194.f3522"]]},{"id":"e066460a.da2f58","type":"ui_led","z":"5b452c81.cb87b4","group":"f9407652.65bd68","order":6,"width":0,"height":0,"label":" {{msg.message}}","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"green","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"name":"Run/Standby","x":890,"y":340,"wires":[]},{"id":"6e7d658c.ff134c","type":"comment","z":"5b452c81.cb87b4","name":"Spray Status","info":"","x":670,"y":280,"wires":[]},{"id":"c4a5ee95.b86e1","type":"comment","z":"5b452c81.cb87b4","name":"run/standby","info":"","x":1050,"y":340,"wires":[]},{"id":"61848607.ed4038","type":"comment","z":"5b452c81.cb87b4","name":"Reading Boolean from device","info":"","x":140,"y":320,"wires":[]},{"id":"1722b3b9.a388dc","type":"comment","z":"5b452c81.cb87b4","name":"Bool Addressing conforms to that of the Click PLC.","info":"","x":250,"y":500,"wires":[]},{"id":"536a9d0d.c88af4","type":"debug","z":"5b452c81.cb87b4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":260,"wires":[]},{"id":"bf81420f.323c4","type":"modbus-client","name":"1750+ 2","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"tcpHost":"10.13.1.74","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,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true},{"id":"f9407652.65bd68","type":"ui_group","name":"1750+ 2","tab":"a1387b82.164db8","order":2,"disp":false,"width":"10","collapse":false},{"id":"a1387b82.164db8","type":"ui_tab","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I don't see a dashboard switch in your flow, however the usual way is to feed the current state of the device into the front of the switch so that the switch changes when the state changes, and feed the output of the switch into the logic to drive the device. To stop an infinite loop occurring, configure the switch to not pass the message through to the output and (usually) configure it to Show State of Input.
The result is that if the state changes externally then the switch follows it, and if the switch is clicked then it sends the message to change the device, and the new state is picked up and fed into the switch so that the display changes. Then you know that the device has actually changed when you click the switch.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.