Arriving home - detecting phones which are arriving to Home

How to compare the current distance with the last distance without persistence?
You would still need any type of dummy item to store the last distance.

Good to know. I didn´t found any information about that and Google wants you to add an payment option directly.

Yes of course.
What I meant is that you don’t need this zone and multiple clauses. A simple comparison is sufficient

This is what I thought of first! But I also had to add some ‘guards’ in the rule I think.
For example, consider somehow the location accuracy - sometimes the accuracy increases, and the location is pointed to the center of the location accuracy radius - meaning that this can be far closer to home before the previous one - so just comparing the previous and the current is not enough I think.

Also I had to check if this movement is a ‘bigger’ movement. If you walk around somewhere, you might get closer to home (just a few meters), but you are not going home. Setting a minimum distance is not enough I think (before the rule gets triggered), because I do lots of things not so far from my home - groceries, etc…

I don´t think it´s possible to get an rule that could cover all of this.
It sounds more like a job for an AI to predict if you´re really going home or just getting groceries.

Yes, that’s will be my another ‘big’ project later, to add same AI to my smart home.

However if this is too complicated to do, I should rephrase my original question:

  • How other users manage heating/cooling ‘smartly’? I live in a flat, so I don’t have a ‘programmable’ thermostat either, I will buy radiator valve thermostats (Z-Wave). Thus I don’t really know which is a right and doable way.
    Just make some rules based on current presence, weather conditions outside and time? I have seen many-many users who use some smart thermostat, but I really don’t know how they ‘program’ it.
  • Same for AC, I will buy a smart controller for my AC.

I´m using a tado bridge and thermostat for my smart heating.
The app already has a geofence and start to heat when getting closer to home.
But without an AI that checks if you´re really going home or just getting groceries.
The tado bridge can be controlled by openHAB and Alexa.

And there´s another tado thermostat for AC :slight_smile:
Just have a look at the products.

I used to use a geofence, but found it highly inaccurate due to location drift. I now use my WiFi connection to detect presence.

If everyone is away, the thermostat drops to Eco Mode. When someone arrives home, the thermostat resumes its normal schedule.

I also have imported some simple scheduling that checks against a set of “school days”. If everyone has left the house by school time, the thermostat operates in school mode (drops to Eco temps but preheats or precools the house in anticipation of my kids’ arrival home from school).

This has worked well for me especially since my HVAC is a new unit and even if the temp is a couple of degrees off of desired temp when there is an arrival, it takes little time to get the house to the desired temp.

Thanks! After figuring out that you can’t really detect precisly by phone, this looks the best idea!

So you mean, that you use some calendars which has some info which days are ‘school’ days?
What does ECO means on your thermostat? Does it kick in after a bigger temperature drop or it somehow manages the boiler to operate on a lower power?


Yes, exactly about the school days.

I use a Nest thermostat and the ECO on my thermostat is a min/max temperature setting. Basically I am telling the thermostat that in this mode no one is home and I don’t want the thermostat to run constantly to achieve my actual desired settings all day.

Nest uses Eco MIN and Eco MAX. Eco MIN basically equates to do not use the heat while everyone is away UNLESS it drops below this temperature. Eco MAX equates to the exact opposite. Do not use the A/C while everyone is away UNLESS it rises above this temperature.

Thanks for your respone!
Nest Thermostats are really cool! However I can’t achieve this in my flat :frowning: I need TRVs (Thermostat Radiator Valves). However this behaviour looks really good, even if I will implement it in openHab.

Thanks for you as well!

Yes I had a look at tado devices before, but it seemed a little bit pricier than other products and I didn’t find any review that will ensure it will work great with openhab and the devices itself are great products.

I’m just going old-school with a simple ping!
I’ve set my dhcp to static-define and up address to the devices macaddress (so they always get the same one), then send pings to them!
I can track if their home by if they can ping or not.
Works effectively
(Not at home right now for any scripts/setups but is not difficult to do!)

Just an idea for you.

This doesn´t work for iPhones as they´re not responding to pings after a period of time not being used.
There are some solutions to “wake up” the iPhone but none of them works constant enough, at least for me.
And it´s about to know when someone is heading home to start heating/cooling instead of starting when someone already arrived home.

How did you make OH2 detect when someones home?
I’m just starting to make some automation based on who’s home.
We all have Iphone connected to Wifi when we get home, and this may be the easy way to detect this I think.

With iOS13 it‘s easier to use HomeKit and Homebridge with the openhab2-complete plugin.

You have multiple options to choose from:

  • Use iCloud binding. This maybe the easiest way to go (you just need to set it up and use a generic calculate distance from Home rule), but I don’t really recommend it. This binding polls the status from iCloud and it always lags behind the actual state. So approx. you will have to wait 10 minutes to update the state if you are at home or you have gone away. So the iCloud binding is good for other automations and to see device status but not for presence I think.
  • Yes you can use some ping method, which needs no other device/configuration and service to use, you can find some great example here on the forum, like this:
    iPhone Presence Detection with hping3 and ARP

This is the most generic way to do, this works with every Wi-Fi connected device. However you will have to take care of all the specific cases: what happens if your phone battery dies while you are home, what if it loses Wi-Fi connection for some minutes, etc…

I have never used this so I can’t give you additional info on this.

  • But the best way in my opinion is the one @Bredmich said. Set up a HomeKit instance (you can use Homebridge or Node-RED or maybe even the openHAB HomeKit binding) and use proxy switches. Then you can set automations in the Home app for these proxy switches. One for each device and set up to turn on when that specific device arrive home and turn off when you leave home. It works really great, it works instantly, not when you approach your house and you are in wifi range, etc…

What works for me is the icloud binding. My wife and I have iphones and I have rules that run on location for a lack of presence, ie when we are outside of a location distance, ie 200m, then if we are both away do some security stuff, cameras, lights etc.

I have a slightly different routine for when we are home, the icloud binding works but as people have said a 10 minute refresh is annoying as I could be home setting off the alarm before the 10 minute refresh. So what I have here to add is motion detection, if one motion detection sensor is triggered, (I have an external camera with it and a motion sensor in the hall), it sets an auto refresh of the icloud binding, it then bypasses the 10 minute, checks immediately and if it then detects someone is within 100m of home it then turns off all the security.

So far, barring the odd one or two occassions this has been absolutely perfect, and to be honest when it hasn’t worked, the alarm has gone off but about 10 seconds later it’s caught up and everything is turned off…

I’m happy with that as I’d rather it went off as a false alarm rather than not at all.

This is also a great idea, that you bypass the distance for some minutes.

However keep in mind that

If you send an update to the iCloud binding it won’t force the iPhones to refresh, it just only re-polls the last state which was sent to iCloud. However if your rule works like this, it is really great. Why I can’t do this, because I don’t have that much motion sensor…

I’ve used this method for quite a while and haven’t noticed any issues, in fact I’d say that I’ve never noticed that it hasn’t given me a ‘live’ update rather than a re-poll.

In real life, the motion sensor detects motion, the iphone_refresh item checks the location and then if an iphone is home it turns everything off. That all happens in a matter of a second or two so surely it must be a live refresh? My rule has a 5 second timer to allow the refresh to run and return a value but it’s worked perfectly for months like this…

However, as you say…it does rely on a motion sensor update to break the 10 minute refresh.

If you wanted this on your system a motion sensor is only a few quid, shove it pointing at the front door and that should have it. The other option is, a bit left field thinking, to have a different trigger to run a refresh, do you have a door lock, ring doorbell, doorway light that comes one, something that detects you are home???

That is a very good point I brought up in this rule example. I have a motion sensor that is pointed down the stairwell towards the front door. There are no windows in the detection area or anything that could trigger the sensor. I live on the 3rd floor with only one entrance door, so that makes it easier. My system loops until the phone logs onto the wifi. Usually works within a minute or two