|
1 |
| -[](https://github.com/custom-components/hacs) |
2 |
| - |
3 |
| -# iPhone Detect |
4 |
| -This integration sends a message to the defined hosts on UDP port 5353. |
5 |
| -The iPhone responds, _even when in deep sleep_, and an entry in the ARP cache is made . |
| 1 | +# iPhone Detect for Home-Assistant |
6 | 2 |
|
7 |
| -Uses Home Assistant's [device_tracker](https://www.home-assistant.io/components/device_tracker/) and idea/script from [return01](https://community.home-assistant.io/u/return01) |
| 3 | +[](https://github.com/mudape/iphonedetect/actions/workflows/hassfest.yaml) |
| 4 | +[](https://github.com/mudape/iphonedetect/actions/workflows/hacs_action.yml) |
| 5 | +[](https://github.com/custom-components/hacs) |
8 | 6 |
|
9 |
| -Only **IP addresses** will work, _no hostnames_! |
10 |
| -You have to assign a **static** IP address(es) to your iPhones, probably in your router. |
| 7 | + |
| 8 | + |
| 9 | + |
11 | 10 |
|
12 |
| -_The interval_seconds time must be shorter than the timeout in which the ARP cache is cleared (usally 15-45sec), or the phone will be marked not_home._ |
13 |
| -_So, leave it at the default value (12sec) or make it shorter._ |
| 11 | +This integration sends a mDNS message to defined hosts. |
| 12 | +The device responds if it's connected to the network, even when in deep sleep, and an entry in the ARP cache is made and read. |
| 13 | +Usefull as a [device_tracker](https://www.home-assistant.io/integrations/device_tracker/) for your [person](https://www.home-assistant.io/integrations/person/) integration to see if users are at home. |
14 | 14 |
|
15 |
| -<a href="https://www.buymeacoffee.com/MudApe" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a> |
| 15 | +## Installation |
| 16 | + |
| 17 | +After installation you need to **restart** Home-Assistant before using the integration. |
| 18 | + |
| 19 | +### Using HACS |
| 20 | + |
| 21 | +If you dont' have [HACS](https://hacs.xyz) installed yet, I highly recommend it. |
| 22 | +[](https://my.home-assistant.io/redirect/hacs_repository/?owner=mudape&repository=iphonedetect&category=integration) or search for `iPhone Device Tracker`. |
| 23 | + |
| 24 | +### Manual |
| 25 | + |
| 26 | +Download the `iphonedetect` directory and place in your `<config>/custom_component` |
| 27 | + |
| 28 | +## Configuration |
| 29 | + |
| 30 | +### Network |
| 31 | + |
| 32 | +Assign a **static** IP address to the device you want to track, probably in your router. |
| 33 | +Alternative, set a manual IP in your device WiFi configuration. |
| 34 | +Avoid automatically connect to differtent SSID's (2.4 and 5 ghz bands) |
| 35 | + |
| 36 | +### Setup |
| 37 | + |
| 38 | +[](https://my.home-assistant.io/redirect/config_flow_start/?domain=iphonedetect) |
| 39 | + |
| 40 | +If you don't have [My Home Assistant](https://my.home-assistant.io/) redirects set up, go to Settings -> Devices & Services |
| 41 | +Click "Add integration" and search for `iPhone Device Tracker` |
| 42 | + |
| 43 | +Give the entity a unique `name` and enter its IP address. |
| 44 | + |
| 45 | + |
16 | 46 |
|
17 |
| -## Example configuration.yaml |
18 |
| - |
19 |
| -```yaml |
20 |
| -device_tracker: |
21 |
| - - platform: iphonedetect |
22 |
| - consider_home: 60 |
23 |
| - scan_interval: 12 |
24 |
| - new_device_defaults: |
25 |
| - track_new_devices: true |
26 |
| - hosts: |
27 |
| - hostname1: 192.168.0.17 |
28 |
| - hostname2: 192.168.0.24 |
29 |
| -``` |
30 |
| -This will create `device_tracker.hostname1` and `device_tracker.hostname2` once the devices have been detected on your network. |
31 |
| -(Re)start the Wi-Fi on your device/phone to trigger their creation on first run. |
32 |
| - |
33 |
| -__Note__ |
34 |
| -If you have `track_new_devices: false` (in this or any integrations specified before this) for the device_tracker component you need to manually change `track:` to true for each device in `known_devices.yaml` |
35 |
| -(see component settings for [device_tracker](https://www.home-assistant.io/components/device_tracker/#configuring-a-device_tracker-platform)) |
36 |
| -```yaml |
37 |
| -hostname1: |
38 |
| - icon: |
39 |
| - mac: |
40 |
| - name: hostname1 |
41 |
| - picture: |
42 |
| - track: true |
43 |
| -``` |
| 47 | +This will create an entity `device_tracker.<name>` |
44 | 48 |
|
| 49 | +Repeat the steps for additional entities. |
| 50 | + |
| 51 | +#### Options |
| 52 | + |
| 53 | +You can change the consider home timeout per tracked device in the UI. |
| 54 | +Default is 24 seconds. |
| 55 | + |
| 56 | + |
| 57 | +#### Reconfigure |
| 58 | + |
| 59 | +You can change the IP address of the tracked device in the UI. |
| 60 | + |
| 61 | + |
| 62 | +## Troubleshooting | FAQ |
| 63 | + |
| 64 | +<details> |
| 65 | +<summary>Private Wi-Fi address</summary> |
| 66 | +The device private MAC address will remain the same for each network, as long as the network isn't recreated or rotating (iOS 18+) MAC is used. |
| 67 | + |
| 68 | +In other words, if a tracked device no longer can be found the user have propably recreated the connection to your Wi-Fi forcing a new random MAC address to be used. |
| 69 | +<br /> |
| 70 | +Note that if your WiFi has different SSID for the 2.4 and 5 ghz bands, and the phone has private network enabled, two different MAC will be presented to the DHCP. |
| 71 | +Most likely that will require the integration to track two IP's per user/Person. |
| 72 | +<br /> |
| 73 | +So, for best result only have/connect to one SSID, turn off private network and assign static IP. |
| 74 | +</details> |
| 75 | +<details> |
| 76 | +<summary>False or flaky not_home status</summary> |
| 77 | +Especially when the network has multiple Access Points, tracked devices sometimes are marked as not_home when actually connected to the network. |
| 78 | +Increasing the consider home timeout might help this. |
| 79 | +Most likely it's a network issue though, try placing your AP's at different locations. |
| 80 | + |
| 81 | +Devices might auto-update during night, they of course then will be not_home for awhile. |
| 82 | +</details> |
| 83 | + |
| 84 | +## Attribution |
| 85 | + |
| 86 | +Original idea from [return01](https://community.home-assistant.io/u/return01) |
| 87 | + |
| 88 | +## Disclaimer |
| 89 | + |
| 90 | +Author is in no way affiliated with Apple Inc. |
| 91 | +Author does not guarantee functionality of this integration and is not responsible for any damage. |
| 92 | +All product names, trademarks and registered trademarks in this repository, are property of their respective owners. |
| 93 | + |
| 94 | +<a href="https://www.buymeacoffee.com/MudApe" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a> |
0 commit comments