Great to hear we are similar in our thinking.
I seem to be (still ?) confused with what the context.blah and var things.
My thinking is:
(excuse the rant)
The message comes in.
The delay is in msg.delay
If the msg.delay is “valid” store this. From what I get this has to be via CONTEXT, as it has to survive the node’s reiteration.
Alas this is done by looking at the msg.topic and if it equals ‘delay’ then…
ELSE
(meaning that it wasn’t a delay message)
get the stored value and construct the new message.
That is done by getting this message’s payload and add the msg.delay to it.
I have the first three lines because I need to get the topic, payload (to store if it is a delay) and …
You are probably right. I shall delete them.
There seems to be a flaw with my structural understanding of what is what.
Again: Not wanting to dismiss your efforts, this is the boiled down version I got with a mixture of what you have and what I had.
Now, also there are a few things which are “different” to the original request and were left out only to keep it simple.
I haven’t included the extra input nodes as this is only to get the idea working.
Oh, the idea:
A message is received and a .sh (bash) script is run to then execute an .py (python) script.
This gets around the problem about parsing the message to the script. (another thread.)
It is displayed and after a certain (set) time, it is wiped.
It is wiped by running another .sh script. Which is where the delay comes in.
So please don’t fret about what the scripts do and how they do it.
I busted a lot of time getting them to work and take multiple words as parameters.
This is done by wrapping them in “quotes”.
[{"id":"2dfc598e.d9a4ee","type":"ui_slider","z":"e9882c4e.450a6","name":"","label":"Wipe Delay","group":"d8f7708b.e6a3b","order":0,"width":"5","height":"1","passthru":true,"topic":"delay","min":0,"max":"20000","step":"1000","x":110,"y":180,"wires":[["d6716a43.917c88","e4ae8879.587a6","e9bf5a2f.345b3","ffec291e.484cc"]]},{"id":"4851ca4d.bbe0dc","type":"inject","z":"e9882c4e.450a6","name":"","topic":"","payload":"Banana","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["9f112d7f.e7a9d8","e9bf5a2f.345b3"]]},{"id":"e9bf5a2f.345b3","type":"function","z":"e9882c4e.450a6","name":"Set delay","func":"if (msg.topic === \"delay\") \n{\n node.status({fill:\"yellow\",shape:\"dot\",text:\"value\"});\n context.set(\"delay\", msg.payload);\n// msg = null;\n} \nelse \n{\n node.status({fill:\"green\",shape:\"dot\",text:\"message\"});\n delay = context.get(\"delay\");\n if (delay === undefined) delay = 1000; // default delay ms\n msg.delay = delay;\n return msg;\n}\n","outputs":1,"noerr":0,"x":300,"y":220,"wires":[["315aeaa0.3c51ce","11f395d8.d4035a","f2b49294.ac6ce8"]]},{"id":"ffec291e.484cc","type":"function","z":"e9882c4e.450a6","name":"/1000","func":"var j = msg.payload;\nvar x = j / 1000;\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":180,"wires":[["cf4017e3.973d7"]]},{"id":"6ecb508b.ca1f1","type":"inject","z":"e9882c4e.450a6","name":"","topic":"delay","payload":"4000","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":"2","x":110,"y":280,"wires":[["e9bf5a2f.345b3"]]},{"id":"cf4017e3.973d7","type":"ui_text","z":"e9882c4e.450a6","group":"d8f7708b.e6a3b","order":0,"width":"5","height":"1","name":"","label":"Seconds Delay = ","format":"{{msg.payload}}","layout":"row-center","x":490,"y":180,"wires":[]},{"id":"315aeaa0.3c51ce","type":"delay","z":"e9882c4e.450a6","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":220,"wires":[["61300481.033ab4"]]},{"id":"9f112d7f.e7a9d8","type":"exec","z":"e9882c4e.450a6","command":"/home/pi/PiFace/LCD_message","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":790,"y":140,"wires":[["d59566e1.636b48","39f43c2a.58068c"],[],[]]},{"id":"61300481.033ab4","type":"exec","z":"e9882c4e.450a6","command":"/home/pi/PiFace/LCD_off","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Wipe display after a time","x":770,"y":220,"wires":[["9c1eb40a.bbea68","39f43c2a.58068c"],[],[]]},{"id":"d8f7708b.e6a3b","type":"ui_group","z":"","name":"Group 1","tab":"cf397e02.acf53","order":1,"disp":true,"width":"10"},{"id":"cf397e02.acf53","type":"ui_tab","z":"","name":"Message CTL","icon":"dashboard","order":3}]
There is also a “default time” node which sets the default time to 4 seconds so when I deploy the flows it isn’t some weird number.