How does anyone_home() work with appdaemon?

New to appdaemon and trying to figure out how to best to presence tracking. I have added a device tracker in HASS like this:

device_tracker:

  • platform: nmap_tracker
    hosts: 192.168.0.0/24

Of course that means I get ALL network devices in my network, I thought that could be useful later for other stuff I want to to, but I guess that anyone_home() will use all those devices for its state? Do I have to filter it out already here or is there any other way to specify which of the devices I’m interested in for anyone_home()?

Just for testing, I changed my config to:

device_tracker:

  • platform: nmap_tracker
    hosts:
    • 192.168.0.12
    • 192.168.0.14

But even after restarting HASS, I still see all off my devices in HASS States… What am I doing wrong?

your known devices are in the known_devices.yaml so if you dont delete them there they will keep on existing.
everyone_home(), anyone_home() and noone_home() use all devices that exist in HA. so if you have more devices they cant be used for presence detection.
but you can create your own like this:

intialize(...):
 self.listen_state(self.do_something,"device_tracker.person1")
 self.listen_state(self.do_something,"device_tracker.person2")

def do_something(self,...):
  person1 = self.getstate("device_tracker.person1")
  person2 = self.getstate("device_tracker.person2")
  if person1 == "home" and person2 == "home":
    self.do_everyone_home()
  elif person1 == "home" or person2 == "home": 
    self.do_anyone_home()
  else:
    self.do_noone_home()

  def do_everyone_home(self,...):
    ... do something

  def do_anyone_home(self,...):
    ... do something

  def do_noone_home(self,...):
    ... do something

Thanks, I will test that out. However, I noticed that nmap works so so with iPhones. I used arp ping with openhab2 before, which worked pretty good. Is there a way to get a similar solution here (without having additional apps on the phone)?

sorry i dont have an iphone and i have never found a decent devicetracker solution anyway.
so i cant help you there.
the only thing that mostly helps is setting the switch time long enough, resulting that you are gone for a while before the system noticed that you are gone.

Mmm, I kinda thought so too. It’s OK though, I care mostly about the lights turning on directly, it doesn’t matter if they turn off a few minutes later. But there must be something better than nmap for random network devices. Tested with the TV now, as it is a good hint too that someone is home, but it keeps going away from time to time, even though it’s definitely on. Can you combine different trackers to get better results? Or maybe the router is the best way to go?

you can use different trackers together, but i havent found a realy relyable setting untill now.
allthough for none mobile devices nmap is quite relyable when you have a long enough delay.
but for tablets and mobile phones i havent found anything.

i rather rely on motion detection.