iOS icon indicating copy to clipboard operation
iOS copied to clipboard

Many entries in integration for the same phone

Open WayneManion opened this issue 1 year ago • 44 comments

Model Name: iPhone15,3 (I think this is an iPhone 14 Pro Max) Software Version: 17.5.1 App version: 2024.6

Home Assistant Core Version Core 2024.7.3 Supervisor 2024.06.2 Operating System 12.4 Frontend 20240710.0

Describe the bug I have a Motorola Android phone with the Android Home Assistant Companion (AHAC) app. It works fine. I have the AHAC app on my old TCL Android phone. My daughter uses this phone as a media player and to play games sometimes. It also works fine. My mom doesn't lives by herself. I have the iOS Home Assistant Companion (iHAC) app installed on her phone so I can keep track of her when she picks up my daughter from day care. My mom is fully aware of the device tracking. This also works more or less OK. I have to remind my mom every so often to open the iHAC app just so it keeps talking.

My wife has an iPhone with the iHAC. It does not behave. The device tracker functionality works extremely poorly. We have been using Home Assistant for at least the last five years. She has been using the iHAC app for multiple years on multiple different iPhone models. The device tracking has never worked very well.

I have deleted the phone in the Home Assistant UI and she has uninstalled and reinstalled the iHAC app on her phone. A couple weeks ago when trying to troubleshoot a device tracker problem for the 1000th time, I noticed in the UI page for the Mobile Phone integration that there were many devices all called "Christie's iPhone". Some of these devices had no entities. Some had a single entity (a device_tracker entity to add insult to injury). A couple of the "Christie's iPhone" devices had 15-17 entities of the normal types (binary_sensor, device_tracker, sensor).

I deleted all of the iPhone devices using the Home Assistant web UI. If I remember correctly it took a couple cycles of Home Assistant core restarts to get rid of them all.

Yesterday I was fruitlessly trying once again to figure out why her phone does such a bad job reporting location when I saw many devices again. I believe there were 15 "Christie's iPhone" devices with zero entities, one with a single entity, and three "Christie's iPhone" devices with 15-17 entities each.

How can I keep this from happening?

To Reproduce Delete the "Christie's iPhone" devices. Wait a few days. There will once again be additional devices. These devices may have zero, one, or many associated entities.

Expected behavior A single device called "Christie's iPhone" that works reliably.

Screenshots

Additional context

Screenshot from 2024-07-24 09-55-02 Screenshot from 2024-07-24 09-55-27

WayneManion avatar Jul 24 '24 15:07 WayneManion

I deleted all the "Christie's iPhone" entries in the Mobile app integration web UI and then rebooted the HassOS box. Now it looks like this: Screenshot from 2024-07-24 10-36-23

WayneManion avatar Jul 24 '24 15:07 WayneManion

Screenshot from 2024-07-24 10-40-05

WayneManion avatar Jul 24 '24 15:07 WayneManion

I was able to remove all of the extra Christie's iPhone entries, but I had to remove them one at a time, restarting Home Assistant in between every time. If I deleted more than one entry in one go, the deletion did not work.

WayneManion avatar Jul 24 '24 18:07 WayneManion

About the location update: Can you explain how is your setup? How do you exposed HA for remote access, how is it configured in the app. If you check the app permissions, is location allowed "Always" and for "precise location"? Do you have zones configured? iOS works best zone-based, entering and exiting zones.

About the integrations entries: I am not sure why it endup like this, I'll investigate, but just double checking, right now you were able to remove them all and there is just one entry for your wife's phone, correct?

bgoncal avatar Jul 25 '24 11:07 bgoncal

I am a Nabu Casa subscriber. She accesses Home Assistant remotely using the UUID-style Nabu Casa server address. We have also tried using Tailscale in the past. I will check the app permissions when she comes home later.

I do have zones set up in Home Assistant. There is a zone set up for her workplace as well as several other places she frequents.

I was able to remove all of the old "Christie's iPhone" entries. The only way I could get rid of them was to use the three dots to delete one, restart Home Assistant, and then repeat. This was something along the lines of 20 Home Assistant core restarts.

WayneManion avatar Jul 25 '24 16:07 WayneManion

We looked at her settings and as far as I can tell we have the permissions on her phone set correctly. 854407e5-68be-4f8a-9906-e41b6542cb85 71928d35-5319-4975-b985-8c6028179bb8

WayneManion avatar Jul 26 '24 12:07 WayneManion

It is just a couple days later and there are already six "Christie's iPhone" entries appearing in the web UI for the Mobile app integration.

WayneManion avatar Jul 28 '24 17:07 WayneManion

Can you share your Wife's HA app logs? I can't reproduce the issue on my side

bgoncal avatar Jul 29 '24 12:07 bgoncal

Where do I go to obtain these logs? Are they on my wife's phone somewhere? I never mess with Apple stuff, so I am pretty unfamiliar with how one would find such logs.

WayneManion avatar Jul 30 '24 14:07 WayneManion

Companion app settings >> debugging >> export logs

bgoncal avatar Jul 30 '24 14:07 bgoncal

Your logs weren't uploaded, please try again

bgoncal avatar Aug 05 '24 09:08 bgoncal

Perfect, thanks, I'll get back to you after looking at it, how does the integration list looks now? All cluttered with your wife's phone entries?

bgoncal avatar Aug 05 '24 14:08 bgoncal

Yes, it is still a awash with "Christie's iPhone" entries.

WayneManion avatar Aug 05 '24 15:08 WayneManion

Btw, my bad I should have asked you to send the logs in private since they have sensitive information to stay public in GitHub, please feel free to delete it and send to me [email protected]

bgoncal avatar Aug 05 '24 16:08 bgoncal

Btw, my bad I should have asked you to send the logs in private since they have sensitive information to stay public in GitHub, please feel free to delete it and send to me [email protected]

Done.

WayneManion avatar Aug 05 '24 16:08 WayneManion

Wayne, did you disable "iOS" integration? I see in the logs it is not loaded

bgoncal avatar Aug 06 '24 12:08 bgoncal

Wayne, did you disable "iOS" integration? I see in the logs it is not loaded

Not that I can remember.

Screenshot from 2024-08-06 09-36-05 Just now I went to the Integrations page in the web UI. I clicked 'Add integration' and searched for iOS. I found 'Home Assistant iOS'. I clicked that. Screenshot from 2024-08-06 09-33-40

I got a dialog that said: "Do you want to start setup?". I clicked the only option, "submit". Screenshot from 2024-08-06 09-33-22

I did all of this in Brave Browser on my Arch Linux desktop machine fwiw. Do I need to use an iOS device to set this up?

WayneManion avatar Aug 06 '24 14:08 WayneManion

This should have been configured automatically when you setup and iOS device, so currently there is no active iOS integration on your list?

bgoncal avatar Aug 06 '24 14:08 bgoncal

Screenshot from 2024-08-06 09-37-49 I would expect to see "Home Assistant iOS" or "iOS" in this list, so... no. There does not appear to be an active iOS integration.

We have been using Home Assistant for years. Over this time, lots of stuff has changed, but the configuration.yaml and all that stuff has been like a Ship of Theseus.

Clarification: we have been using Home Assistant since before there was an iOS app.

WayneManion avatar Aug 06 '24 14:08 WayneManion

Can you try to add the iOS integration again and then check your HA Core logs to see if there is anything relevant there?

bgoncal avatar Aug 06 '24 14:08 bgoncal

This is the last 100 lines from the log file after failing to set up the iOS integration (I was using Firefox this time):

    has_devices = await cast(
                  ^^^^^^^^^^^
TypeError: object bool can't be used in 'await' expression
2024-08-06 09:54:52.877 WARNING (SyncWorker_36) [py.warnings] /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:1063: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.1.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(

2024-08-06 09:54:54.064 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 255, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
    update_callback()
  File "/config/custom_components/opnsense/__init__.py", line 470, in process_entities
    entities = self.process_entities_callback(self.hass, self.config_entry)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/opnsense/switch.py", line 179, in process_entities_callback
    key="service.{}.{}".format(service["name"], property),
                               ~~~~~~~^^^^^^^^
KeyError: 'name'
2024-08-06 09:55:23.877 WARNING (SyncWorker_34) [py.warnings] /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:1063: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.1.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(

2024-08-06 09:55:25.141 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 255, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
    update_callback()
  File "/config/custom_components/opnsense/__init__.py", line 470, in process_entities
    entities = self.process_entities_callback(self.hass, self.config_entry)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/opnsense/switch.py", line 179, in process_entities_callback
    key="service.{}.{}".format(service["name"], property),
                               ~~~~~~~^^^^^^^^
KeyError: 'name'
2024-08-06 09:55:27.840 ERROR (MainThread) [frontend.js.latest.202407100] Uncaught error from Firefox 128.0 on Linux x86_64
ReferenceError: Polymer is not defined
/hacsfiles/fan-control-entity-row/fan-control-entity-row.js:9:1
2024-08-06 09:55:39.738 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_flow.py", line 70, in async_step_confirm
    has_devices = await cast(
                  ^^^^^^^^^^^
TypeError: object bool can't be used in 'await' expression

WayneManion avatar Aug 06 '24 14:08 WayneManion

That looks very unrelated unfortunately, I see on your screenshot that you have only 4 devices under mobile_app integraton, did you clean up again?

bgoncal avatar Aug 06 '24 15:08 bgoncal

No. The extra entries are still there. I guess there are multiple "entries" for the same "device".

Screenshot from 2024-08-06 10-04-12

WayneManion avatar Aug 06 '24 15:08 WayneManion

Maybe this is more relevant:

2024-08-06 10:06:55.525 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_flow.py", line 70, in async_step_confirm
    has_devices = await cast(
                  ^^^^^^^^^^^
TypeError: object bool can't be used in 'await' expression

WayneManion avatar Aug 06 '24 15:08 WayneManion

Unfortunately it also looks unrelated, I am still trying to find something in your logs that could explain that but I could not find it yet.

While I do that if you have time (I know it's boring and annoying to ask your wife's phone haha), I would like to see if the same behavior would happen doing the following:

  • Open HA App on her phone, open companion App settings and remove the server
  • Uninstall the App
  • Reboot her phone (this is important)
  • Remove the entries from Home Assistant mobile_app integration
  • Reboot HA
  • Install latest iOS HA App beta from Testflight: https://testflight.apple.com/join/1AlPbnLZ
  • Monitor what happens.

If you also have another iOS device you could try and check how it behaves, it would be nice to find a pattern.

bgoncal avatar Aug 06 '24 15:08 bgoncal

I will try to give that a shot when she is home later.

Reminder: my mom's phone is also connected to our HA instance. She has her own house, so getting a hold of her phone to do this stuff is more challenging. I would have to do all of this stuff on her phone, it would be difficult or impossible to guide her through it.

WayneManion avatar Aug 06 '24 15:08 WayneManion

But your mom's iPhone is working well right? Or did I misunderstood?

bgoncal avatar Aug 06 '24 19:08 bgoncal

But your mom's iPhone is working well right? Or did I misunderstood?

I bring it up to ask if I need to jump through the same set of hoops on my mom's phone as well.

WayneManion avatar Aug 06 '24 20:08 WayneManion

No need, just your wife's

bgoncal avatar Aug 07 '24 08:08 bgoncal

We followed the removal and re-installation steps. I emailed you a copy of the Home Assistant server log file that was generated during the iOS setup and server configuration process.

When my wife set up the server in the phone app she said the server address was already populated. Would this have come from some kind of network probe? Or would it have been left over from the previous install of the app?

Does the testflight version of the Home Assistant Companion app have additional logging enabled?

WayneManion avatar Aug 08 '24 19:08 WayneManion