Garage Door Open Sensor Alert

I’m having a hard time wrapping my head contextually around how to get this to work because I’m so new at Home Assistant and Node-Red. I have several other automations running with node red and I love it.

The first node is an events state node checking to see the status of the garage door sensor. If it’s open/“on” it sends it to the check entity node which is a simple boolean seeing if we are home or not which is based upon Life360 prescense detection etc…It’s just a simple boolean, but this is where the hang up is.

Typically we are home when we open the garage door, so we open the garage door, but we are still at home so it stops at the second node. I can’t figure out in my head how to get this to report once we LEAVE the house and that input boolean for Home Occupied turns off. Get entity state only updates one time and not continuously. I’ve tried flipping the first two to where it first checks to see if we are away from the house first before checking the status of the door, but it never fires off properly. One node I think would solve it is ‘poll state’ and set it to every so often, but it doesn’t accept any inputs, only outputs.

Any thoughts? This seems pretty simple but I for some reason can’t get the flow to work. https://imgur.com/a/pnDTYJg

What if you put a 5 min delay between the first and second node? If you opened the garage and were still home, the process would stop; if you opened the garage and left within 5 min (and Life360 updated you to ‘away’ within that time), it should continue the flow.

Trigger state node that fires when the garage door changes or the home input boolean changes. Then constraints to check if each entity state is valid.

[{"id":"98c7a0e7.fcec1","type":"trigger-state","z":"fac037bf.a42d78","name":"Garage Door Open/Away","entityid":"sensor.garagedoor,input_boolean.home_empty","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"id":"p86n1c79c48","targetType":"entity_id","targetValue":"sensor.garagedoor","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"id":"n01nnkl1a0l","targetType":"entity_id","targetValue":"input_boolean.home_empty","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"id":"c3qle2tykwl","targetType":"entity_id","targetValue":"input_boolean.house_guests","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":190,"y":1360,"wires":[["4c5febc.34ef014"],["2ba7a4e1.2598ac"]]},{"id":"4c5febc.34ef014","type":"trigger","z":"fac037bf.a42d78","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-60","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":554,"y":1360,"wires":[["135d46ba.596d39"]]},{"id":"2ba7a4e1.2598ac","type":"change","z":"fac037bf.a42d78","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":386,"y":1408,"wires":[["4c5febc.34ef014"]]},{"id":"135d46ba.596d39","type":"api-call-service","z":"fac037bf.a42d78","name":"Send Telegram Msg","version":1,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":788,"y":1360,"wires":[[]]}]

Kermit I will look at this some more when I get home, I haven’t yet utilized the Trigger state node yet. This looks more elegant than what I came up with last night which is posted below.

One question I do have about the ‘code’ that gets posted for Node-Red, can I just go to ‘import’ clipboard and it will show up as a sequence in my current flow I’m working in?

That’s exactly why nice people post it!

I have an automation set up to SMS my wife and me when we both have left the house and the garage door or front door is unlocked. I have a node watching for state change of both of our location trackers. When either changes to away, it checks to see if the other tracker is also away. If both are away, then it checks the status of the doors. If unlocked / open it then sends both of us a message.

I’ve been working on this and the flow ‘works’. Here’s what I’ve got.

[{"id":"7c18687c.18b038","type":"trigger-state","z":"35b7cd00.03d4a4","name":"Garage Door Open/Away","server":"2b82661b.641baa","entityid":"input_boolean.home","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"id":"c3qle2tykwl","targetType":"entity_id","targetValue":"input_boolean.house_guests","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"},{"id":"qccs5cvot7a","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"},{"id":"ilfbq9q82p","targetType":"entity_id","targetValue":"binary_sensor.wyzesense_778a7bb2","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":170,"y":960,"wires":[["38444a9.45aa4b6"],["937defda.307b9"]]},{"id":"38444a9.45aa4b6","type":"trigger","z":"35b7cd00.03d4a4","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-60","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":534,"y":960,"wires":[["bf7ff37.104031"]]},{"id":"937defda.307b9","type":"change","z":"35b7cd00.03d4a4","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":366,"y":1008,"wires":[["38444a9.45aa4b6"]]},{"id":"bf7ff37.104031","type":"api-call-service","z":"35b7cd00.03d4a4","name":"Send Telegram Msg","server":"2b82661b.641baa","version":1,"service_domain":"telegram_bot","service":"send_message","entityId":"","data":"{      \"title\":\"Garage Door\",    \"message\":\"Main Garage Door is open!\",    \"target\":[redacted, redacted] }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":960,"wires":[[]]},{"id":"2b82661b.641baa","type":"server","z":"","name":"Home Assistant"}]

Unfortunately, I don’t know how to get it to poll continuously. It’s like it looks for the state one time and one time only and then if all the conditions are met, it then starts the flow. For instance if the garage door is then closed but Life360 hasn’t updated that we’re home yet because of a delay, it doesn’t actually stop the flow, it will continuously send messages until our home presence is detected.

Is there a way to have it poll the 3 inputs for changes? House Guests, Home Occupied Boolean, and then my Wyze Door sensor?

Use the events:state instead of the trigger:state node. It will run every time the state changes.

I want notification when garage door is open and when is close in Telegram, but i receve message only garage door is closed.

[{"id":"3dbe2415.fd69bc","type":"tab","label":"Garasjeporten","disabled":false,"info":""},{"id":"e408c2ba.f45d48","type":"telegrambot-notify","z":"3dbe2415.fd69bc","name":"Garasjeporten åpen","bot":"fef8610e.ca254","chatId":"554520354","message":"Garasjeporten er åpen","parseMode":"","x":640,"y":240,"wires":[]},{"id":"9bc5e40a.f9718","type":"server-state-changed","z":"3dbe2415.fd69bc","name":"Garasjeporten","server":"ec284707.210298","version":1,"entityidfilter":"cover.garasjeport","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":170,"y":220,"wires":[["e408c2ba.f45d48"],["ca10cb5c.3f7128"]]},{"id":"ca10cb5c.3f7128","type":"telegrambot-notify","z":"3dbe2415.fd69bc","name":"Grasjeporten lukket","bot":"fef8610e.ca254","chatId":"554520354","message":"Grasjeporten er lukket","parseMode":"","x":630,"y":340,"wires":[]},{"id":"fef8610e.ca254","type":"telegrambot-config","z":"","botname":"sony","usernames":"sony","chatIds":"554520354","pollInterval":"300"},{"id":"ec284707.210298","type":"server","z":"","name":"Home Assistant"}]

@smile I think that you might have solved it by now :slight_smile:
Care2share?

@Letalis Unfortunately not solved :unamused:

You should be able to do something similar to below, I’m using Alexa instead of telegram.

[{"id":"d680dd62.92401","type":"server-state-changed","z":"b6caae64.0d8ea","name":"Has a Gate Opened or Closed","server":"378bb7a2.0cc518","version":1,"entityidfilter":"binary_sensor.*_gate","entityidfiltertype":"regex","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":181.5,"y":163,"wires":[["3e560f70.675c4"],["476f7ab5.1fcdf4"]]},{"id":"eb4ba96a.dae348","type":"api-call-service","z":"b6caae64.0d8ea","name":"Notify via Lounge and Kitchen Alexa","server":"378bb7a2.0cc518","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"message\":\"{{payload}}\",\"data\":{\"type\":\"announce\"},\"target\":[\"media_player.patrick_s_dot\",\"media_player.kitchen_dot\"]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1136.5,"y":245,"wires":[["b80d8e57.d0f06"]]},{"id":"476f7ab5.1fcdf4","type":"template","z":"b6caae64.0d8ea","name":"Get the closed gate name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{data.new_state.attributes.friendly_name}} has closed.","output":"str","x":503,"y":204,"wires":[["ae83e126.75ff1"]]},{"id":"3e560f70.675c4","type":"template","z":"b6caae64.0d8ea","name":"Get the opened gate name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{data.new_state.attributes.friendly_name}} has opened.","output":"str","x":508.5,"y":90,"wires":[["ae83e126.75ff1"]]},{"id":"ae83e126.75ff1","type":"api-current-state","z":"b6caae64.0d8ea","name":"Don't Announce Gate Status","server":"378bb7a2.0cc518","version":1,"outputs":2,"halt_if":"false","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.gate_announcements","state_type":"habool","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":831.5,"y":179,"wires":[[],["fdae6ec2.2217"]]},{"id":"fdae6ec2.2217","type":"delay","z":"b6caae64.0d8ea","name":"Delay 2 Seconds","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1089.5,"y":141,"wires":[["eb4ba96a.dae348"]]},{"id":"378bb7a2.0cc518","type":"server","z":"","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]
1 Like

Here is what I do. This is for the refrigerator. For garage I just have a longer timer period.

Deleted the HA login info, but should still paste in ok, I made sure I could paste it in.

You will need to attach your notification method (I use email-text and just added alexa notification) to the top output of the timer

[{"id":"51075d27.5a8654","type":"server-state-changed","z":"be7e827c.1443b","name":"fridge door open","server":"6b7c71f.47a699","entityidfilter":"binary_sensor.fridge_door_open","entityidfiltertype":"substring","haltifstate":"","x":131,"y":73,"wires":[["828a3e55.2e6eb"]],"outputLabels":["\"on\""]},{"id":"cf11d11.6ddc43","type":"stoptimer","z":"be7e827c.1443b","duration":"90","units":"Second","payloadtype":"num","payloadval":"0","name":"Timer","x":521,"y":73,"wires":[["2c324c03.06cbd4","dfde3a29.5389b8"],[]]},{"id":"828a3e55.2e6eb","type":"switch","z":"be7e827c.1443b","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":301,"y":73,"wires":[["cf11d11.6ddc43"],["1999af30.abfd31"]]},{"id":"1999af30.abfd31","type":"function","z":"be7e827c.1443b","name":"Stop Timer","func":"var newMsg = { payload: \"stop\"};\nreturn newMsg;","outputs":1,"noerr":0,"x":401,"y":133,"wires":[["cf11d11.6ddc43"]]},{"id":"6b7c71f.47a699","type":"server","z":""}]

I added some more logic to my door open alert. If the door is open long enough to send an alert, it will also send a message when the door is closed. Change out the debug nodes with your message sender after you confirm it works.

[{"id":"cb7049bc.fea488","type":"server-state-changed","z":"fda7c812.18d0e8","name":"fridge door open","server":"6b7c71f.47a699","entityidfilter":"binary_sensor.fridge_door_open","entityidfiltertype":"substring","haltifstate":"","x":101,"y":50,"wires":[["ff345c30.92371"]],"outputLabels":["\"on\""]},{"id":"e27d8ad2.1a5e88","type":"stoptimer","z":"fda7c812.18d0e8","duration":"5","units":"Second","payloadtype":"num","payloadval":"0","name":"Timer","x":509,"y":50,"wires":[["1406769d.eeb809","18484074.1cd22"],[]]},{"id":"ff345c30.92371","type":"switch","z":"fda7c812.18d0e8","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":297,"y":60,"wires":[["e27d8ad2.1a5e88","fe390d8a.563f5"],["631699c8.8bafb8"]]},{"id":"1406769d.eeb809","type":"function","z":"fda7c812.18d0e8","name":"Set Fridge Door Open","func":"// Setup flow variable for if door open\nvar LocalFlag4 = flow.get('FridgeDoor');\nLocalFlag4 = true;\nflow.set(\"FridgeDoor\",LocalFlag4);\nreturn;\n","outputs":2,"noerr":0,"x":718,"y":29,"wires":[[],[]]},{"id":"18484074.1cd22","type":"debug","z":"fda7c812.18d0e8","name":"Door Open message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":827.5,"y":66,"wires":[]},{"id":"631699c8.8bafb8","type":"function","z":"fda7c812.18d0e8","name":"Stop Timer","func":"var newMsg = { payload: \"stop\"};\nvar LocalFlag2 = flow.get('FridgeDoor');\nif (LocalFlag2===true) {\n    LocalFlag2 = false;\n    flow.set(\"FridgeDoor\",LocalFlag2);\n    return [newMsg, newMsg];\n}\nelse \n    return [newMsg, null];\n","outputs":2,"noerr":0,"x":419,"y":96,"wires":[["e27d8ad2.1a5e88","9d38b421.9e5398"],[]]},{"id":"9d38b421.9e5398","type":"debug","z":"fda7c812.18d0e8","name":"Door Closed message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":624,"y":104,"wires":[]},{"id":"fe390d8a.563f5","type":"function","z":"fda7c812.18d0e8","name":"Set Door Closed","func":"// Setup flow variable for if door open\nvar LocalFlag5 = flow.get('FridgeDoor');\nLocalFlag5 = false;\nflow.set(\"FridgeDoor\",LocalFlag5);\nreturn;\n","outputs":2,"noerr":0,"x":423,"y":21,"wires":[[],[]]}]

Mistake in previous version, I connected the door closed message to wrong dot

[{"id":"e76072dc.71e4f","type":"server-state-changed","z":"fda7c812.18d0e8","name":"fridge door open","server":"6b7c71f.47a699","entityidfilter":"binary_sensor.fridge_door_open","entityidfiltertype":"substring","haltifstate":"","x":85,"y":1299,"wires":[["14edc6d7.2532c9"]],"outputLabels":["\"on\""]},{"id":"98909b98.fe7db8","type":"stoptimer","z":"fda7c812.18d0e8","duration":"5","units":"Second","payloadtype":"num","payloadval":"0","name":"Timer","x":493,"y":1299,"wires":[["4b0fe98f.9ad608","a2acb1fa.fab5d"],[]]},{"id":"14edc6d7.2532c9","type":"switch","z":"fda7c812.18d0e8","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":281,"y":1309,"wires":[["98909b98.fe7db8","502d7708.c5f1d8"],["c52a1a59.4d4388"]]},{"id":"4b0fe98f.9ad608","type":"function","z":"fda7c812.18d0e8","name":"Set Fridge Door Open","func":"// Setup flow variable for if door open\nvar LocalFlag4 = flow.get('FridgeDoor');\nLocalFlag4 = true;\nflow.set(\"FridgeDoor\",LocalFlag4);\nreturn;\n","outputs":2,"noerr":0,"x":702,"y":1278,"wires":[[],[]]},{"id":"a2acb1fa.fab5d","type":"debug","z":"fda7c812.18d0e8","name":"Door Open message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":811.5,"y":1315,"wires":[]},{"id":"c52a1a59.4d4388","type":"function","z":"fda7c812.18d0e8","name":"Stop Timer","func":"var newMsg = { payload: \"stop\"};\nvar LocalFlag2 = flow.get('FridgeDoor');\nif (LocalFlag2===true) {\n    LocalFlag2 = false;\n    flow.set(\"FridgeDoor\",LocalFlag2);\n    return [newMsg, newMsg];\n}\nelse \n    return [newMsg, null];\n","outputs":2,"noerr":0,"x":403,"y":1345,"wires":[["98909b98.fe7db8"],["110c08ee.041567"]]},{"id":"110c08ee.041567","type":"debug","z":"fda7c812.18d0e8","name":"Door Closed message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":608,"y":1353,"wires":[]},{"id":"502d7708.c5f1d8","type":"function","z":"fda7c812.18d0e8","name":"Set Door Closed","func":"// Setup flow variable for if door open\nvar LocalFlag5 = flow.get('FridgeDoor');\nLocalFlag5 = false;\nflow.set(\"FridgeDoor\",LocalFlag5);\nreturn;\n","outputs":2,"noerr":0,"x":407,"y":1270,"wires":[[],[]]}]

Hi, I’ve found your generously shared code and trying to apply it to my Garage Door but am no programmer. I am trying to edit the function node and having 2 issues:

  1. You reference in an edit function node a variable ‘FridgeDoor’ but I have no idea how I reference my garage door in its place. What do I need to do to this?
  2. When I try and edit the text in the Properties tab of the edit function node, my text is not editable. I cannot change it. Is it calling a sub-flow or something else I am missing?
    Would very much just like to get your flow rec working.
    Can you help please?
    Many thanks.
  1. That’s just a variable, it can be any name. But I use in all three function nodes, it has to be exactly the same in all instances or it won’t work.
    That variable doesn’t matter, the input to start this flow needs to be a binary sensor coming from Home Assistant that changes state when your garage door opens/closes.
  2. No idea when you can’t edit it. Can you create a new function node, and edit that? If so, you can make a new one and copy the code into it.

Randy

Thanks for replying Randy.
As for issue #2… appears I am not alone in this regard. Went down a rabbit hole on the Node Red forums about browser compatibility etc. only to find the answer right here… Unable to edit function node - #4 by Biscuit

Hi Patrick… noob question… what type of input boolean have you created and if it’s not a simple toggle, what are the values?
Thanks for your time.

Hi Euromem,
No hassle whatsoever, this is how you learn and become proficient.
This is my input boolean is HA’s yaml file. It is a simple on off boolean to announce the gate status or not.

gate_announcements:
  name: Gate Announcements
#  initial: on
  icon: mdi:speaker-wireless
1 Like