I’m trying to rely on IOS for presence detection with no success.
Conversations like this are killing my credibility:
Any chance there’s an update in our future that can get me back in good graces?
I’m trying to rely on IOS for presence detection with no success.
Conversations like this are killing my credibility:
Any chance there’s an update in our future that can get me back in good graces?
Your wife is calm and polite compared to mine
In my opinion presence detection will always have glitches and issues. That is why I suggest a belt ans suspenders approach. Setup as many presence detection options as you can and use them together to determine if someone is home. See below for a good explanation.
Combined with that, a user recently suggested putting a motion sensor by your front door area, and checking the status of that before marking yourself gone, so that it won’t mark you gone, unless there was was motion in that area.
Do you know why specifically it has her going ‘not_home’ ?
In my instance I had to make my home radius larger due to gps accuracy.
I use the following automation for testing. Basically any time my location updates I get a ios message with my gps coordinates on a map. Helps me see where my phone things I am.
- alias: Notify iOS moving
trigger:
platform: state
entity_id: device_tracker.ryans_iphone_app
action:
service: notify.ios_ryans_iphone_app
data_template:
message: >
"Long press for location"
data:
push:
category: map
action_data:
latitude: "{{trigger.to_state.attributes.latitude}}"
longitude: "{{trigger.to_state.attributes.longitude}}"
I suspect it’s because the IOS app has once again lost it’s “Device Tracker Component Loaded” setting. Of course, attempting to enable it will cause the application to lock up. So, it will have to be deleted and re-installed. I’ll confirm that when I have access to her phone later today.
The IOS application is not really best for presence detection. I tried so far bluetooth, owntracks and nmap (my router is not supported) as well.
I think there is currently not a good way for presence detection, at least not a very smart way to do it and to fix things like forgot phone home or forgot keys home or forgot smart watch home, or a combination of those.
I am thinking of writing a plugin that will combine room presence with home / not_home presence and expose the position and state in a way that helps writing automation on top.
Grouping of trackers under one group for a person works in a way, but as soon as you have one item left at home, or one item that is slow in detecting your departure, your detection is broken.
The IOS app is nice to control things when not home but i find owntracks to be better to send background information, especially because it uses mqtt.
I would say only implement a presence system that is for sure bullet proof. If you rely on IOT stuff you will never be happy.
One way to do it that works for me is to require people to use the home automation to lock/unlock the house so that way the system knows when people are gone. Same for coming home.
Then you know guaranteed for sure if someone is home or not. You can add other stuff for individual presence that doesn’t need to be as reliable.
As a side note. I tried the iOS stuff and didn’t find value in it. I already had sms notifications and the web interface on my phone. I ended up canning it because i couldn’t get the bugs worked out and had other HA projects I cared more about.
I get HA to ask my iphone where it is using the find my phone feature. I use automation to request my iphone location based on time of day, battery level or when i need to confirm location. It might be helpful as an alternative to the HA ios app for your wifes phone.
Another alternative is to use homekit automation on your wifes phone to turn on a HA switch (through home bridge) when she is not home. This might be more reliable than the HA ios app.
I’ll look into sosumi, but it hasn’t been updated in 3 years. I’m skeptical to say the least.
Homebridge is on my list of todo’s so maybe that’s an option.
I have been using sosumi for the past three years without issue. Let me know if you need help setting it up.
The best solutions that I have found it to have a dedicated device per person/pet/thing for tracking presence, then creating template sensors in HA for monitoring multiple presence sources.
I use Happy Bubbles and some BLE Beacons for this and got it all set up with the help of this video. I’m currently just using one of the devices set up in my living room with multiple BLE Beacons (one for my wallet, one for my wife’s purse, etc. things that go with either of us wherever we go).
I then have some template sensors set up to display if either of us is home by combining the state of our beacons with the state of our HA iOS app location and the state of our Netgear router connection to our phones.
Here mine:
- platform: template
sensors:
location_bryan:
friendly_name: 'Bryan'
value_template: >
{% if is_state("device_tracker.bryan_wifi","home") or is_state("device_tracker.bryansiphone","home") or is_state("sensor.bryans_wallet","Livingroom") %}
home
{% elif is_state("device_tracker.bryan_wifi","not_home") and is_state("device_tracker.bryansiphone","not_home") and is_state("sensor.bryans_wallet","away") %}
away
{% else %}
unknown
{% endif %}
entity_id:
- group.location_bryan
I then build my presence based automations off of the state of this sensor.
On key thing is have the away state set with “and” condidtions,
{% elif is_state("device_tracker.bryan_wifi","not_home") and is_state("device_tracker.bryansiphone","not_home") and is_state("sensor.bryans_wallet","away") %}
This makes sure that ALL of those devices are reporting “away” before doing any automation, making extra sure that my lights aren’t turning off or that my security doesn’t get triggered when someone is home.
The really great thing about this solution is that I can easily add more functionality to it by just getting more BLE beacons for my kids or my dog, or by getting more Happy Bubble devices to put into different rooms so I can track what room each person/thing is in as long as they have their beacon on them.
(Also great to have an extra beacon around to give to the babysitter or guests watching the house)
I’ve had similar issues using a single source for presence detection pretty much no matter what it is. What seems to be working well for me at the moment is to aggregate the state of many presence detection methods (I’m using bluetooth, wifi via dd-wrt, and owntracks) I have automations to trigger the state of the input boolean if all or some are home or away. For example, I know that I can’t be away if my bluetooth or wifi sensors say home, owntracks may be less reliable. I only trigger change to state of input boolean to away if all are away. I have a separate input boolean and set of automations for my devices and my wifes devices.
I then trigger all of my presence based automations based on the state of the input booleans. This is also nice because it allows me to easily change how the input booleans are switched on or off without rewriting all of my automation triggers. This has been pretty reliable for me and has significantly improved the wife acceptance factor.
One additional presence detection approach I’ve been using with really good success is known as the “wasp in a box algorithm”. I’ve implemented it with an input boolean, motion sensors, and contact sensors on the exits of my home. Essentially, if there is any motion in the house while the exits are closed, then I know there is occupancy. If any of the exits open, then I don’t know the occupancy until I again detect motion while the exits are closed. Along with my other presence detections (DD-WRT, iOS, etc), I use this status as the final check in determining if I should kick the house into “Away” mode.
Great idea - could you share the relevant code?
Sure, you need just two automations:
alias: Turn On Presence
trigger:
- platform: state
entity_id: binary_sensor.upstairsMotion
state: 'on'
- platform: state
entity_id: binary_sensor.downstairsMotion
state: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.frontDoorContact
state: 'off'
- condition: state
entity_id: binary_sensor.backDoorContact
state: 'off'
action:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.presence
alias: Turn Off Presence
trigger:
- platform: state
entity_id: binary_sensor.frontDoorContact
state: 'on'
- platform: state
entity_id: binary_sensor.backDoorContact
state: 'on'
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.presence
Then, you can just check the state of input_boolean.presence in any other scripts to see if anyone is home.
An important note with this, when the presence boolean is on/true, we know definitively that someone is home. However, when the boolean is off/false, we can’t know definitively that nobody is home. For example, if you go outside to do yardwork, the boolean will go to false. We wouldn’t want the house to arm away while we’re mowing the lawn. So I would still recommend using this in conjunction with other presence detectors.
I’ve been struggling with that issue for some time, tried many different combinations. I’ll try to describe my failed setups along with current successful!
My setup is 2 iphones (5s and 6s). I want HA to know that I left home within 3-7min that I left home and 1-2min before I arrived.
First try was a built-in HA ios application, which updates location using GPS by default.
It’s pretty accurate, but it was not accurate enough for me. Especially when iphone is in low power mode, it does not allow background process to update location. Most of the time you arrive from work with <= 20% of battery and HA still shows you as “away”. I tried making it better by forcing updates with “update_location” push notification. But that still requires a mobile client to do some work in background, so it does not work really.
My second attempt was adding “proximity” component in addition to iOS mobile app. It did not provide better results, due to the same issue, it was failing to update location even when I’d been moving towards home for some time. I did not find it useful and eventually stopped using proximity.
Next attempt was to use WiFi for presence detection. Unfortunately iPhones drop wifi connection when going to sleep mode, so nmap would show you as “away” every time your iOS device goes to inactive mode. Neither of provided on Web “hping3 workarounds” worked for me. It’s worth adding that for Android device (LG OneTouch with some old Android OS) nmap works fine, it can reliably detect presence.
Next I tried setting up BLE beacon on my PIE and tested that it works. I wanted to avoid using 3p applications whatsoever, so I tried using HA iOS app iBeacon support by setting my beacon UUID in Home zone. Based on my testing I think iOS app is far from ideal in beacons support. First of all there’s this bug, which confuses you showing only “Left zone” notifications, and secondly it never reliably worked for me. Beacon was ok, because it worked with other 3p iOS beacon apps. In addition to beacons I tried setting up BLE and BL presence detectors with no effect.
I also tried using built-in MQTT server with onTrack iOS application. The main problem with mqtt is that client looses connection to server every time your iPhone switches from LTE network to Wifi, which for me happens exactly when I arrive, so there’s no location update when you actually need it :).
Finally I tried using “iCloud” tracker. My though was that apple would allow iCloud client application to run in background and properly update it’s location. I found some old posts describing it as very battery consuming, but reliable. Later on battery drain was fixed by having very infrequent updates - up to 30min between checks when iphone is stationary. So I decided to update component to be more configurable, so that one could find appropriate balance between battery consumption and updates frequency. In addition I fixed iCloud component service called “device_tracker.icloud_update” in that pull request which was eventually accepted. Currently I use this updated icloud component as the only presence detection mechanism with good results. I have max_interval: 10 and gps_accuracy_threshold: 1000. This eliminates false positives and detects my arrival about 1min before I open the door. I haven’t yet experienced any battery issues. In addition I use “device_tracker.icloud_update” service to programmatically request location updates!
Hope that helps!
I’ve been using HomeKit and an input boolean for pseudo presence detection with much success for several months. It has been very reliable. I recently ditched Homebridge for the HA HomeKit integration, and while I don’t have nearly as much time under the HA HomeKit, it seems to be just as reliable. You should be able to dial in your geofence in the Home app to get to the 1-2 minutes before you arrive home timing you are looking for.
I’ve been using the OwnTracks Http component and running OwnTracks on my IOS devices and it works great.
Yeah, but I don’t particularly like the idea of adding 3p dependencies to your setup. You suddenly depend on another peace of completely different sw. Also you have to expose your password to owntracks, which is not protected, unless you have ssl. Does it work for you, when your phone switches to wifi from cellular upon arrival? My guts sense apple location tracking should be more reliable on Ios, but to few metrics to prove it :).