I'm tying myself in knots trying to make sure/think through this flow. Basically I'm trying to:-
-Detect a new voicemail in a folder, and if found, play a nag every 15 minutes until it's listened to.
-If a second voicemail lands in the same folder, ramp things up a bit by playing a second, different nag is played every 15 minutes and the first nag is not played at all.
-Reinitialise when no voicemails waiting
I'm sure I've probably made sure silly logic errors as I'm not a natural programmer. I have now spent so long looking at this flow and tweaking it I almost can't see it any more. Thank you for any tips.
Uses: node-red-contrib-simple-gate
[{"id":"85dfd613.ecdcc8","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"cd64ef11.16891","type":"watch","z":"85dfd613.ecdcc8","name":"activity in vm folder","files":"/var/spool/asterisk/voicemail/default/24/INBOX/","recursive":true,"x":90,"y":200,"wires":[["2ec2c5c1.8b710a"]]},{"id":"c67a5b72.1e56c8","type":"delay","z":"85dfd613.ecdcc8","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1010,"y":300,"wires":[["cf3ac840.41d4a8"]]},{"id":"2e5178b7.dac9f8","type":"delay","z":"85dfd613.ecdcc8","name":"once","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":450,"y":180,"wires":[["6f8e1057.3ff5"]]},{"id":"3ff99cee.703944","type":"exec","z":"85dfd613.ecdcc8","command":"bash /var/spool/asterisk/tmp/voicemails.sh","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"play sound ","x":1610,"y":100,"wires":[[],[],[]]},{"id":"2ec2c5c1.8b710a","type":"fs-ops-access","z":"85dfd613.ecdcc8","name":"Greater than one voicemail?","path":"/var/spool/asterisk/voicemail/default/24/INBOX/","pathType":"str","filename":"msg0001.wav","filenameType":"str","read":true,"write":false,"throwerror":false,"x":200,"y":280,"wires":[["345f1593.60958a"],["2e5178b7.dac9f8","23d7925c.772b9e"]],"info":"Bottom one if it doesn't exist\nTop one if it does"},{"id":"6f8e1057.3ff5","type":"delay","z":"85dfd613.ecdcc8","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":620,"y":180,"wires":[["6d921943.a46468","de4395b7.59d938"]]},{"id":"6d921943.a46468","type":"fs-ops-access","z":"85dfd613.ecdcc8","name":"Does a first vm exist?","path":"/var/spool/asterisk/voicemail/default/24/INBOX/","pathType":"str","filename":"msg0000.wav","filenameType":"str","read":true,"write":false,"throwerror":false,"x":1000,"y":120,"wires":[["c67a5b72.1e56c8","bac5dd54.1a068"],[]],"info":"Bottom one if it doesn't exist\nTop one if it does"},{"id":"1daaeb8e.39c6a4","type":"change","z":"85dfd613.ecdcc8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"BOOM","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1380,"y":240,"wires":[["f3e6ffc7.fa12d"]]},{"id":"f3e6ffc7.fa12d","type":"mqtt out","z":"85dfd613.ecdcc8","name":" voicemail at work","topic":"pbx/voicemail","qos":"","retain":"","broker":"70556b7.be24694","x":1790,"y":240,"wires":[]},{"id":"345f1593.60958a","type":"delay","z":"85dfd613.ecdcc8","name":"once","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":470,"y":280,"wires":[["bbcde3e7.f0e85"]]},{"id":"736d3048.d0e9a","type":"exec","z":"85dfd613.ecdcc8","command":"bash /var/spool/asterisk/tmp/voicemailspiling.sh","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"play naggier sound at ","x":1830,"y":380,"wires":[[],[],[]]},{"id":"c6cd108b.e50aa","type":"mqtt out","z":"85dfd613.ecdcc8","name":"messages piling up","topic":"pbx/voicemail/prelim","qos":"","retain":"","broker":"70556b7.be24694","x":1410,"y":440,"wires":[]},{"id":"bac5dd54.1a068","type":"time-range-switch","z":"85dfd613.ecdcc8","name":"shop open?","lat":"1","lon":"1","startTime":"08:30","endTime":"17:30","startOffset":0,"endOffset":0,"x":1270,"y":100,"wires":[["3ff99cee.703944"],["b2b852b8.24ca9"]]},{"id":"5ce6339d.2f069c","type":"time-range-switch","z":"85dfd613.ecdcc8","name":"shop open?","lat":"1","lon":"1","startTime":"08:30","endTime":"17:30","startOffset":0,"endOffset":0,"x":1430,"y":380,"wires":[["736d3048.d0e9a"],["aafd810.1adba8"]]},{"id":"bbcde3e7.f0e85","type":"delay","z":"85dfd613.ecdcc8","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":300,"wires":[["f7aefb68.fd3758","2aa11b79.ce6df4"]]},{"id":"b2b852b8.24ca9","type":"mqtt out","z":"85dfd613.ecdcc8","name":"out of hours vm left","topic":"pbx/voicemail/ooh","qos":"","retain":"","broker":"70556b7.be24694","x":1610,"y":160,"wires":[]},{"id":"cf3ac840.41d4a8","type":"gate","z":"85dfd613.ecdcc8","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1010,"y":220,"wires":[["6d921943.a46468"]]},{"id":"7a5b5ca4.bb51e4","type":"change","z":"85dfd613.ecdcc8","name":"Close","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"close","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":260,"wires":[["cf3ac840.41d4a8"]]},{"id":"f7aefb68.fd3758","type":"fs-ops-access","z":"85dfd613.ecdcc8","name":"does a second vm exist","path":"/var/spool/asterisk/voicemail/default/24/INBOX/","pathType":"str","filename":"msg0001.wav","filenameType":"str","read":true,"write":false,"throwerror":false,"x":990,"y":380,"wires":[["41287418.d969dc","5ce6339d.2f069c","7a5b5ca4.bb51e4"],[]],"info":"Bottom one if it doesn't exist\nTop one if it does"},{"id":"41287418.d969dc","type":"delay","z":"85dfd613.ecdcc8","name":"","pauseType":"delay","timeout":"15","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":990,"y":540,"wires":[["f7aefb68.fd3758"]]},{"id":"23d7925c.772b9e","type":"change","z":"85dfd613.ecdcc8","name":"open","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":160,"wires":[["cf3ac840.41d4a8"]]},{"id":"de4395b7.59d938","type":"fs-ops-access","z":"85dfd613.ecdcc8","name":"Does a first vm exist?","path":"/var/spool/asterisk/voicemail/default/24/INBOX/","pathType":"str","filename":"msg0000.wav","filenameType":"str","read":true,"write":false,"throwerror":false,"x":800,"y":260,"wires":[["1daaeb8e.39c6a4"],[]],"info":"Bottom one if it doesn't exist\nTop one if it does"},{"id":"2aa11b79.ce6df4","type":"fs-ops-access","z":"85dfd613.ecdcc8","name":"does a second vm exist","path":"/var/spool/asterisk/voicemail/default/24/INBOX/","pathType":"str","filename":"msg0001.wav","filenameType":"str","read":true,"write":false,"throwerror":false,"x":710,"y":400,"wires":[["c6cd108b.e50aa"],[]],"info":"Bottom one if it doesn't exist\nTop one if it does"},{"id":"aafd810.1adba8","type":"mqtt out","z":"85dfd613.ecdcc8","name":"out of hours vm left","topic":"pbx/voicemail/ooh","qos":"","retain":"","broker":"70556b7.be24694","x":1750,"y":440,"wires":[]},{"id":"70556b7.be24694","type":"mqtt-broker","z":"","name":"hass","broker":"192.168.194.22","port":"1883","clientid":"noderedmacmini","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]