Detecting when you are away

I’m looking for a way of being able to detect when a person is present in the house or not.

This is so when they are not present (i.e. house unoccupied) I can automatically trigger presence simulation, putting certain lights on around the property in the evening, etc.

Options could be looking for specific network devices connected to the Wi-Fi (i.e. our phones), a long-range RFID tag of some sort that could be detected inside the property (but that would require extra hardware), geo-fencing using an app, or something else?

Open to any ideas :slight_smile:

There are many examples in this forum. I use the Network Binding to ping for our phones.

What phones have you got?

Thanks for the response.

I’d searched the forum but not found anything relevant (everything I found referred to presence simulation, not detection).

The Network Binding looks to be what I’m after!

We have Android phones (Samsung).

what else do you have in your system? Any door contact switches or motion sensors?

This looks interesting to me.

1 Like

Everyone in my family uses Life360 to track our whereabouts, but presently there isn’t a Life360 binding. As a workaround, I use Node Red. There’s a Life360 plug-in that tells you when members of your circle enter or leave a zone (node-red-contrib-life360 (node) - Node-RED). There’s also a OpenHAB plug-in for Node Red (node-red-contrib-openhab3 (node) - Node-RED). With both of these, I can know when the entire family has left the home zone.

I also use the Network binding to ping phones, however two of my family members use Apple phones and they can go offline for minutes at a time. To help with that, I put a timeout on each of the phone items (using a timer) so I delay taking any action until they’ve been offline at least X minutes.

I use a variation on this excellent work here to have a compound definition of house presence with exceptionally high accuracy (each family member’s phone status, various motion sensor status, security camera status, door status, tv status, sonos speaker status, google home status all contribute).

Here’s the workup I made for OH3 for it:

1 Like

Many thanks for the response, plenty to consider for the best way forward :slight_smile:

No door or motion sensors (yet!), mostly just lighting.

I used to make it really complicated but I’ve simplified a lot. We all have Android phones so we use the openHAB Android app’s feature where it will report the WiFi SSID the phone is connected to to an Item. If that Item matches my home WiFi name, that person is home.

If I wanted to be sneakier, I could use Tasker’s ability to report nearby WiFi SSID names and update an Item with that list. Is one of my home WiFi SSIDs are in the list, I’ll count that person home.

Geofencing is usually too slow and inaccurate.

Pinging the phone with the Network binding took too much fiddling (note, modern phones will randomize their MAC addresses and they go to sleep so you need to reconfigure the network settings to turn off random MAC addresses on the phone for hping to work).

Reporting the WiFi is accurate enough that I’ve not needed to go down the Bayesian route or the Wasp in the Box algorithm.

And I’ve no motion sensors at all but even if I did we couldn’t rely on them because of the dogs.

Sometimes simple can be good enough.

You might be interested in Generic Presence Detection if you want to add a little bit of a delay before marking someone as away. It can be implemented using the Debounce rule template so all you’ll need is some Item configuration.

My Away/Home logic is used primarily to run lighting programs to simulate us being home; I’m concerned with “away overnight” rather than short-term absences, so I set away mode when the alarm has been armed in “away” mode for more than 12 hours and cancel it when the alarm is disarmed. In away mode, it runs a few programs to turn lights on during the evening, and then runs our usual bedtime program to turn everything out for the night.

My Away/Home logic is used primarily to run lighting programs to simulate us being home; I’m concerned with “away overnight” rather than short-term absences, so I set away mode when the alarm has been armed in “away” mode for more than 12 hours and cancel it when the alarm is disarmed. In away mode, it runs a few programs to turn lights on during the evening, and then runs our usual bedtime program to turn everything out for the night.

That’s pretty much my use case here. If I’m out for the evening I want “out” mode to activate (I have three states - Home/Out/Away) which makes sure lights are on, but doesn’t switch them off late evening.

Not got the alarm integrated yet (next project!), want to use some of the alarm sensors to trigger stuff, check doors are closed etc.

I also did not find a ONE good and accurante way to say when I or someone in the household is away.

My strategy now is to use a set of sensors. I agree with @rlkoshak but I am not as far as him and I keep making it complicating, plus I have no dog :slight_smile:

I am using a ping of the Phone devices. It is not very accurate, rather slow and laggy if you debounce to avoid false triggers with devices sleep, hop between networks, when DNS fails, etc… It has the benefit to work without the devices having to have any software installed.

I am letting my OpenHab App report the connected Wifi. If works only on devices with the OpenHab App, some permissions and some luck :slight_smile:

I am using Motion and Occupancy sensors as well. They don’t tell me that I am away but tell me that I am probably not, or someone else is home :slight_smile:

Yesterday, I published sys2mqtt with a first plugin that also can help in the sense that if I use my computer, I know for you I am not away and only I can use my computer.

If you are using Tasker on Android, you may also setup some automation so your phone tells OH that you are now in the car (detected when the car’s bluetooth is connected for instance). That is often a sign that you will be gone soon or someone will be gone with your phone and you car :slight_smile:

Finally, there is always an option that is very reliable and can work if you make it convenient: THE BUTTON.
Just put a very simple button such as a SNZB01P next to the door and get used to pressing it when you leave and when you come back. To incentivise its use, make it turn on/off the lights, play some bye/welcome home message, etc… It has the drawback of being manual but it is pretty reliable.

My suggestion would be to create a Switch item and turn it on/off with some/all of the methods above. This way, if you forget to click the button for instance, but hop in the car, things will still work. If you notice that the car method is reliable, dump the push button even.

Although it is not hooked up right now (battery died), for years I used this as part of my solution. In my case it was an ‘away’ button, when I arrived back home the system detected my arrival and turned everything back on. The button was stuck to the wall next to the door and I could simply tap the button, as I left for work in the morning and it would shut off all the lights, adjust the thermostat… what ever

What I found out of experience is that every once in awhile the automation I had set up to detect my departure and shut everything down would malfunction and I’d come home and the lights would have been on all day. As time went on, I tried to ‘battle harden’ the automation, to catch edge cases and things I hadn’t considered but every once in awhile I’d come home at night and look up to see all the lights on.

‘The button’ is pretty reliable. The button tells the system I’m ‘leaving for the day’ even if it still detects motion or doors opening and closing for a few more minutes. (forgot my coffee)

Presence detection is actually a kind of tough task. I use the wasp in a box method. I live in a third floor flat and it is just me. There is only one way in and out of the apartment. (unless you are spiderman)

Pro tip: place the button near the last place you pick everything up as you leave. For me that is the kitchen counter where I leave my keys and wallet when I get home. By the time I get to the front door, I might have both hands full.

1 Like

Yeah I ran into that, here is what I do.
Indeed, there are devices where the order may fail. You send a command to turn off a light and it stays on.

A solution to that is a to keep the automation simple.
Make a Switch: AwayFromHome. When you click the button (or whatever else), simply and ONLY set the AwayFromHome to ON. Do not do anything else.

Then you can make a rule like:

rule "foobar"
when 
 Item AwayFromHome changed to ON
then
  // do the stuff
end

If you end up thinking that do the stuff does not happen, the questions will be: did you fail say turn OFF the lights ? or did you (the automation) turn them back ON.

If the answer is that it failed turning OFF, you can then add a cron like:

rule "Turn lights OFF hourly when AwayFromHome"
when
    Time cron "0 0 * * * ?" // Fires every hour on the hour
then
    // Gate so that, if we are home, we do nothing
    if (AwayFromHome.state == OFF) return;

    // The following ONLY runs if AwayFromHome.state == ON
    // do the stuff
end

Obviously, you may do it hourly, every minute, every 7 minutes, whatever you prefer.

I was using a combination of “Mobile connected to WiFi” and “Google Presence” on my phone. Last week I thought I’d give BLE a chance. I’ve never tried this before and I have to say that this is a fantastic solution for me:

It detects my Android phone without any problems and what is really cool → No additional App (simulating a beacon) is needed. And ESPresence can handle the random MACs:

Extensive fingerprint based ids instead of mac addresses so we can track or count things others can’t

Switching Bluetooth and/or restarting the mobile phone → So far it has always reported to openHAB :slight_smile:

It simply publishes the distance in meters to my MQTT broker every 10s (refresh rate can be set in ESPresence).
In openHAB I use the expiration timer to reset the string item to “Away” after 15s. I can then use the item in any of the rules, e.g:

If status of (Item XY !== “Away”) then send command ON to Item “AtHome”.

Until now I see it works with distances between 0 - 15m. So far I haven’t had any problems in the cellar or upstairs either. Of course, the more people living in the household, the more complicated the rules are.

When I get home, it detects my phone about 10 m from the door. Perfect! :slight_smile:

We have the tado heating system, and I have openHAB use it’s presence detection. It works well, although the lady of the house needs to open up her (iPhone) app once in a while. I had to write a rule which checks whether she officially left the house over the past 24 hours…

But I’m intrigued by this ESP32 solution. How far does one board reach? And/or how many boards did you install?

I only use 1 board so far and that is in my sideboard on the main floor (where the Raspi with openHAB runs). As I know it’s about 10m inside and up to 50m (?) outside.

I have tested once more:

  • Upstairs I see distances between 4 - 6m in all rooms
  • In the cellar in the “worst” room with lots of concrete and a closed door I get “Away”

It depends on the house, of course. But I would say that 1 on each floor should definitely work well.

1 Like

Thanks for sharing @michaeljoos, that sounds interesting. I need to test that. It would be great if that exists as ESPHome plugin so I could integrate that into other ESPHome devices.

Bingo ESP32 Bluetooth Low Energy Device — ESPHome