I used to be able to do this on Android using Autoremote and Tasker, which would send an MQTT to Homeassistant once the SSID changed but that app isn’t available on iPhone so I was wondering what alternatives there are.
I use my router to keep track of devices that are present as suggested here: Setting up presence detection - Home Assistant.
An alternative is using the Companion App to notify of a change in location.
Life360 works for us.
I use my router. When I’m at home, 99% of the time my phone is connected to my wifi, and I never leave home without my phone.
So my phone’s wifi presence is the best indicator for this purpose.
You can play with the timeout, eg: Update if it has disconnected for at least 7 minutes, to be sure you didn’t just go outside to pick something up.
Just realised MaxK also suggested the router.
Why don’t you just use the official Home Assistant companion apps for Android / iOS?
These provide a whole range of possible sensors. Among other things, one for the SSID of the currently connected network, or a location detection based on GPS
i attempted to achieve this by using Home Assistant‘s iOS companion app. the only sensor it exposed that will be useful for this purpose was the BSSID one, and it didn’t change its state upon disconnecting from the network.
how is it supposed to work? I added my fritz!box 7490 to my Home Assistant and there is no sensor for whether my phone is connected to my Wi-Fi
Not all of the companion apps sensors are enabled by default. You may need to go into the settings and enabled the location etc. sensor on your device.
Most router integration will create device_tracker
entities for devices that connect to them. They may not be enabled by default either, so you need to check the entities list… make sure to set filtering to show disabled entities.
I already enabled the BSSID sensor. The state changes are simply not reported to Home Assistant once my phone is disconnected from Wi-Fi though
Is your Home Assistant server accessible outside your local network? If it is, have you set an external connection URL in the companion app’s Server & Device menu?
I believe you want sensor.ssid
NOT sensor.bssid
We use openwrt ubus device tracker for this at home, and i also have attached to my Person entity presence a BLE beacon that turns-on when i’m on wi-fi and delay-turns-off when i’m no longer on home wi-fi (that way i can restart the router without all my away automations firing).
yeah. I just noticed there is an SSID sensor as well. using That didn’t change anything though.
The update interval in iOS is different than Android: Sensors | Home Assistant Companion Docs. So, you are probably seeing the inconsistent connection status as a result of the update interval.
As @Didgeridrew mentioned, check the external connection URL in the companion app.
Also, just to confirm, you are using this Fritz Integration: AVM FRITZ!Box Tools - Home Assistant?
It does support device tracking so this may be a better way than using the companion app.
I am, and I’ve only just realized my iPhones connected status is under a menu called “diagnostic “. I haven’t noticed that it was there before because the title for the menu it’s under is illlogical in my mind, so I unknowingly mentally ignored it. It should just be called “state “or “device tracker” or so.
BSSID is a sensor that displays the MAC address of your device.
For the name of the connected WiFi network you have to usw the SSID sensor.
…::edit::…
I see that this has already been answered. Sorry
If you use HomeKit that’s an option too, the geolocation on HomeKit is pretty accurate and you can use that in conjunction with Home Assistant to do a lot.
Doesn’t seem reliable. Tonight, it randomly set my phone to “away” for 5 hours, despite me being at home, the phone being fully charged and the internet seemingly working (There was some download throughput during all this time in the monitoring interface).
I’m gonna try the external URL solution now.