Window Opened Notification

I have 13 windows in the house. I want to send a notification to my iOS device when a window is opened. Now I have been able to do this if I setup 1 flow per window. But is there a way to setup under 1 flow and just have Node-Red send the notification based on knowing which when was opened. I have added my flow below. The Notify Sean iPhone sends iOS notification with the name of the window opened. My goal is to put all windows in this flow and have Node Red pull the name from entity id and change iOS notification instead of having 13 flows that are the same.

[{"id":"5b724328.7e27ec","type":"tab","label":"Guest Bedroom Window Opened","disabled":false,"info":""},{"id":"edec98aa.273268","type":"api-call-service","z":"5b724328.7e27ec","name":"Notify Garage Google Mini","server":"f70a8bc3.ce4fe8","version":1,"debugenabled":false,"service_domain":"tts","service":"google_say","entityId":"media_player.garage_speaker","data":"{\"message\":\"Guest Bedroom Window 1 Opened\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":600,"y":480,"wires":[[]]},{"id":"b05fd6da.02be88","type":"api-call-service","z":"5b724328.7e27ec","name":"Notify Sean iPhone","server":"f70a8bc3.ce4fe8","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_seans_iphone","entityId":"","data":"{\"message\":\"Guest Bedroom Window 1 Opened\",\"title\":\"Window Opened\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":570,"y":60,"wires":[[]]},{"id":"24557b4b.9c2ed4","type":"api-call-service","z":"5b724328.7e27ec","name":"Notify Michelle iPhone","server":"f70a8bc3.ce4fe8","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_michelle_iphone","entityId":"","data":"{\"message\":\"Guest Bedroom Window 1 Opened\",\"title\":\"Window Opened\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":580,"y":140,"wires":[[]]},{"id":"8119622a.a5f2","type":"api-call-service","z":"5b724328.7e27ec","name":"Notify Master Bedroom Echo","server":"f70a8bc3.ce4fe8","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_master_bedroom_echo_dot","entityId":"","data":"{    \"type\": \"tts\"    \"message\": \"Guest Bedroom Window 1 Opened\",}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":600,"y":240,"wires":[[]]},{"id":"6bb9d99e.7f6b18","type":"api-call-service","z":"5b724328.7e27ec","name":"Notify Living Room Echo","server":"f70a8bc3.ce4fe8","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media_living_room_echo","entityId":"","data":"{    \"type\": \"tts\"    \"message\": \"Guest Bedroom Window 1 Opened\",}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":590,"y":320,"wires":[[]]},{"id":"42569d52.aa50b4","type":"api-call-service","z":"5b724328.7e27ec","name":"Notify Office Google Mini","server":"f70a8bc3.ce4fe8","version":1,"debugenabled":false,"service_domain":"tts","service":"google_say","entityId":"media_player.office_speaker","data":"{\"message\":\"Guest Bedroom Window 1 Opened\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":590,"y":400,"wires":[[]]},{"id":"a88e15f5.aa0978","type":"server-state-changed","z":"5b724328.7e27ec","name":"Guest Bedroom Window 1 Opened","server":"f70a8bc3.ce4fe8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.wyze_guestbed_window_one","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":160,"y":100,"wires":[["b05fd6da.02be88","24557b4b.9c2ed4","8119622a.a5f2","6bb9d99e.7f6b18","42569d52.aa50b4","edec98aa.273268"],[]]},{"id":"f70a8bc3.ce4fe8","type":"server","z":"","name":"Home Assistant","addon":true}]

flow

1 Like

Sure, it gets easier if you have some kind of common naming. Then you can just use the get_entities node and filter for the windows that are open.

You’ll want to create a group for your windows and use the state of the group as your trigger, then use the get entities node to determine which ones in your group are open.

I do something similar for my thermostats, when a door/window is left open for 5 minutes it turns off the thermostats and sends a notification via pushover with which doors/windows are open.

[{"id":"42442f06.7b14f","type":"server-state-changed","z":"5ddddd21.00d204","name":"Door/Window Open","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"group.doors_windows","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":110,"y":1500,"wires":[["5cb1066a.159528"]]},{"id":"5cb1066a.159528","type":"switch","z":"5ddddd21.00d204","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":1500,"wires":[["92868919.54d7a8"],["a13066de.6decb8"]]},{"id":"92868919.54d7a8","type":"stoptimer","z":"5ddddd21.00d204","duration":"5","units":"Minute","payloadtype":"num","payloadval":"0","name":"5 Minutes","x":580,"y":1500,"wires":[["81951836.f6f138"],[]]},{"id":"a13066de.6decb8","type":"change","z":"5ddddd21.00d204","name":"Stop Timer","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":1560,"wires":[["92868919.54d7a8","a154c077.9126e"]]},{"id":"3bfdd611.5a426a","type":"api-call-service","z":"5ddddd21.00d204","name":"Door/Window Open","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.door_open","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1030,"y":1500,"wires":[["3b2966e7.564c1a"]]},{"id":"a154c077.9126e","type":"api-call-service","z":"5ddddd21.00d204","name":"Door/Window Closed","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.door_open","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":800,"y":1560,"wires":[[]]},{"id":"81951836.f6f138","type":"api-call-service","z":"5ddddd21.00d204","name":"Turn Off Thermostats","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"climate","service":"turn_off","entityId":"climate.daikinap97021, climate.thermostat_bathroom, climate.thermostat_dining_room, climate.thermostat_downstairs_bathroom, climate.thermostat_entrance, climate.thermostat_gym, climate.thermostat_haileys_room, climate.thermostat_kitchen, climate.thermostat_living_room_2, climate.thermostat_master_bathroom, climate.thermostat_master_bedroom, climate.thermostat_play_room, climate.thermostat_spare_bedroom, climate.thermostat_storage, climate.thermostat_theatre, climate.thermostat_living_room_1","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":800,"y":1500,"wires":[["3bfdd611.5a426a"]]},{"id":"3b2966e7.564c1a","type":"ha-get-entities","z":"5ddddd21.00d204","server":"94fdcfdf.a00b","name":"Which Doors/Windows?","rules":[{"property":"entity_id","logic":"in_group","value":"group.doors_windows","valueType":"str"},{"property":"state","logic":"includes","value":"on, open","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":1270,"y":1500,"wires":[["e0d33504.13ee68"]]},{"id":"e0d33504.13ee68","type":"template","z":"5ddddd21.00d204","name":"Format Msg","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.attributes.friendly_name}}","output":"str","x":1470,"y":1500,"wires":[["ce669e51.69747"]]},{"id":"ce669e51.69747","type":"join","z":"5ddddd21.00d204","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1610,"y":1500,"wires":[["85ccf662.f8c1e8"]]},{"id":"85ccf662.f8c1e8","type":"api-call-service","z":"5ddddd21.00d204","name":"Notify","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"notify","service":"pushover","entityId":"","data":"{\"message\":\"{{payload}} left open for 5 minutes. Thermostats turned off\",\"title\":\"Temperature\",\"data\":{\"priority\":0,\"sound\":\"pianobar\"}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1750,"y":1500,"wires":[[]]},{"id":"94fdcfdf.a00b","type":"server","z":"","name":"Home Assistant","addon":true}]
2 Likes

This is great btw! So I have a question maybe you or others can answer. My door sensors don’t report on/off or open/closed. They report 22/23. These are the recessed Zwave sensors. Was curious if that changes any of the grouping of devices or if there is a way to change the response to on/off or open/closed.

You could easily use a template sensor to get on/off

1 Like

Well that did not work. :frowning: The zwave door sensor shows up in HA as sensor.patio_door_sensor and you cannot associate “door” or “window” as a device_class to a sensor object. Thoughts?