Send notification every 15 minutes until the window is closed

Hello guys,

I’m struggling to get this automation to work.
I have Wyze sensors on every window in the house but I can’t get to work this:

Window Opened - Wait 15 minutes - Send Notifications (and repeat this task until the window is closed).

Now I’m using the wait-until node for 15 minutes but it’s not what I want.

Thanks and have a great day.

Take a look at the alert integration, should be exactly what you need.

Use a looptimer node.

[{"id":"6cdc6fad.152ce","type":"comment","z":"4f853fd0.1ea12","name":"Monitor of Front/Garage door sensors ","info":"","x":284.14280700683594,"y":935.0477924346924,"wires":[]},{"id":"3fdbfc14.233024","type":"trigger","z":"4f853fd0.1ea12","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"3","extend":false,"units":"min","reset":"off","bytopic":"all","name":"Wait 3 mins for door to be closed","x":673.1606979370117,"y":1112.7263679504395,"wires":[["fb3417c5.c53638"]]},{"id":"50d9a9e2.038a28","type":"comment","z":"4f853fd0.1ea12","name":"Monitor Patio door and Nook window sensors ","info":"","x":299.7677993774414,"y":1058.7977886199951,"wires":[]},{"id":"8f91b2e.041ac5","type":"poll-state","z":"4f853fd0.1ea12","name":"Front/Garage door monitor","server":"8a3231e1.3f0e1","version":1,"updateinterval":"1","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":true,"entity_id":"binary_sensor.front_garage_doors","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":244.76785278320312,"y":987.5478668212891,"wires":[["37e4014b.b65f3e"]]},{"id":"5d0e804d.a3b9","type":"poll-state","z":"4f853fd0.1ea12","name":"Patio door & Nook windows monitor ","server":"8a3231e1.3f0e1","version":1,"updateinterval":"1","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":true,"entity_id":"binary_sensor.patio_door_nook_windows","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":268.5178527832031,"y":1113.7977457046509,"wires":[["3fdbfc14.233024"]]},{"id":"5fa487d2.c43948","type":"api-call-service","z":"4f853fd0.1ea12","name":"Notify Target device with Message","server":"8a3231e1.3f0e1","version":1,"service_domain":"notify","service":"{{topic}}","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1604.8217544555664,"y":1048.5716705322266,"wires":[[]]},{"id":"37e4014b.b65f3e","type":"trigger","z":"4f853fd0.1ea12","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"3","extend":false,"units":"min","reset":"off","bytopic":"all","name":"Wait 3 mins for door to be closed","x":672.8571701049805,"y":987.1428751945496,"wires":[["fb3417c5.c53638"]]},{"id":"2e302f45.37251","type":"function","z":"4f853fd0.1ea12","name":"Create Alexa/IOS Alert","func":"var name = flow.get('alert_name')\n\nvar message1 = flow.get('message1')\nvar message2 = flow.get('friendly_name') \nvar message3 = flow.get('message3')\nvar sound = flow.get('sound')\nvar target = flow.get('target')\n\n\nvar final_msg = `${message1}` + `${message2}` + `${message3}`\nvar payload = {\"data\":\n{\n \"message\": `${final_msg}`,\n \"title\": `${name}`,\n \"data\": {\n \"sound\": `${sound}`,\n \"type\": \"announce\"\n }\n}\n}\nmsg.payload = payload\nmsg.topic = `${target}`\nreturn msg","outputs":1,"noerr":0,"x":1282.1965713500977,"y":1048.5237522125244,"wires":[["5fa487d2.c43948","534ed9c9.b3aa08"]]},{"id":"fb3417c5.c53638","type":"change","z":"4f853fd0.1ea12","name":"Set Message Attributes","rules":[{"t":"set","p":"alert_name","pt":"flow","to":"General Alert","tot":"str"},{"t":"set","p":"message1","pt":"flow","to":"The ","tot":"str"},{"t":"set","p":"friendly_name","pt":"flow","to":"data.attributes.friendly_name","tot":"msg"},{"t":"set","p":"message3","pt":"flow","to":" is open","tot":"str"},{"t":"set","p":"sound","pt":"flow","to":"US-EN-Alexa-Garage-Door-Opened.wav","tot":"str"},{"t":"set","p":"target","pt":"flow","to":"alexa_media_juan_carlos","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1006.3038444519043,"y":1048.1664609909058,"wires":[["2e302f45.37251"]]},{"id":"534ed9c9.b3aa08","type":"debug","z":"4f853fd0.1ea12","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1559.9999732971191,"y":962.8572044372559,"wires":[]},{"id":"8a3231e1.3f0e1","type":"server","z":"","name":"Hassio","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]

2 Likes

Ok, it’s a post in the node-red category, but for me it seems way easier to just use the alert integration or am I missing something?

Thanks a lot, exactly what I wanted. Didn’t know this node exist.
Thanks again!

[{"id":"c4da78f2.382a58","type":"server-state-changed","z":"9c580098.19d8a","name":"lock state change","server":"cc436e5e.bbf7e","version":1,"entityidfilter":"binary_sensor.loungedoorlock","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":180,"y":620,"wires":[["a0a2690e.b46f58"],[]]},{"id":"a0a2690e.b46f58","type":"ha-wait-until","z":"9c580098.19d8a","name":"initial timer","server":"cc436e5e.bbf7e","outputs":2,"entityId":"binary_sensor.loungedoorlock","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"5","timeoutUnits":"minutes","entityLocation":"data","entityLocationType":"msg","checkCurrentState":true,"x":420,"y":620,"wires":[[],["47635cf0.dc8574"]]},{"id":"34f09ea1.dc89f2","type":"api-call-service","z":"9c580098.19d8a","name":"notify unlocked","server":"cc436e5e.bbf7e","version":"1","debugenabled":false,"service_domain":"notify","service":"everyone","entityId":"","data":"{\"message\":\"The front door has been unlocked for {{minutes}} minutes\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":890,"y":620,"wires":[["a0fb93d.aff9a7"]]},{"id":"a0fb93d.aff9a7","type":"ha-wait-until","z":"9c580098.19d8a","name":"loop timer","server":"cc436e5e.bbf7e","outputs":2,"entityId":"binary_sensor.loungedoorlock","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"15","timeoutUnits":"minutes","entityLocation":"data","entityLocationType":"msg","checkCurrentState":true,"x":770,"y":500,"wires":[["357d0e17.cef0d2"],["47635cf0.dc8574"]]},{"id":"357d0e17.cef0d2","type":"api-call-service","z":"9c580098.19d8a","name":"notify locked","server":"cc436e5e.bbf7e","version":"1","debugenabled":false,"service_domain":"notify","service":"everyone","entityId":"","data":"{\"message\":\"The front door is now locked\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1040,"y":500,"wires":[[]]},{"id":"47635cf0.dc8574","type":"change","z":"9c580098.19d8a","name":"","rules":[{"t":"set","p":"minutes","pt":"msg","to":"$round(data.timeSinceChangedMs / 60000,0)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":620,"wires":[["34f09ea1.dc89f2"]]},{"id":"407cc06f.d4b95","type":"comment","z":"9c580098.19d8a","name":"Front Door","info":"","x":80,"y":440,"wires":[]},{"id":"cc436e5e.bbf7e","type":"server","z":"","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

Send first message after 5 minutes, another every 15 minutes, saying how long door has been opened for, finally sends a message to say the door is closed.

1 Like

Silly question Bertie: @eggman how did you paste the flow so that it is compressed into a single line. I tried the </> symbol but it didn’t work for me…

Put three back ticks at the start and end of the code.

Thanks, yes tried that but it doesn’t seem to work for me. I’m scratching my head as to why not, I must be missing something…

Make sure you’re using the backtick and not a single quote - on a windows keyboard it’s usually top left above the tab key.

` not '

1 Like

Yes, on the Mac it’s in a similar keyboard position. I’ll just have to figure out what I’m doing wrong. Thank you, I appreciate you taking the time!!

Try clicking the </> icon for pre-formatted text, it should auto generate the ` and then paste your code in

1 Like

Considering the sensor entities are named binary_sensor.window_*, you can use this flow to monitor all of them.

[{"id":"629e99bb.42bff8","type":"trigger","z":"9e2d545a.b4a658","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-15","extend":false,"units":"min","reset":"","bytopic":"topic","name":"","x":1010,"y":820,"wires":[["294ed851.068248"]]},{"id":"524f82f1.f5bfcc","type":"server-state-changed","z":"9e2d545a.b4a658","name":"Window Sensor","server":"fc6553e6.c5975","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"^binary_sensor\\.window_.*$","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":680,"y":820,"wires":[["629e99bb.42bff8"],["8bc1d5ca.6b9d08"]]},{"id":"8bc1d5ca.6b9d08","type":"change","z":"9e2d545a.b4a658","name":"RESET","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":840,"wires":[["629e99bb.42bff8"]]},{"id":"90d2aed3.bb667","type":"api-call-service","z":"9e2d545a.b4a658","name":"Notify","server":"fc6553e6.c5975","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_iphone","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1310,"y":820,"wires":[[]]},{"id":"294ed851.068248","type":"template","z":"9e2d545a.b4a658","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n    \"data\": {\n        \"message\": \"{{topic}} is open\"\n    }\n}","output":"json","x":1180,"y":820,"wires":[["90d2aed3.bb667"]]}]
3 Likes

For some reason, when I tried this, the message comes out "It has been minutes minutes since “event”.

I am having the same problem. Were you able to resolve?

I’ll have to dig back into it when I get home. I did figure it out, but I can’t remember what I did.

I actually turned the flow off, because my kids left the door open so often that my wife found the reminder more annoying than the door being left open.