Notification node with OK/Cancel and timeout


I'm curious if it's possible to add timeout to notification node with OK/Cancel buttons or to control that node by simulating a button click (eg. by sending it a msg.).

I'm developing an energy saving mode for my home. It will shut down some devices when nobody's there. Presence detection is based on cell phones being connected to a WiFi network.
This method has a lag and sometimes gives a false "nobody's home' reading.

Because of this I want to display a dialog saying "Energy saving mode will be engaged in X minutes." Then if no action in taken the dialog should disappear and mentioned mode should be turned on. The buttons should allow users to postpone this event or switch the system into manual mode.

For now I can make the dialog appear, start a countdown in the background and engage ES mode after the countdown hits 0. I don't know how to close the dialog that is opened. Is it even possible with a generic notification node?


not easily do-able at present - but probably something we should look at.
Meanwhile - the toast (rather than OK/Cancel) does have a timeout, and can be dismissed early with Esc key.

I have added the capability to dismiss the dialog by sending a blank payload "" .
Will be in next release.

Thanks, dceejay!

BTW I never thought of an ESC key since I'm testing my setup on a touchscreen with no virtual keyboard...

I do something similar, try this;

[{"id":"dd52f866.edb3c8","type":"inject","z":"4487e413.bb781c","name":"System Shutdown","topic":"","payload":"sudo poweroff","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":90,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-power-off"},{"id":"b60d313.4c49bd","type":"inject","z":"4487e413.bb781c","name":"System Reboot","topic":"","payload":"sudo reboot","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":150,"y":130,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-refresh"},{"id":"2ad017fa.99df08","type":"inject","z":"4487e413.bb781c","name":"Restart node-RED","topic":"","payload":"node-red-restart","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":170,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-refresh"},{"id":"8f8e8089.058fa","type":"function","z":"4487e413.bb781c","name":"Countdown","func":"const input = msg.payload;\nconst cancel = false;\nvar desc;\nvar counter = 10;\n\nif (input == \"cancel\"){\n    flow.set(\"cancel\", true);\n    return;\n} else if (input == \"node-red-restart\"){\n        desc = \"Restarting node-RED\";\n    } else if (input == \"sudo reboot\"){\n        desc = \"Rebooting system\";\n    } else if (input == \"sudo poweroff\"){\n        desc = \"Shutting down system\";\n    } else {return;}\n\nvar countdown = setInterval(function(){\n  node.status({text:(desc+\" in \"+counter+\" seconds\")});\n  counter--;\n  if (flow.get(\"cancel\")===true) {\n      clearInterval(countdown);\n      node.status({text:\"Request Cancelled\"});\n      flow.set(\"cancel\", false);\n  }\n  \n  if (counter === -1) {\n    node.status({text:(desc+\" NOW!\")});\n    clearInterval(countdown);\n    node.send({\"payload\": input});\n  }\n}, 1000);","outputs":1,"noerr":0,"x":370,"y":153,"wires":[["f560bf46.4c304"]],"icon":"font-awesome/fa-hourglass-1"},{"id":"c06193e0.c2a49","type":"inject","z":"4487e413.bb781c","name":"Cancel","topic":"","payload":"cancel","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":180,"y":210,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-exclamation-triangle"},{"id":"f560bf46.4c304","type":"exec","z":"4487e413.bb781c","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"System Command","x":600,"y":150,"wires":[[],[],[]]}]