Hi,
Is it possible to store the state of a dashboard switch node in a context [file] and restore the state after a reset/deploy with an injector node?
Hi,
Is it possible to store the state of a dashboard switch node in a context [file] and restore the state after a reset/deploy with an injector node?
Hi,
in you settings.js file enable storing context in a file (Working with context : Node-RED), then try this:
[{"id":"0c8265f37d6d6231","type":"inject","z":"3ee8efab.e6694","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"#:(storeInFile)::lastSwitchState","payloadType":"flow","x":160,"y":580,"wires":[["b9bcda0a2aa16907"]]},{"id":"b9bcda0a2aa16907","type":"ui_switch","z":"3ee8efab.e6694","name":"","label":"switch","tooltip":"","group":"7d65a5299b5721bf","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":330,"y":580,"wires":[["209e7c0d8ab556d6"]]},{"id":"209e7c0d8ab556d6","type":"change","z":"3ee8efab.e6694","name":"","rules":[{"t":"set","p":"#:(storeInFile)::lastSwitchState","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":580,"wires":[[]]},{"id":"7d65a5299b5721bf","type":"ui_group","name":"Retentive switch","tab":"cc16d42c.cb9c08","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"cc16d42c.cb9c08","type":"ui_tab","name":"Test","icon":"fa-lightbulb-o","order":1,"disabled":false,"hidden":false}]```
Yes got it, I also use injectors to restore the switch from the stored context value
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.