NodeRed: Help with Flow that Will Lock Doors at night based on Time Trigger

Hi folks,

I’ve implemented a flow that is obviously not working. Despite my geofence via the iOS companion app being rock solid, doors will lock and garage doors will shut while I’m at home. Essentially, my flow is ignoring my EZTimer initiation, and simply shutting things if they’re in an open/unlock state throughout the day.

Why is this not working right?

[{"id":"46f5119a.743498","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"aa2ca71d.d6db68","type":"api-current-state","z":"46f5119a.743498","name":"Karson Home?","server":"e204944a.31bc78","version":1,"outputs":2,"halt_if":"home","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"device_tracker.karsons_iphone","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":954.5714721679688,"y":294.5714416503906,"wires":[[],["1d9990cf.a4636f"]]},{"id":"a0c78676.6ac618","type":"server-state-changed","z":"46f5119a.743498","name":"Karson Location","server":"e204944a.31bc78","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.karsons_iphone","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":679.5714416503906,"y":194.35479736328125,"wires":[["aa2ca71d.d6db68"]]},{"id":"a423502f.a60a2","type":"api-call-service","z":"46f5119a.743498","name":"Lock Front Door","server":"e204944a.31bc78","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.front_door_schlage_allegion_be469zp_connect_smart_deadbolt_locked","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1586.2857856750488,"y":510.0000057220459,"wires":[[]]},{"id":"bf3df078.d6e8","type":"api-call-service","z":"46f5119a.743498","name":"Close Main Garage Door","server":"e204944a.31bc78","version":1,"debugenabled":false,"service_domain":"cover","service":"close_cover","entityId":"cover.main_stall_garage_door","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1616.2857856750488,"y":190.0000057220459,"wires":[[]]},{"id":"3fae4c6.42fa4b4","type":"api-call-service","z":"46f5119a.743498","name":"Close 3rd Stall Garage Door","server":"e204944a.31bc78","version":1,"debugenabled":false,"service_domain":"cover","service":"close_cover","entityId":"cover.3rd_stall_garage_door","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1626.2857856750488,"y":310.0000057220459,"wires":[[]]},{"id":"7ff1da0d.d31a5c","type":"api-call-service","z":"46f5119a.743498","name":"Lock Back Door","server":"e204944a.31bc78","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.back_door_schlage_allegion_be469zp_connect_smart_deadbolt_locked","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1586.2857856750488,"y":410.0000057220459,"wires":[[]]},{"id":"1d9990cf.a4636f","type":"switch","z":"46f5119a.743498","name":"Motion or No Motion?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1254.8572387695312,"y":297.1428909301758,"wires":[[],["bf3df078.d6e8","3fae4c6.42fa4b4","7ff1da0d.d31a5c","a423502f.a60a2"]]},{"id":"63587b8c.823a9c","type":"switch","z":"46f5119a.743498","name":"Execute Flow","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":376.0000991821289,"y":288.8572292327881,"wires":[["aa2ca71d.d6db68"]]},{"id":"dc57768e.48c498","type":"server-state-changed","z":"46f5119a.743498","name":"Kitchen Motion Sensor","server":"e204944a.31bc78","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kitchen_ecolink_motion_detector_sensor","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":1049.1429595947266,"y":186.14290618896484,"wires":[["1d9990cf.a4636f"]]},{"id":"7368526b.37754c","type":"eztimer","z":"46f5119a.743498","name":"10PM","autoname":"22:00","suspended":false,"sendEventsOnSuspend":false,"lat":"42.034534","lon":"-93.620369","timerType":"2","startupMessage":false,"ontype":"2","ontimesun":"dawn","ontimetod":"22:00","onproperty":"payload","onvaluetype":"num","onvalue":1,"onoffset":0,"onrandomoffset":0,"offtype":"1","offtimesun":"dusk","offtimetod":"dusk","offduration":0,"offproperty":"payload","offvaluetype":"num","offvalue":0,"offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":160.28582000732422,"y":289.14295291900635,"wires":[["63587b8c.823a9c"]]},{"id":"e204944a.31bc78","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Both of the event state nodes (Karson location and kitchen motion sensor) are triggering the flow.

So I could use an “Event State” node instead, too, but what I’m running into is the time condition, as well.

The flow seems more complicated than it needs to be. You just need the eztimer node set to the time you want, a current state node to see if you are home, and the call service nodes to perform the actions.

This is my flow for auto-locking doors after a timeout. It works in tandem with my presence flow that locks/unlocks doors upon my wife or I leaving or arriving home. Since you’ve got the presence part done, this should solve your wait issues.

[{"id":"400f2ede.c894c8","type":"tab","label":"Locks","disabled":false,"info":""},{"id":"a936acc.ff47e5","type":"server-state-changed","z":"400f2ede.c894c8","name":"Front Door Lock","server":"df8e6220.fa7b2","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"lock.front_door_lock","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"unlocked","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":180,"y":220,"wires":[["ec26b4a9.7a2058","ad1559aa.eaca18"],["ad1559aa.eaca18"]]},{"id":"9183bf76.c43318","type":"server-state-changed","z":"400f2ede.c894c8","name":"Back Door Lock","server":"df8e6220.fa7b2","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"lock.back_door_lock","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"unlocked","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":180,"y":420,"wires":[["6e4fce0a.81d4d8","cefde665.218be8"],["cefde665.218be8"]]},{"id":"ec26b4a9.7a2058","type":"ha-wait-until","z":"400f2ede.c894c8","name":"Wait for Door to Open","server":"df8e6220.fa7b2","outputs":2,"entityId":"binary_sensor.front_door_contact_sensor","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"5","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"lock_payload","entityLocationType":"msg","checkCurrentState":true,"blockInputOverrides":true,"x":440,"y":160,"wires":[[],["9c88c826.8bd7c8"]]},{"id":"9c88c826.8bd7c8","type":"api-call-service","z":"400f2ede.c894c8","name":"Lock Door","server":"df8e6220.fa7b2","version":1,"debugenabled":true,"service_domain":"lock","service":"lock","entityId":"lock.front_door_lock","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":160,"wires":[[]]},{"id":"6e4fce0a.81d4d8","type":"ha-wait-until","z":"400f2ede.c894c8","name":"Wait for Door to Open","server":"df8e6220.fa7b2","outputs":2,"entityId":"binary_sensor.back_door_contact_sensor","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"1","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"lock_payload","entityLocationType":"msg","checkCurrentState":true,"blockInputOverrides":true,"x":420,"y":360,"wires":[[],["6b34fed7.a4859"]]},{"id":"6b34fed7.a4859","type":"api-call-service","z":"400f2ede.c894c8","name":"Lock Door","server":"df8e6220.fa7b2","version":1,"debugenabled":true,"service_domain":"lock","service":"lock","entityId":"lock.back_door_lock","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":690,"y":360,"wires":[[]]},{"id":"468ceaff.4dfcdc","type":"api-call-service","z":"400f2ede.c894c8","name":"Notify","server":"df8e6220.fa7b2","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":690,"y":220,"wires":[[]]},{"id":"ad1559aa.eaca18","type":"function","z":"400f2ede.c894c8","name":"Prepare Notification","func":"var theMessage;\n\nif(msg.payload == 'unlocked') {\n theMessage = \"The front door has been unlocked.\"\n}\nelse {\n theMessage = \"The front door has been locked.\"\n}\n\nmsg.payload = {\n domain: 'tts',\n service: 'google_translate_say',\n data: {\n entity_id: 'media_player.living_room_display',\n message: theMessage\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":220,"wires":[["468ceaff.4dfcdc"]]},{"id":"807afcfa.836a7","type":"api-call-service","z":"400f2ede.c894c8","name":"Notify","server":"df8e6220.fa7b2","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":670,"y":420,"wires":[[]]},{"id":"cefde665.218be8","type":"function","z":"400f2ede.c894c8","name":"Prepare Notification","func":"var theMessage;\n\nif(msg.payload == 'unlocked') {\n theMessage = \"The back door has been unlocked.\"\n}\nelse {\n theMessage = \"The back door has been locked.\"\n}\n\nmsg.payload = {\n domain: 'tts',\n service: 'google_translate_say',\n data: {\n entity_id: 'media_player.kitchen_display',\n message: theMessage\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":420,"wires":[["807afcfa.836a7"]]},{"id":"70153707.d3332","type":"server-state-changed","z":"400f2ede.c894c8","name":"Front Door","server":"df8e6220.fa7b2","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.front_door_contact_sensor","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":540,"wires":[[],["a7d1f4e7.ef7788"]]},{"id":"6e7d759f.65976c","type":"server-state-changed","z":"400f2ede.c894c8","name":"Back Door","server":"df8e6220.fa7b2","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.back_door_contact_sensor","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":660,"wires":[[],["da33bf7.f65e4c"]]},{"id":"fb9e202f.f0fa1","type":"debug","z":"400f2ede.c894c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":600,"wires":[]},{"id":"da33bf7.f65e4c","type":"api-call-service","z":"400f2ede.c894c8","name":"Lock Door","server":"df8e6220.fa7b2","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.back_door_lock","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":390,"y":660,"wires":[["fb9e202f.f0fa1"]]},{"id":"a7d1f4e7.ef7788","type":"api-call-service","z":"400f2ede.c894c8","name":"Lock Door","server":"df8e6220.fa7b2","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.front_door_lock","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":390,"y":540,"wires":[["fb9e202f.f0fa1"]]},{"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}]