Current State of presence detection

I thought that too … but at the end I don’t think is so important WHO is in the room (unless is a thief ehehe), but rather the presence or not of a family person, no?

Or what could be the use: if Paul enters the bulb turns blue, if Ann enters the bulb turns pink?

I got 3 RPI’s for Christmas and no power supplies or memory cards. LOL

in my case, I have my automation checking behind my kids. If one of my sons leaves home, I turn off the lights, fan and tv in their room. So I’m relying heavily on the “who”. But I also need to have the PIR idea in there too in case they have a friend over, ran out of chips and dip and just ran down to the store. I wouldn’t want the lights and tv turning off on their friend just because my son left for 5 minutes.

I think you suffer of a disease called “automatities” ahah

Use multiple options to determine if they are home or not.

With an iphone the icloud component is pretty reliable and doesn’t require an app.

Combine that with Nmap

and possibly bluetooth off the Pi3

Two ways to combine them. Each automation has a trigger for each of the above trackers going from home to not_home. But you use a condition that all of the trackers are home / not_home. This way any one can trigger the automation but there are checks and balances with the other trackers to prevent false alarms.

Putting that all into the automation can be a lot to write the first time but its copy/paste after that.

Alternatively (and what I think I will setup soon) is to create my own binary sensor and have an automation trigger home/not_home using the same logic as above. That way you are just writing one state trigger into an automation and it saves a lot of copy/paste and size in your automations.

Agreed.
And the ticket may just be that we have to combine multiple methods to determine it. The iPhone/iCloud solution just kills our phone batteries but was by far the most reliable.
Nmap suffers from the iPhone sleep issue
The Bluetooth Tracker kept finding to many other devices and I still would need some type of devices placed around the house like the HappyBubbles solution.

Right now I’m trying out the new trackr solution that w1ll1am23 has been working on here https://community.home-assistant.io/t/trackr-intergration/3941/28?u=turboc with the crowd sourced search function, it may offer a solution with zones similar to the iPhone/iCloud solution without the battery drain.

I’m just checking to see where everyone else is on this to see if there are any other solutions and the Happybubbles one is one that I’m going to check out as well.

I am having the same problem as mentioned above, unreliable presence detection when ‘home’.

  • (2) Apple iOS devices
  • Ubuntu VM with HA
  • 802.11ac wireless network
  • Gigabit Ethernet LAN

I have owntracks setup and it works perfect remote.

The problem is that when I am home owntracks can’t update because I am on the wireless network. So I am falling back on nmap. Because iOS tends to go to sleep I have set what I believe are overly conservative configuration.

- platform: owntracks
  max_gps_accuracy: 200
  waypoints: True
- platform: nmap_tracker
  hosts: 192.168.XXX.100-125
  home_interval: 5
  consider_home: 900
  track_new_devices: no

That should ignore devices 5 minutes after detecting them and consider them home for 15 minutes. My logic here being that the amount of time considered home is irrelevant because once it gets an update from owntracks the last device tracker to update gets priority.

The problem is that nmap is still showing inconsistent ‘home/not home’ results. Is there a debug method for nmap to determine what/why it is considered someone ‘not home’? Or conversely to simply see the device_tracker updates to see if my wifi devices are connecting via LTE and updating owntracks? They shouldn’t because the owntracks is using iBeacons to determine ‘home’.

The home_interval/consider_home logic has kind of confused me.

What I think I want is check as often as you like, but consider it home for 900 seconds from the last successful nmap search for the device.
So assuming a scan every minute.
So minute 1: device is found (I’m Home)
Till minute 10: device still found (I’m Still Home)
Minute 10 : Device not found (but I’m still home because it hasn’t been 900 seconds since last successful attempt.)
Minute 13: Device found (I’m still home)
Minute 19: device found (I’m still home)
Minute 20: device not found( because I physically left home) (but I’m still showing home because it hasn’t been 900 Seconds since last successful scan)
Minute 35: device still not found (it’s been over 900 seconds so now I’m shown as not home).

So here is my config for nmap.

  - platform: nmap_tracker
    hosts: -Pn 192.168.1.1-16  
    home_interval: 1

Using that I never see one of my devices go home/not_home when they shouldn’t in the log book. That, combined with the multiple triggers and conditions I described above has resulted in pretty reliable automations based on home/away status.

1 Like

With the Pn option it doesn’t surprise me.

-Pn: Treat all hosts as online – skip host discovery

It works reliably for me. I have my HA devices locked down to those reserved IPs so I can have nmap survey a narrow range of IPs.

Also helps in locking down what is discovered in HA and eliminates a bunch of noise in the device_trackers as guests connect or I bring home a work computer ect. Track what you want to track, ignore the rest.

I have set up my presence detection using multiple trackers as per https://community.home-assistant.io/t/presence-detection-with-multiple-devices-multiple-trackers/4335 and it works reliably(so far).
I have

  • NMAP to track my phones

  • Bluetooth/BLE tracker running on a different PI3 and reporting back to HA trough appdaemon

  • Owntracks(Misses occasionally)

  • GPS Logger(works great)

  • Locative(Misses occasionally)

All this tied up together with an input boolean

2 Likes

I guess the problem is more with false negatives (away from home when someone is home), than with false positives (thinking someone is home when they aren’t). So do you just compare the responses from each of these and if one of them says you are home, then you’re home??

Wait 5 minutes before setting the state away, set hoe as soon as any tracker is detected.
I found the ble tracker using PI3 and the gpsloger are the most reliable

    - alias: 'Set Anil Away'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.anilhome
        state: 'on'
      - condition: state
        entity_id: device_tracker.pixel_bt #bluetooth
        state: 'not_home'
      - condition: state
        entity_id: device_tracker.ac37434ce86a #nmap
        state: 'not_home'
      - condition: or
        conditions:
        - condition: state
          entity_id: device_tracker.anils6_pixel #owntracks
          state: 'not_home'
        - condition: state
          entity_id: device_tracker.anils6_pixel
          state: 'away'
        - condition: state
          entity_id: device_tracker.anils6_pixel
          state: 'Work'

  trigger:
    - platform: state
      entity_id: device_tracker.pixel_bt
      state: 'not_home'
      for:
        minutes: 5
    - platform: state
      entity_id: device_tracker.anils6_pixel
      state: 'not_home'
      for:
        minutes: 5
    - platform: state
      entity_id: device_tracker.anils6_pixel
      state: 'Work'
      for:
        minutes: 5
    - platform: state
      entity_id: device_tracker.ac37434ce86a
      state: 'not_home'
      for:
        minutes: 5
  action:
    - service: homeassistant.turn_off
      entity_id: input_boolean.anilhome

- alias: 'Set Anil Home'
  condition:
    condition: state
    entity_id: input_boolean.anilhome
    state: 'off'
  trigger:
    - platform: state
      entity_id: device_tracker.pixel_bt
      state: 'home'
    - platform: state
      entity_id: device_tracker.anils6_pixel
      state: 'home'
    - platform: state
      entity_id: device_tracker.ac37434ce86a
      state: 'home'
    - platform: state
      entity_id: device_tracker.4cd5eae084d35a83
      state: 'home'
      for:
        seconds: 30
      
  action:
     service: homeassistant.turn_on
     entity_id: input_boolean.anilhome

(Thanks Zen for the tip for fromatting)

2 Likes

quote=“anilet, post:34, topic:8347, full:true”(Sorry I have no idea how to properly format the code)
[/quote]

@anilet Slightly OT, but just to address this question - if you use three back ticks ( ` ) on a line by themselves at the top and bottom of your code when you paste it in, it will maintain your formatting, and show up in a code box.

     Like This

I am sure this used to be in a help dialog somewhere, but when I went looking for it to point you in the right direction, I didn’t see it anywhere.

Thanks Zen for the tip, I did search forum before posting.

I use iBeacons for home presence detection and it has been very reliable. I have 4 beacons around the house and use OwnTracks to monitor them with iPhones. I can reliably determine when any combination of my wife and I are home or not home. I also have an iBeacon in my car and use that with GPS to detect when I’m in the car (or garage) or detect presence at work or the gym. The problem with GPS/Owntracks alone was that it sometimes took a while to update and GPS may not work well when you’re in a building. Network-based tracking (nmap, routers, pings, ARP scanning, etc.) didn’t work well because of the iPhone’s quirky behavior related to sleeping and network access.

Anyone ever use 2 nmaps, or 2 subnets? I recent added on to split all the cameras & HA stuff off the main lan (was getting bogged down) and now my nmap is unreliable. I think it is scanning 1 (where the cellphones are) and the the other (where most the devices are) and updating that the phones are away.

I want to track the phones and the devices as both are used in automations.

Currently attempting:

- platform: nmap_tracker
  hosts:
    - 192.168.1.64-253
    - 192.168.2.1-253
  track_new_devices: yes
  interval_seconds: 15
  consider_home: 180

Devices on x.x.2.x are registering but nothing on .x.x.1.x is. And I tried reversing the order but no luck.

is nmap routable?

I’m thinking not. I removed the x.x.2.x and am not seeing anything on x.x.1.x. Previously I had HA on the .1.x subnet and today moved it to the .2.x. I was not seeing any errors so I thought it was connecting to the .1.x router but perhaps not.

Not happy about this