Struggling to map out an HVAC alert

This will likely reek of newb, so thanks for your patience here!

My goal is:
If any of 6 different door contacts are open and the HVAC is running, wait 2 minutes, send alert to Alexa saying which doors are open, and then loop every 5 minutes doing the same until everything is closed or the HVAC is off.

Any ideas?

I don’t have any door sensors so this is just a basic sketch.
I have made placeholders for three doors, you have to check each node, as I said I don’t have door sensors so I just guessed the states.

But it triggers on any of them and calls the state on all of them.
If they are open then the message will be changed to the door name.

I join the messages with comma and pass it to the function node that creates the message which the call service node speaks out.

I don’t have any way of testing it, and I have high hopes that I messed something up, but it should give you a start.

Either I’m completely clueless or you forgot the sketch.

See… I messed up even worse than expected…
Just a minute…

[{"id":"8c584b08.bd73d8","type":"trigger-state","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.door1","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":1310,"y":120,"wires":[["f29455a9.40fde8"],["f29455a9.40fde8"]]},{"id":"99e89d2f.991b2","type":"trigger-state","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.door2","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":1310,"y":180,"wires":[["2064361a.76f14a"],["2064361a.76f14a"]]},{"id":"73c9c52a.6920ec","type":"trigger-state","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.door3","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":1310,"y":240,"wires":[["6c55abeb.a2e9f4"],["6c55abeb.a2e9f4"]]},{"id":"f29455a9.40fde8","type":"ha-wait-until","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","outputs":2,"entityId":"sensor.door1","entityIdFilterType":"exact","property":"state","comparator":"is","value":"closed","valueType":"str","timeout":"2","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1520,"y":120,"wires":[["74157009.546fe","8d6ae22.6efad2","5d64fac6.b4b204"],[]]},{"id":"2064361a.76f14a","type":"ha-wait-until","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","outputs":2,"entityId":"sensor.door2","entityIdFilterType":"exact","property":"state","comparator":"is","value":"closed","valueType":"str","timeout":"2","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1520,"y":180,"wires":[["74157009.546fe","8d6ae22.6efad2","5d64fac6.b4b204"],[]]},{"id":"6c55abeb.a2e9f4","type":"ha-wait-until","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","outputs":2,"entityId":"sensor.door3","entityIdFilterType":"exact","property":"state","comparator":"is","value":"closed","valueType":"str","timeout":"2","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1520,"y":240,"wires":[["5d64fac6.b4b204","8d6ae22.6efad2","74157009.546fe"],[]]},{"id":"74157009.546fe","type":"api-current-state","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","version":1,"outputs":2,"halt_if":"open","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.door1","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1800,"y":120,"wires":[["207f4b28.ef4af4"],[]]},{"id":"8d6ae22.6efad2","type":"api-current-state","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","version":1,"outputs":2,"halt_if":"open","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.door2","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1800,"y":180,"wires":[["d9200e96.e9b4d"],[]]},{"id":"5d64fac6.b4b204","type":"api-current-state","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","version":1,"outputs":2,"halt_if":"open","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.door3","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1800,"y":240,"wires":[["6eb32774.f3c7c8"],[]]},{"id":"497f715d.6e23e","type":"join","z":"2227cef1.c55b22","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"10","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2350,"y":160,"wires":[["69b10b26.d41934"]]},{"id":"a28cf90e.0151c8","type":"api-call-service","z":"2227cef1.c55b22","name":"","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.SOME_PLAYER","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2740,"y":160,"wires":[[]]},{"id":"69b10b26.d41934","type":"function","z":"2227cef1.c55b22","name":"","func":"msg.payload = {\n    data:{\n    \"message\": msg.payload\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2520,"y":160,"wires":[["a28cf90e.0151c8"]]},{"id":"207f4b28.ef4af4","type":"change","z":"2227cef1.c55b22","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"door1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2060,"y":120,"wires":[["497f715d.6e23e"]]},{"id":"d9200e96.e9b4d","type":"change","z":"2227cef1.c55b22","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"door2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2060,"y":180,"wires":[["497f715d.6e23e"]]},{"id":"6eb32774.f3c7c8","type":"change","z":"2227cef1.c55b22","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"door3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2060,"y":240,"wires":[["497f715d.6e23e"]]},{"id":"4bbca37b.1700ec","type":"server","z":"","name":"Home Assistant","addon":true}]
1 Like

There’s a few different ways to attack this. My preferred method is to use a group with the contact sensors.

First, create a group in HA and add all 6 door contact sensors to it (remember to reload your groups after you create the group!)

From there, it’s pretty easy: Use an inject node with a 5 minute interval. Then, 2 current state nodes, 1 for the doors group and 1 for your HVAC. Then, a trigger with a delay of 2 minutes. Then just send an alert to Alexa or anything else. You can also do this with a get entities node and look for contact sensors, but I like a group because I have both interior and exterior contact sensors.

[{"id":"86354976.01c398","type":"inject","z":"b3dcf049.35f5e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":580,"wires":[["67bbbd61.645634"]]},{"id":"67bbbd61.645634","type":"api-current-state","z":"b3dcf049.35f5e","name":"Door Sensors","server":"df8e6220.fa7b2","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.door_contact_sensors","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":400,"y":580,"wires":[["9bc46a44.7566b"],[]]},{"id":"9bc46a44.7566b","type":"api-current-state","z":"b3dcf049.35f5e","name":"HVAC On","server":"df8e6220.fa7b2","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"climate.home_thermostat","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":640,"y":580,"wires":[["61a6740b.b598c4"],[]]},{"id":"61a6740b.b598c4","type":"trigger","z":"b3dcf049.35f5e","name":"2 Minute Wait","op1":"","op2":"true","op1type":"nul","op2type":"bool","duration":"2","extend":true,"units":"min","reset":"off","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":580,"wires":[["70e83150.5d3108"]]},{"id":"df8e6220.fa7b2","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

1 Like

I forgot your requirement about reporting which doors are open. For this, I used a get entities node to look for open doors in the door_contact_sensors group.

[{"id":"86354976.01c398","type":"inject","z":"b3dcf049.35f5e","name":"Every 5 Minutes","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":580,"wires":[["a44af7ff.6cbd6"]]},{"id":"9bc46a44.7566b","type":"api-current-state","z":"b3dcf049.35f5e","name":"HVAC On","server":"df8e6220.fa7b2","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"climate.home_thermostat","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":800,"y":580,"wires":[[],["61a6740b.b598c4"]]},{"id":"61a6740b.b598c4","type":"trigger","z":"b3dcf049.35f5e","name":"2 Minute Wait","op1":"","op2":"true","op1type":"nul","op2type":"bool","duration":"2","extend":true,"units":"min","reset":"off","bytopic":"all","topic":"topic","outputs":1,"x":1000,"y":580,"wires":[[]]},{"id":"a44af7ff.6cbd6","type":"ha-get-entities","z":"b3dcf049.35f5e","server":"df8e6220.fa7b2","name":"","rules":[{"property":"entity_id","logic":"in_group","value":"group.door_contact_sensors","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":390,"y":580,"wires":[["cc4e0e55.c12c58"]]},{"id":"cc4e0e55.c12c58","type":"function","z":"b3dcf049.35f5e","name":"Create message","func":"function join_array(array, join, finalJoin) {\n var arr = array.slice(0), last = arr.pop();\n join = join || ', ';\n finalJoin = finalJoin || ' and ';\n return arr.join(join) + finalJoin + last; \n}\n\n\n\nvar output_message = \"This is an alert. The following doors have been left open. \"\nvar doors = msg.payload\nvar door_names = []\n\nfor(i = 0; i < doors.length; i++) {\n door_names.push(doors[i].attributes.friendly_name.replace(\" Contact Sensor\", \"\"))\n}\n\noutput_message += join_array(door_names)\n\nmsg.message = output_message\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":580,"wires":[["9bc46a44.7566b"]]},{"id":"df8e6220.fa7b2","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false}]

1 Like