If anyone is still interested.
(Foreign nodes used)
(fan, gate)
[{"id":"fbe74a055f167918","type":"subflow","name":"WAP status monitor","info":"","category":"","in":[{"x":100,"y":80,"wires":[{"id":"034a71c3fa82b627"},{"id":"643c3cdc07e3c049"}]}],"out":[{"x":660,"y":80,"wires":[{"id":"643c3cdc07e3c049","port":0}]},{"x":660,"y":150,"wires":[{"id":"9f8f0275c09b9051","port":0}]},{"x":660,"y":210,"wires":[{"id":"ec436d4dd0c415df","port":0}]}],"env":[{"name":"down","type":"str","value":""},{"name":"up","type":"str","value":""},{"name":"offlinemsg","type":"str","value":""}],"meta":{},"color":"#DDAA99","outputLabels":["Offline message","Feedback signal","Problem message"],"status":{"x":660,"y":280,"wires":[{"id":"344fab4eca9db3f5","port":0}]}},{"id":"643c3cdc07e3c049","type":"function","z":"fbe74a055f167918","name":"Counter","func":"var counter = context.get(\"counter\") || 0;\n\n// Get values from $env variables.\nlet UP = env.get(\"up\");\nlet DOWN = env.get(\"down\");\nlet offline = env.get(\"offlinemsg\");\n\nif (msg.payload == UP)\n{\n // UP\n //node.warn(\"+1\");\n node.status({text: \"+1 \"});\n counter = counter + 1;\n context.set(\"counter\",counter);\n if (counter < 3)\n {\n // Ok\n // Therefore do/send NOTHING\n return;\n// msg.payload = \"Online\";\n// return msg;\n }\n} else\nif (msg.payload == DOWN)\n{\n // DOWN\n //node.warn(\"-1\");\n node.status({text: \"-1 \"});\n counter = 0;\n context.set(\"counter\",counter);\n}\nif (counter < 0)\n{\n counter = 0;\n context.set(\"counter\",counter);\n}\n\n//node.warn(\"Counter is at value \" + counter);\nnode.status({text: \"Counter is at value \" + counter});\n\n\nif (counter > 1)\n{\n // Two fails.\n// msg.payload = \"Offline\";\n msg.payload = offline;\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":80,"wires":[[]]},{"id":"034a71c3fa82b627","type":"switch","z":"fbe74a055f167918","name":"Up/Down","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"UP","vt":"env"},{"t":"eq","v":"DOWN","vt":"env"}],"checkall":"true","repair":false,"outputs":2,"x":105,"y":170,"wires":[["db3a6b270e9875b4"],["635488afad2607dd"]],"l":false},{"id":"9f8f0275c09b9051","type":"trigger","z":"fbe74a055f167918","name":"Variable","op1":"","op2":"TICK","op1type":"nul","op2type":"str","duration":"30","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":440,"y":150,"wires":[[]]},{"id":"635488afad2607dd","type":"change","z":"fbe74a055f167918","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":315,"y":170,"wires":[["9f8f0275c09b9051","db3a6b270e9875b4"]],"l":false},{"id":"115ce6b7b0ecbab9","type":"change","z":"fbe74a055f167918","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"msg.delay / 6","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":315,"y":130,"wires":[["9f8f0275c09b9051"]],"l":false},{"id":"db3a6b270e9875b4","type":"counter","z":"fbe74a055f167918","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":185,"y":130,"wires":[["fa1f32eae6eb928a"]],"l":false},{"id":"fa1f32eae6eb928a","type":"switch","z":"fbe74a055f167918","name":"count value?","property":"count","propertyType":"msg","rules":[{"t":"lt","v":"3","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":245,"y":130,"wires":[["115ce6b7b0ecbab9"],["ec436d4dd0c415df"]],"l":false},{"id":"ec436d4dd0c415df","type":"change","z":"fbe74a055f167918","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Problem","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":210,"wires":[[]]},{"id":"344fab4eca9db3f5","type":"status","z":"fbe74a055f167918","name":"","scope":["643c3cdc07e3c049"],"x":460,"y":280,"wires":[[]]},{"id":"610e3e684b9f0ebb","type":"pythonshell in","z":"c56bddee.ca0a18","name":"wifiscan","pyfile":"/home/pi/python_stuff/wifiscan.py","virtualenv":"","continuous":false,"stdInData":false,"x":340,"y":4620,"wires":[["64e80fd6757450b7"]]},{"id":"93bb9ee10ed12d10","type":"split","z":"c56bddee.ca0a18","name":"Spliter","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":330,"y":4730,"wires":[["ff4761cea65711f5"]]},{"id":"ff4761cea65711f5","type":"switch","z":"c56bddee.ca0a18","name":"Look for my WAP names","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Marys_Farm_2.4","vt":"str"},{"t":"cont","v":"PiNet","vt":"str"},{"t":"cont","v":"MusicPi","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":390,"y":4780,"wires":[["aa10b4119644f4bf"],[],[]]},{"id":"d64c32ccf6489133","type":"debug","z":"c56bddee.ca0a18","name":"STATUS","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":4590,"wires":[]},{"id":"c60b0751c9bb4b15","type":"change","z":"c56bddee.ca0a18","name":"up","rules":[{"t":"set","p":"payload","pt":"msg","to":"UP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":4670,"wires":[["d3d2d9bfb238c398"]]},{"id":"725a561b78318d32","type":"change","z":"c56bddee.ca0a18","name":"down","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":4810,"wires":[["d3d2d9bfb238c398"]]},{"id":"6dfd1861b9442a00","type":"gate","z":"c56bddee.ca0a18","name":"Simulate WAP not visible","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":670,"y":4810,"wires":[["725a561b78318d32","04a0212668fa4649"]]},{"id":"7d5746c5627d733b","type":"inject","z":"c56bddee.ca0a18","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"close","payloadType":"str","x":450,"y":4840,"wires":[["6dfd1861b9442a00"]]},{"id":"43149a1220842b81","type":"inject","z":"c56bddee.ca0a18","name":"Go","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":450,"y":4880,"wires":[["6dfd1861b9442a00"]]},{"id":"bee2cea7a2f5a514","type":"inject","z":"c56bddee.ca0a18","name":"(reset - for testing only)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":690,"y":4890,"wires":[["725a561b78318d32"]]},{"id":"d3d2d9bfb238c398","type":"fan","z":"c56bddee.ca0a18","name":"","x":675,"y":4670,"wires":[["ed619f1dc568ee75"]],"l":false},{"id":"80c73d34b4f76dce","type":"debug","z":"c56bddee.ca0a18","name":"Feedback","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":4690,"wires":[]},{"id":"64e80fd6757450b7","type":"change","z":"c56bddee.ca0a18","name":"delay (ms)","rules":[{"t":"set","p":"delay","pt":"msg","to":"$globalContext(\"SCAN_TIME\") * 6","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":295,"y":4670,"wires":[["93bb9ee10ed12d10","c60b0751c9bb4b15"]],"l":false},{"id":"f21047b4495ebcc6","type":"debug","z":"c56bddee.ca0a18","name":"Problem (Just for the sake of making sure there is a signal)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1210,"y":4770,"wires":[]},{"id":"04a0212668fa4649","type":"change","z":"c56bddee.ca0a18","name":"Online","rules":[{"t":"set","p":"payload","pt":"msg","to":"Online","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":4850,"wires":[["d64c32ccf6489133"]]},{"id":"aa10b4119644f4bf","type":"trigger","z":"c56bddee.ca0a18","name":"Slight delay (needed)","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":650,"y":4750,"wires":[["6dfd1861b9442a00"]]},{"id":"ed619f1dc568ee75","type":"subflow:fbe74a055f167918","z":"c56bddee.ca0a18","name":"","env":[{"name":"down","value":"true","type":"bool"},{"name":"up","value":"UP","type":"str"},{"name":"offlinemsg","value":"Offline","type":"str"}],"x":810,"y":4670,"wires":[["d64c32ccf6489133"],["80c73d34b4f76dce","610e3e684b9f0ebb"],["f21047b4495ebcc6"]]},{"id":"9e6c34630719c036","type":"comment","z":"c56bddee.ca0a18","name":"Timed pulses here in reality","info":"","x":360,"y":4560,"wires":[]}]
And there is a sub-flow.
Left side of flow:
My clock (every n
seconds) comes into the node to run a python script (posted above) and list the visible WAPs.
Moving down:
The delay
(frequency) is put in the message to share with other nodes where needed.
Split the message to get individual WAP names.
Switch to my 2 WAPS (there's going to be a third)
I add a slight delay - you'll see why soon.
The gate
node simulates / allows you to simulate the WAP name not being visible.
(I've tweaked the flow IRL slightly) to get around the need for the 2 change
nodes.
One sends the online
message.
The one above it sends a message to the subflow
to tell it that the WAP is visible.
Looping now back to the left of the flow:
Where we went down before, we go right.
Go into a change
node that sends an UP
message.
That goes to the function
node.
The message is received. An internal counter increments.
(Now going back to the online
message bit.
The down
message is sent into the function
node and that decrements the counter.
All things being good, if the counter is < 3
nothing is sent.
If the counter >=3
the offline
message is sent.
So if 3
messages pass (no time limits used/needed) and there is no DOWN
message received an offline
message is sent.
Somewhere in there the feedback output of the subflow sends a signal back to force a scan of visible WAPs.
The third output is just there to make sure things are working.
But the real thing is the offline message being sent on output 1.
Clearer?