Back again...this is a continuation of a topic from over a year ago...for reference: (https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451)
I stepped away from this part of my project to work on other items as I never really was able to make it reliable. Need is upon me now, thus the resurrection.
Short story is that the UI switch does not respond to UI activation...and the state of the switch is unreliable in reset to match the actual state of the 433mhz controlled relay. Here is the flow:
[{"id":"fe93b018b2b9d692","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"ff6761b0aaece246","type":"switch","z":"fe93b018b2b9d692","name":"","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"2513048","vt":"str"},{"t":"eq","v":"8529fb","vt":"str"},{"t":"eq","v":"2529fb","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":260,"y":110,"wires":[["8b42f15fdd01ccee","50cfb7fdbc9503c8"],[],[]],"outputLabels":["relay 1","relay 2","relay 3"]},{"id":"8b42f15fdd01ccee","type":"debug","z":"fe93b018b2b9d692","name":"from switch node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":460,"y":90,"wires":[]},{"id":"50cfb7fdbc9503c8","type":"change","z":"fe93b018b2b9d692","name":"remove flow.switch2 --> reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"switch2","tot":"flow"},{"t":"set","p":"switch2","pt":"flow","to":"$not(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":210,"wires":[["46122a637156923a","01e62b0f01af71da"]]},{"id":"46122a637156923a","type":"ui_switch","z":"fe93b018b2b9d692","name":"","label":"switch2","tooltip":"","group":"bc31878d1a223849","order":4,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"switch2","topicType":"str","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":true,"className":"","x":930,"y":210,"wires":[["38f08a67e36964d5","c6902f0c006adcdc","bce93aa4b3a7d097"]]},{"id":"c6902f0c006adcdc","type":"change","z":"fe93b018b2b9d692","name":"copy msg.payload --> flow.switch2","rules":[{"t":"set","p":"switch2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":250,"wires":[["68d18854d09e1e11"]]},{"id":"38f08a67e36964d5","type":"debug","z":"fe93b018b2b9d692","name":"Out of switch","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":90,"wires":[]},{"id":"adfaabc84c86d5ae","type":"inject","z":"fe93b018b2b9d692","name":"Reset switch state on boot","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":".1","topic":"","payload":"switch2","payloadType":"flow","x":690,"y":150,"wires":[["52b20a55b48bcc78","46122a637156923a"]]},{"id":"01e62b0f01af71da","type":"debug","z":"fe93b018b2b9d692","name":"out of switch2 reset","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":340,"wires":[]},{"id":"52b20a55b48bcc78","type":"debug","z":"fe93b018b2b9d692","name":"out of boot reset","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":90,"wires":[]},{"id":"bce93aa4b3a7d097","type":"rpi-433-emitter","z":"fe93b018b2b9d692","pin":"0","pulseLength":"0","protocol":"0","x":1200,"y":170,"wires":[]},{"id":"0f91292ccb242826","type":"rpi-433-sniffer","z":"fe93b018b2b9d692","pin":"3","pulseLength":0,"debounceDelay":500,"x":100,"y":110,"wires":[["ff6761b0aaece246","7ee1a528a0422b82"]]},{"id":"7ee1a528a0422b82","type":"debug","z":"fe93b018b2b9d692","name":"from sniffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":110,"y":200,"wires":[]},{"id":"68d18854d09e1e11","type":"debug","z":"fe93b018b2b9d692","name":"copy value after switch","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1190,"y":310,"wires":[]},{"id":"bc31878d1a223849","type":"ui_group","name":"Testing","tab":"70cd76099d731fa7","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"70cd76099d731fa7","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
Currently the UI switch node responds to external 433mhz inputs and transitions on/off, however UI activation of the switch does not work. @Colin and @Steve-Mcl have offered assistance previously that was very helpful (should have a way to pay you both a retainer!). I have a hunch that this may be due to the context storage on my Pi which is currently configured as such storing to file:
And configured in NR setting.js as:
contextStorage: {
default: { module:"localfilesystem" },
storeInMemory: { module: "memory" }
},
However when I check the pi/.node-red/context folder it is unreliable to see the flow context stored...sometimes I see the context stored...other times not: