Companion app on iPhone6 disconnects every few mins & causes device_tracker issues on Android

I’m not entirely sure if I should be posting this issue in the Companion app for Android or iOS or neither, but hopefully it’s okay here

I have two phones:

Xiaomi Mi10TLite running Android 12 with active SIM card with mobile data
old iPhone6 with iOS 12.5.7 with expired SIM card

If I go out for a walk I switch on the 4G data connection on my Mi10TLite & use the Cloudflare AddOn to create an ArgoTunnel back to my HomeAssistant server. This all works perfectly & I have remote access to HomeAssistant (v2024.6.4).

I then use the Bluetooth Hotspot internet connection to share my Mi10TLite 4G data connection and then connect the Bluetooth on my iPhone6 to the Mi10TLite to give it a working internet connection. This works fine, albeit slowly, allowing me to access my HomeAssistant server on the iPhone6 via the shared 4G connection to my Mi10TLite over Bluetooth.

I use the device_tracker entities on both devices to update my location on a Map card. So if I go out for a walk, both devices should be independently communicating my GPS location back to my HomeAssistant server.

This works perfectly on the Mi10TLite allowing me to see my breadcrumb style track on the Map card.

Now the problem:

With the iPhone6 connected & tracking, this works for a few minutes & then the Companion app v2023.12.1 (2023.508) seems to ‘disconnect’ from my HomeAssistant server. If I swipe-down to refresh, it eventually reconnects & updates the iPhone6 device_tracker location (takes 1-2 minutes to reconnect).

At first I thought this was due to user setting of “Automatically close connection after being hidden for 5 mins” being ON, but I switched this OFF and the problem of the device_tracker connection being lost still happens.

At the time of the disconnect, the Companion app on the iPhone6 is not the foreground app (it’s running in the background).

When the iPhone6 device_tracker disconnects, it also seems to cause a problem with the Mi10TLite device_tracker. Although the Companion app on my Mi10TLite it’s still updating my GPS location to my HomeAssistant server, it seems to think the ‘previous’ location is at the point where my iPhone6 lost it’s connection. This results in a back-and-forth ‘fan tail’ of breadcrumb tracks on the Map card showing my Mi10TLite track. This continues until I take the iPhone6 out of my pocket & force it to reconnect by doing a ‘swipe-down’ to refresh the Companion app.

Everything then works for a few minutes & then the iPhone6 disconnects again and then causes the ‘fan tail’ track issue on my Mi10TLite.

I tried to resolve this problem using an Automation to update the location on my iPhone6 every 20 seconds. This works perfectly, but it doesn’t stop the iPhone6 Companion app seemingly disconnecting.

alias: iPhone 20secs » update tracker
description: ""
trigger:
  - platform: time_pattern
    seconds: /20
condition: []
action:
  - service: notify.mobile_app_iphone6
    data:
      message: request_location_update
  - service: homeassistant.update_entity
    metadata: {}
    data: {}
    target:
      entity_id: device_tracker.iphone6
mode: single

I have made another observation which seems relevant:

When I first open the Companion app on my iPhone6 after establishing a working Bluetooth connection between iPhone6 & Mi10TLite, very often the display is shown in ‘Light’ mode, even although I normally have it set to ‘Dark’ mode. I discovered that when it changes to Light mode, it is also resetting the “Automatically close connection after being hidden for 5 mins” back to ON. I presume there is something odd going on with the user settings when the iPhone6 Companion app connects over Bluetooth?? Perhaps something to do with tokens??

Whenever I open the iPhone6 Companion app, I now check that the “Automatically close connection…” option is OFF, but this doesn’t resolve the connection lost issue.

So basically, I want to know how to ensure the iPhone6 Companion app DOESN’T keep losing it’s connection to my HomeAssistant server when operating over a Bluetooth shared 4G data link?


Bit more information in the two attached images.

Label No.1 shows where the iPhone6 device_tracker disconnected and in the second image, this then starts the ‘fan tail’ device_tracker on my Mi10TLite.

When I notice this has happened, I perform a manual refresh on the iPhone6 and put it back in my pocket. This fixes the problem for a few minutes and then it happens again as shown by Label No. 2.


I’ve also noticed something a bit odd in the actual Map card track as indicated in these two images.

You can see the last point logged in the Map card track on the iPhone6 is shown as happening at 08:27:20, but this isn’t correct - as can be seen in the iPhone6 location history debug log, it actually disconnected at 08:18:20 and the location logged at 08:27:24 was after I reconnected the iPhone6 by performing a swipe-down to refresh. So, in other words, the new location logged after a swipe-down refresh is appearing at the point where the connection had previously been lost.

I don’t know if this is a Map card display issue or the actual device_tracker data?

One more detail that I am beginning to wonder if could be relevant:

I’m logged in on both the Mi10TLite & iPhone6 Companion apps as the SAME user. Perhaps I should try creating a new HomeAssistant user specific for the iPhone6 and log in the iPhone6 Companion app using that user?

Check your powersave setting on your iPhone.
Also check the app permissions in the iPhone settings.

On iOS 12.5.7 (iPhone6) there is only ‘Low Power Mode’ which is OFF.

And HomeAssistant has ‘Location’ permission ‘Always’ and ‘Background App Refresh’ is ON.

As far as I can tell, I have all necessary permissions etc granted. The Companion app works fine in the background for several minutes, it’s only after about 5mins or so that it disconnects.

Maybe it is just not possible to do it.
Apple supports current version of their OS and two versions back.
Older versions are not supported in their developer tools, so coding to those devices are hard if not impossible.
It is Apple that sets this limitation.

So I created a separate user to use on my iPhone6 as a tracker & it stops the ‘fan tail’ behaviour going on with the original user account on my Mi10TLite device_tracker (see attached image).

But still the iPhone6 Companion app over shared Bluetooth connection, keeps disconnecting after a few minutes. And it seems to do this even when it’s the foreground app (although I haven’t yet tried keeping the iPhone screen on to see if doing so stops it disconnecting).

I gave up trying to get Home Assistant device_tracker to work on iOS 12.5.7 over a Bluetooth Hotspot.

Instead, I installed the iCloud3 integration and it works fine (which I think demonstrates that my issues above are issues with the Home Assistant Companion app device_tracker on iOS 12.5.7).