Hi all, first post so be nice
I've been using node red a few weeks, and have little knowledge of JSON at present. From the posts I have been reading I may be out of my depth!
Could I get your thoughts on this flow, it works fine but is it good practice? i.e. is there a more simple solution I am missing?
There is a dashboard switch, a Homekit switch on iPhone, and the physical switch on the Sonoff (Tasmota firmware). Pressing any button toggles the Sonoff output, and dresses the other switches.
[{"id":"346c0959.7434e6","type":"homekit-service","z":"fa1345d7.0957a8","isParent":true,"bridge":"9679c348.3a24a","parentService":"","name":"(Homekit) Left kitchen under cupboard","serviceName":"Switch","topic":"","filter":false,"manufacturer":"null","model":"null","serialNo":"null","characteristicProperties":"","x":270,"y":260,"wires":[["f91b44aa.3134a8","79335d6b.951a54"]],"inputLabels":["input"]},{"id":"f91b44aa.3134a8","type":"ui_switch","z":"fa1345d7.0957a8","name":"(Dashboard) Left kitchen under cupboard","label":"Left kitchen under cupboard","tooltip":"","group":"6b06c45.47e7a3c","order":2,"width":0,"height":0,"passthru":false,"topic":"","style":"","onvalue":"{\"On\":true}","onvalueType":"json","onicon":"","oncolor":"","offvalue":"{\"On\":false}","offvalueType":"json","officon":"","offcolor":"","x":300,"y":140,"wires":[["346c0959.7434e6"]]},{"id":"145f29b3.3ba656","type":"mqtt out","z":"fa1345d7.0957a8","name":"MQTT out: Sonoff cmnd/DVES_8C4BF7_fb/power","topic":"cmnd/DVES_8C4BF7_fb/power","qos":"","retain":"","broker":"5615eece.b3a81","x":930,"y":260,"wires":[]},{"id":"d8eb346b.857468","type":"debug","z":"fa1345d7.0957a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":160,"wires":[]},{"id":"79335d6b.951a54","type":"function","z":"fa1345d7.0957a8","name":"func","func":"node.status({fill:\"red\",shape:\"ring\",text:msg.payload.On});\nreturn { payload: msg.payload.On };","outputs":1,"noerr":0,"x":550,"y":260,"wires":[["145f29b3.3ba656","d8eb346b.857468"]]},{"id":"b419a87a.442098","type":"mqtt in","z":"fa1345d7.0957a8","name":"stat/DVES_8C4BF7_fb/POWER","topic":"stat/DVES_8C4BF7_fb/POWER","qos":"1","datatype":"auto","broker":"5615eece.b3a81","x":230,"y":420,"wires":[["ca6e3a08.cfa0a8"]]},{"id":"ca6e3a08.cfa0a8","type":"change","z":"fa1345d7.0957a8","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"ON","fromt":"str","to":"{\"On\":true}","tot":"json"},{"t":"change","p":"payload","pt":"msg","from":"OFF","fromt":"str","to":"{\"On\":false}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":420,"wires":[["346c0959.7434e6","ab407683.9e3fd8"]]},{"id":"ab407683.9e3fd8","type":"debug","z":"fa1345d7.0957a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":440,"wires":[]},{"id":"9679c348.3a24a","type":"homekit-bridge","z":"","bridgeName":"Virtual Bridge","pinCode":"111-11-111","port":"","allowInsecureRequest":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true},{"id":"6b06c45.47e7a3c","type":"ui_group","z":"","name":"Lights","tab":"a9f8fa81.8f0588","order":1,"disp":true,"width":"6","collapse":false},{"id":"5615eece.b3a81","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.95","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"a9f8fa81.8f0588","type":"ui_tab","z":"","name":"Kitchen","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
Thanks for any pointers!