Presence detection and evaluate MQTT value

I am using a zone node to detect when my wife or I return home to open our garage door.I am reading the garage door status via an MQTT input node in node red.
I’m having trouble figuring out how to only trigger the garage door to open if it ISN’T already open.
Since the garage door opener just uses a contact closure, if it is already open another signal will cause it to close.

Use the Trigger node and add constraint to check if door is open

Screen Shot 2020-11-14 at 4.26.56 PM

[{"id":"b9423523.5946a8","type":"trigger-state","z":"25063fae.4f85f","name":"Garage door","server":"8a3231e1.3f0e1","entityid":"cover.garage_door_opener","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"t686l5xouuq","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"open"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":1713.333333333333,"y":1181.6666666666665,"wires":[["642ebe9f.203a7"],[]]},{"id":"642ebe9f.203a7","type":"debug","z":"25063fae.4f85f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1908.3332443237305,"y":1174.999963760376,"wires":[]},{"id":"f8d3ac55.78327","type":"mqtt in","z":"25063fae.4f85f","name":"","topic":"topic/garage","qos":"2","datatype":"auto","broker":"af5ffd55.99c9b","x":1515.0000228881836,"y":1181.666835784912,"wires":[["b9423523.5946a8"]]},{"id":"8a3231e1.3f0e1","type":"server","name":"Hassio","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false},{"id":"af5ffd55.99c9b","type":"mqtt-broker","name":"Hassio Broker","broker":"","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

bastero Thank you for your help!

I’m afraid I’m still not quite ‘getting it’. I’ve never set up a “Trigger” node before. And I’m not sure where the ‘command’ from the Zone node comes into pass it through if the door is not already open and to not send it if the door is already open.

@Perseids I’m not sure I understand your statement "the ‘command’ from the Zone node comes into play" What is the ‘zone’ node you are referring to?

Forgive me if I say something that’s obvious… In the example posed, let’s assume that your subscribe node has a topic: ‘topic/garage/STATE’ and that when your open/close switch is activated for the door to open, the MQTT broker publishes on the same topic i.e ‘topic/garage/STATE’ an ‘ON’ as a ‘payload’.

This payload will trigger the 'Trigger" node (provided it is configured to trigger on an ON), in addition the trigger node will also evaluate if you have defined additional constraints before determining the output.

Part of configuring the ‘Trigger’ node requires that you add these constraints for evaluation. In your case this is to check that the door sensor (i.e. binary sensor) is not already in an open state. Hope this helps.

You need to setup a mqtt node that saves it state to a variable then check that variable in your zone flow.


[{"id":"eb0b8258.05b51","type":"mqtt in","z":"ffbd7f06.4a014","name":"","topic":"/sensor/garage_door","qos":"2","datatype":"auto","broker":"644903cf.1e7dbc","x":232,"y":1952,"wires":[["1a912cc6.5d0273"]]},{"id":"1a912cc6.5d0273","type":"change","z":"ffbd7f06.4a014","name":"","rules":[{"t":"set","p":"garageDoorStatus","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":472,"y":1952,"wires":[[]]},{"id":"bd381976.e6f3e8","type":"ha-zone","z":"ffbd7f06.4a014","server":"2dad33ee.42bf5c","name":"","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entities":["person.person1","person.person2"],"event":"enter","zones":["home"],"x":194,"y":2000,"wires":[["3fe1e9b3.de7b96"]]},{"id":"3fe1e9b3.de7b96","type":"switch","z":"ffbd7f06.4a014","name":"Garage Door Open?","property":"garageDoorStatus","propertyType":"flow","rules":[{"t":"eq","v":"closed","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":372,"y":2000,"wires":[["ccd3742c.636d28"]]},{"id":"ccd3742c.636d28","type":"debug","z":"ffbd7f06.4a014","name":"Open Garage Door","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":2000,"wires":[]}]

Kermit, that is exactly what I was needing! I need to keep fiddling with and learning NodeRed. Some(much) of it is still confusing to me and I have a background in industrial control logic! lol

With 2 entities in the Zone node config, does that mean that either device tracker will activate the node or do both have to enter the Zone?

Juan, The below addressed my issue I believe.
Thank you for your help as well!

Glad @Kermit was able to help. Out of curiosity when did you install the zone node from? I can’t see it in the Pallet manager.

It is in the “Home Assistant” group of nodes.

It seems like everything I try to do presents me with a new roadblock.
I’m sure it is simple, but how can I take the MQTT value of my garage door being open(1 in this case) and represent that graphically in the UI?

That’s interesting… it’s not in mine. Thanks!

@bastero wow, that is weird.


Without my email address up there this time… lol

Thanks Jon, you seem to have an extended version of HA nodes :slightly_smiling_face: , I’m running a VM version of HA there may be differences based on HW platforms used not sure though.

You might try downloading and installing the HA palette via “Manage Palette”. Maybe it has been updated since your install.