For BLE detection, I’ve found it’s not any faster than Bluetooth Classic, but faster than wifi. Usually under 5 secs. I need BLE beacons because I don’t have power in all areas. My phone travels with me. I use either Pi Zero W room-assistant (in powered areas) or beacons (unpowered areas).
Here’s the node red sequence that is triggered when I approach the house. I call it Mailbox presence because there’s a beacon in my mailbox:
[{"id":"5ce3563e.767548","type":"server-state-changed","z":"bfbf53.2cf9e0b","name":"Entered Mailbox region/zone","server":"6493570e.9de338","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.owntracks_iphone","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"Mailbox","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":140,"y":180,"wires":[["9b110f90.4fede"],[]]},{"id":"9b110f90.4fede","type":"switch","z":"bfbf53.2cf9e0b","name":"did_leave_home?","property":"did_leave_home","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":180,"wires":[["a9584a00.988088"],[]]},{"id":"a9584a00.988088","type":"api-current-state","z":"bfbf53.2cf9e0b","name":"Get in_test bool","server":"6493570e.9de338","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.in_test_mailbox","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":275,"y":260,"wires":[["9b6a9001.1b6b3"]]},{"id":"9b6a9001.1b6b3","type":"switch","z":"bfbf53.2cf9e0b","name":"in test mode?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":455,"y":260,"wires":[["3269fd53.cd0592","de9958ea.e049f8"],["2865862.66b057a","de9958ea.e049f8"]]},{"id":"3269fd53.cd0592","type":"api-call-service","z":"bfbf53.2cf9e0b","name":"Hall light Turn ON","server":"6493570e.9de338","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.shelly_shsw_25_98f4abf2df4b_2","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":765,"y":320,"wires":[[]]},{"id":"de9958ea.e049f8","type":"change","z":"bfbf53.2cf9e0b","name":"Unset inky did_leave_home","rules":[{"t":"set","p":"did_leave_home","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":260,"wires":[[]]},{"id":"2865862.66b057a","type":"time-range-switch","z":"bfbf53.2cf9e0b","name":"","lat":"37.433","lon":"-122.138","startTime":"sunset","endTime":"23:59","startOffset":"0","endOffset":0,"x":475,"y":320,"wires":[["3269fd53.cd0592"],[]]},{"id":"6493570e.9de338","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Here’s the sequence that sets the flow variable, did_leave_home
, which relies on wifi presence and sets did_leave_home=True after 15 minutes. Everyone has their own way of setting this, I use wifi:
[{"id":"24678649.9b490a","type":"server-state-changed","z":"bfbf53.2cf9e0b","name":"not_home Unifi tracker iphone","server":"6493570e.9de338","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.iphone_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"not_home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":120,"y":480,"wires":[["780fe6b9.ab4758"],[]]},{"id":"780fe6b9.ab4758","type":"api-current-state","z":"bfbf53.2cf9e0b","name":"Get in_test bool","server":"6493570e.9de338","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.in_test_mailbox","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":275,"y":540,"wires":[["bcc898ec.e88f78"]]},{"id":"bcc898ec.e88f78","type":"switch","z":"bfbf53.2cf9e0b","name":"in test mode?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":455,"y":540,"wires":[["d94e0eb.f8eedf"],["b295b70d.236fc8"]]},{"id":"d94e0eb.f8eedf","type":"stoptimer","z":"bfbf53.2cf9e0b","duration":"5","units":"Second","payloadtype":"num","payloadval":"0","name":"","x":642,"y":500,"wires":[["960be873.3e25d8"],[]]},{"id":"b295b70d.236fc8","type":"stoptimer","z":"bfbf53.2cf9e0b","duration":"15","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":642,"y":554,"wires":[["960be873.3e25d8"],[]]},{"id":"960be873.3e25d8","type":"change","z":"bfbf53.2cf9e0b","name":"Set inky did_leave_home","rules":[{"t":"set","p":"did_leave_home","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":912,"y":500,"wires":[[]]},{"id":"a2f547e6.8033f8","type":"change","z":"bfbf53.2cf9e0b","name":"output \"stop\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":382,"y":596,"wires":[["b295b70d.236fc8"]]},{"id":"5c701b5d.a2c1a4","type":"server-state-changed","z":"bfbf53.2cf9e0b","name":"home Unifi tracker iphone","server":"6493570e.9de338","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"device_tracker.iphone_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":112,"y":600,"wires":[["a2f547e6.8033f8","8e98316a.4fdaa"],[]]},{"id":"8e98316a.4fdaa","type":"delay","z":"bfbf53.2cf9e0b","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":427,"y":640,"wires":[["8248147b.a59b88"]]},{"id":"8248147b.a59b88","type":"change","z":"bfbf53.2cf9e0b","name":"Unset inky did_leave_home","rules":[{"t":"set","p":"did_leave_home","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":625,"y":640,"wires":[[]]},{"id":"6493570e.9de338","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]