Use dashboard input to alter scheduled time. #79
-
I'm still rather fairy new to Node-red. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Currently trying to figure out the Dynamic Trigger as stated in the wiki. |
Beta Was this translation helpful? Give feedback.
-
Hi @deek042, there are several possibilities. One way that I went already in the past was to setup a text input widget configured as time picker in a Node-RED dashboard. The output of such widget is the time in milliseconds since midnight. This time can be written to a context variable in the following JSON format: {
"type": "time",
"value": time_value_from_widget,
"offset": 0,
"random": false
} Then you can configure the scheduler node to use that context variable as trigger for an event and it will fire as soon as the time has been reached. You can additionally use a switch widget on the dashboard to turn the scheduler node on or off (by sending a message with payload equal to true or false to the node when the state of the switch changes). You send a message with payload equal to "reload" to the scheduler node each time you have written an updated time value to the context variable. The text input time picker widget can be configured to only send an output when the focus left. Here is a very simple flow that should do the above: This is the flow: [{"id":"24a2b58d3fcbf32f","type":"tab","label":"Scheduler","disabled":false,"info":"","env":[]},{"id":"fadd53876e1d5854","type":"ui_text_input","z":"24a2b58d3fcbf32f","name":"","label":"","tooltip":"","group":"2abe341a.254e8c","order":1,"width":0,"height":0,"passthru":true,"mode":"time","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":600,"y":360,"wires":[["7451ace041a92be0"]]},{"id":"7451ace041a92be0","type":"change","z":"24a2b58d3fcbf32f","name":"","rules":[{"t":"set","p":"time","pt":"flow","to":"{\t \"type\": \"time\",\t \"value\": payload,\t \"offset\": 0,\t \"random\": false\t}\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":360,"wires":[["7c1f13683ce34815"]]},{"id":"7c1f13683ce34815","type":"change","z":"24a2b58d3fcbf32f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"reload","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":360,"wires":[["0850e3cc5766e9f5"]]},{"id":"0850e3cc5766e9f5","type":"chronos-scheduler","z":"24a2b58d3fcbf32f","name":"","config":"5e581578.25c88c","schedule":[{"trigger":{"type":"flow","value":"time"},"output":{"type":"msg","property":{"name":"payload","type":"bool","value":"true"}}}],"multiPort":false,"disabled":false,"outputs":1,"x":1140,"y":360,"wires":[["9692e896d21dda9e"]]},{"id":"9692e896d21dda9e","type":"debug","z":"24a2b58d3fcbf32f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1310,"y":360,"wires":[]},{"id":"2abe341a.254e8c","type":"ui_group","name":"Test","tab":"6ef3ea88.2f9554","order":1,"disp":true,"width":"6","collapse":false},{"id":"5e581578.25c88c","type":"chronos-config","name":"Berlin","sunPositions":[{"angle":-4,"riseName":"blueHourDawn","setName":"blueHourDusk"},{"angle":-8,"riseName":"blueHourDawnBegin","setName":"blueHourDuskEnd"}]},{"id":"6ef3ea88.2f9554","type":"ui_tab","name":"Test","icon":"dashboard","order":1,"disabled":false,"hidden":false}] |
Beta Was this translation helpful? Give feedback.
Hi @deek042, there are several possibilities. One way that I went already in the past was to setup a text input widget configured as time picker in a Node-RED dashboard. The output of such widget is the time in milliseconds since midnight. This time can be written to a context variable in the following JSON format:
Then you can configure the scheduler node to use that context variable as trigger for an event and it will fire as soon as the time has been reached. You can additionally use a switch widget on the dashboard to turn the scheduler node on or off (by sending a message with payload…