Keep track of presence of guest

Hi,

I want to keep track of how many times a person (babysitter) comes to my house in order to be able to have a record of the presences.

She have a guest wifi password so when she’s home she is connecting to my guest wifi and I can be sure she’s home.

Question is how can I “simply” count how many times she was home in a week, a month, a year? And would be great also to track presence time. Any hint?

I have an ASUS router - so I may use an ASUSWRT integration which creates an entity like a “device_tracker.nokia_3310” when this device is connected to home wifi first time.
When the device is first connected to wifi - then this “device_tracker” is created; then it will be “home” or “not_home”.
The name of the entity is set by a device itself: ofc you may create a static IP in the router’s settings (DHCP rules) and define a nice static name for this device (like “phone_babysitter”) - but in case of using a random MAC (iOS feature - and probably you may not force the babysitter to switch this feature off) the static IP address & given fixed nice name will be not set. So, you have to rely on a name set by the device itself.
Now, you have some “device_tracker.nokia_3310” entity.
You need to create a History stats sensor to monitor of time per-day (i.e. reset to zero on midnight) when the entity is “home”.
So, a simple timeline “history-graph” for this “device_tracker” & this History-stats sensor may be useful.

As for “how many times” - may be achieved by counters.

Add a DHCP reservation for her phone and on HA create a ping sensor to track her phone presence.

you seem to not have read my post - particularly about inability to use a fixed address.

On top of what’s been said, you’d then want to track the time and/or count using this: History Stats - Home Assistant.

Note that as long as the babysitter’s phone does not use the HA app to connect to your home HA, a device tracker will not be available, so you’d be depending on the device name only :wink:

Do not think the babysitter uses Companion app.
In case of a volatile IP address only a router-based solutions seems to be reliable.

1 Like

Make her phone IP static in your rouuter.

MAC may change if a corr. toggle is switched on in iOS (which is by default). So you cannot define a static address. Really, this was clearly described in my post.
But - this “private WiFi address” feature does not present in old iOS versions (like on my old iPhone 12.5.x), and may be a similar feature may or may not present on Android.
So, it depends on a particular phone.

My attitude regarding private addresses are a little different.

TL:DR: My network, my rules.

I have a similar situation: We have a tenant and for security reasons I like to know when anybody is home. For example, I get an alert when a gate gets opened if nobody is home, because it’s an unexpected event.

But, I declare this to the tenant and I’m not interested in anything else (not tracking Internet traffic of the tenant, for example). I will ask whether I can turn off the private address feature (this is a per network feature on iOS, so it doesn’t compromise them otherwise), create a DHCP reservation and then set up a ping sensor (I’ve found this to be the most reliable option). Done.

Same here. I don’t allow randomized MACs on my network because of MAC filtering. Guest wants to use WiFi, I ask him to disable private address as per network requirements. No? Don’t use my WiFi, thanks. Also, that subnet has porn and other stuff blocked (sorry, watch that on your own data).

1 Like

In iOS that “private WiFi address” is set ON automatically by default.
I noticed several times that my wife’s iPhone, my sisters iPad have this switch ON again - although I already switched it OFF. They always say “I did not touch it”.
May be it happens after a next update, have no idea.
May be it happens after switching to another AP: have 2.4 & 5 GHz points, sometimes 5GHz stops working, people usually switch to another AP.

I am using ping-based sensors only for “stationary” devices like PCs, TVs, mediaplayers, RPis, …
For mobile devices I use my own “device_trackers” updated based on services like Traccar, Life360, CompanionApp, ASUSWRT, iPhoneDetect.

I’ve seen this happen after an update.

Given my hardware, I’ve found router-based tracking highly unreliable, for some reason, so I stopped bothering. I avoid Life360 due to its cloud nature. In this case, the HA app isn’t an option for a tenant, but otherwise it’s my primary way for tracking.

Consider Traccar - you may install a Traccar server on your hardware.
So, I believe the data are on your side only.

Companion App is the least reliable GPS-based tracker in my list.
Using it on rather old devices like iPhone 5s, 6s+ (iOS 12.x), iPad Air (iOS 15.x) - since 2020 (my 1st steps with HA) a MobileApp integration usually stops updating info about clients. Have to reopen a Companion App - sometimes even have to press a “update location” in the App - only after this HA receives an update, but this usually work for several hours. Then again no updates.

Life360 stopped working in Russia due to war-related reasons.
I contacted Life360 management on 2022 several times and asked them not to switch the service OFF - said smth like “people here who are against the war - are tend to disappear, your services could be useful”. No feedback.
Have to use Life360 with VPN - which is rather unstable.

As a result - have to use my own “device_trackers” updated by “device_tracker.see” based on the last updated tracker: ASUSWRT, iPhoneDetect, Traccar, Life360, Companion (incl. battery data).

Android is rock solid for device tracking with the companion app. iOS? Don’t even bother.

I don’t need to track with precision the only iOS device in my house so I’ve used only the HA companion so far. But if needed I’d use PhoneTrack, also avoiding Life360 due to being cloud-based. This same iPhone has had private address off for about a year and I’ve never seen it turn on by itself.

I’ll check it out.

It can be slow to update. The update interval can also be set client-side at the cost of battery drain.

I fuse the app’s data with that of my Apple home hub (an Apple TV) and that combo works really well.

1 Like

ok so first of all thanks all for your feedback. BTW my setup for the device-tracker part is already there. There are only android phone involved so no issue with random mac or ip. Phones have a reserved IP adress, devices have been identied and renamed so now I can easy see status home / not_home reliably.

The thing I found more hard is about the statistical part. I checked the history_stats so my question is: i have to create several sensor (one for today, other one for this week this months and so on) or there’s some smarter way to have that?

Off track from OPs original question, but iOS is perfectly fine for zone-based location tracking. My understanding is that zones defined in HA are shared with the OS. When the OS detects your (accurate) location in these zones, it sends the update to the HA app.

You are right that outside of zones, location tracking is pretty shoddy on iOS however I can’t see many use cases for perfectly accurate location outside of zones for home, work, gym, etc. There are better methods for detecting presence within the home zone than GPS such as WiFi AP tracking, Bluetooth beacons, etc.

I use the home and work zones to send notifications to my partner when I leave work and arrive home so she knows I got home safe. These are pretty much instantaneous when I enter/leave the zone.

I don’t believe there is a better way that to create a sensor for every zone you want. I just went through this myself in an effort to make a “time at work” tracker. I ended up having to make a separate history_stats sensor each day of the week, plus one for “today”, plus one for “this week”. There unfortunately doesn’t seem to be a simpler way to do this.

Fortunately, as you have to define history_stats sensors via YAML anyway, it makes it very easy to copy and paste the sensor multiple time and just change the timestamps/entity name between each one. Here is my YAML for my weekly sensor:

template:
- sensor:
  - unique_id: 1701269928
    name: Timestamp start of today
    state: >
      {{ as_timestamp(now().replace(hour=0).replace(minute=0).replace(second=0).replace(microsecond=0)) }}
    unit_of_measurement: "s"

sensor:
- platform: history_stats
  unique_id: 1701269639
  name: Time at work this week
  entity_id: person.me
  state: "Work"
  type: time
  start: "{{ states('sensor.timestamp_start_of_today')|float(0) - now().weekday() * 86400 }}"
  end: "{{ now() }}"

In my case, I needed type: time but you may want a different type if you’re trying to count “instances” or the ratio they are there/not there. Have a look at the history_stats documentation for the available types

PS I use timestamp_start_of_today to avoid using now() 7 times every minute (one for each sensor). Storing it in a helper should decrease the load.

You can turn off private wifi address for specific networks and keep it on globally. Never had it turn back on for me.

1 Like