core: Homekit integration is mixing up IP addresses unpon disconnect, won't reestablish connection until HA is restarted
The problem
I use the homekit integration to control 3 ecobee thermostats. 2 of them routinely become unavailable, and don’t become available again until I fully restart home assistant.
All 3 thermostats have static IP addresses assigned by my router (eero), and those are correctly mapped out in core.config_entries:
- “Upstairs” is 192.168.5.35
- “Bedroom” is 192.168.5.34
- “Downstairs” is 192.168.5.33
Looking at the logs (attached below), the homekit integration is mixing these IP addresses up. For example, the log snippet provided below is for an “Upstairs” reload attempt. It starts with address='192.168.5.33', addresses=['192.168.5.33', '192.168.5.35', '192.168.5.34'.... The initial IP address it has for it is the address for “Downstairs,” which is also offline. Interesting that the “addresses” array includes all 3 of them, however.
The log also mentions “Host changed from 192.168.5.34 to 192.168.5.33”, neither of which are correct for “Upstairs”.
Again, restarting home assistant fixes everything (until it stops working again, every day or two).
What version of Home Assistant Core has the issue?
core-2023.2.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
HomeKit Controller
Link to integration documentation on our website
https://www.home-assistant.io/integrations/homekit_controller/
Diagnostics information
Here are the diagnostic information files for all 3 thermostats after a restart, so that they are all connected (I can’t download diagnostics when they are experiencing this problem):
config_entry-homekit_controller-70f6fd12f888ad1e5b13d0735370140a.json.txt config_entry-homekit_controller-0edcd1e466d68eb3608db4268622a0b6.json.txt config_entry-homekit_controller-ca96e93bdd37d645e132d739c68c697f.json.txt
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Log snippet:
2023-02-18 09:33:38.460 DEBUG (MainThread) [aiohomekit.controller.abstract] [192.168.5.34:35345] (id=69:69:EE:76:87:26): Description updated: old=None
new=HomeKitService(name='Bedroom', id='69:69:ee:76:87:26', model='ECB501', feature_flags=<FeatureFlags.SUPPORTS_APPLE_AUTHENTICATION_COPROCESSOR: 1>,
status_flags=<StatusFlags.0: 0>, config_num=3, state_num=30, category=<Categories.THERMOSTAT: 9>, protocol_version='1.1', type='_hap._tcp.local.', ad
dress='192.168.5.33', addresses=['192.168.5.33', '192.168.5.35', '192.168.5.34', 'fe80::4661:32ff:fe66:4ae9', 'fd85:caf7:a066:1:4661:32ff:fe66:4ae9',
'fe80::4661:32ff:fe7b:6af8', 'fd85:caf7:a066:1:4661:32ff:fe7b:6af8', 'fe80::4661:32ff:fe44:41e6', 'fd85:caf7:a066:1:4661:32ff:fe44:41e6'], port=35345)
2023-02-18 09:33:38.460 DEBUG (MainThread) [aiohomekit.controller.abstract] [192.168.5.34:35345] (id=69:69:EE:76:87:26): Disconnected event notificati
on received; Triggering catch-up poll
2023-02-18 09:33:38.460 DEBUG (MainThread) [aiohomekit.zeroconf] 69:69:EE:76:87:26: Device rediscovered
2023-02-18 09:33:38.461 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Starting reconnect loop to 192.168.5.34:35345
2023-02-18 09:33:38.461 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Host changed from 192.168.5.34 to 192.168.5.33
2023-02-18 09:33:38.461 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Attempting connection to 192.168.5.33:35345
2023-02-18 09:33:38.465 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Connecting to accessory failed. Retrying in 0 seconds
2023-02-18 09:33:39.217 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Attempting connection to 192.168.5.33:35345
2023-02-18 09:33:39.223 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Connecting to accessory failed. Retrying in 0 seconds
2023-02-18 09:33:40.351 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Attempting connection to 192.168.5.33:35345
2023-02-18 09:33:40.355 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Connecting to accessory failed. Retrying in 1 seconds
2023-02-18 09:33:41.459 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Attempting connection to 192.168.5.34:38955
2023-02-18 09:33:41.463 DEBUG (MainThread) [aiohomekit.controller.ip.connection] Connecting to accessory failed. Retrying in 3 seconds
2023-02-18 09:33:41.537 ERROR (MainThread) [aiohomekit.utils] Failure running background task: Task-281652
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/pairing.py", line 137, in _ensure_connected
await self.connection.ensure_connection()
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 280, in ensure_connection
await asyncio.shield(self._connector)
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/pairing.py", line 136, in _ensure_connected
async with asyncio_timeout(10):
File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 129, in __aexit__
self._do_exit(exc_type)
File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 212, in _do_exit
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohomekit/utils.py", line 35, in _handle_task_result
task.result()
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/pairing.py", line 398, in _process_config_changed
await self.list_accessories_and_characteristics()
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/pairing.py", line 165, in list_accessories_and_characteristics
await self._ensure_connected()
File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/pairing.py", line 139, in _ensure_connected
raise AccessoryDisconnectedError(
aiohomekit.exceptions.AccessoryDisconnectedError: Timeout while waiting for connection to device 192.168.5.34:38955
Additional information
The relevant section of core.config_entries is below:
{
"entry_id": "70f6fd12f888ad1e5b13d0735370140a",
"version": 1,
"domain": "homekit_controller",
"title": "Upstairs",
"data": {
"AccessoryPairingID": "B3:76:7B:5B:17:80",
"AccessoryLTPK": "redacted",
"iOSPairingId": "redacted",
"iOSDeviceLTSK": "redacted",
"iOSDeviceLTPK": "redacted",
"AccessoryIP": "192.168.5.35",
"AccessoryPort": 41859,
"Connection": "IP"
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "zeroconf",
"unique_id": "b3:76:7b:5b:17:80",
"disabled_by": null
},
{
"entry_id": "ca96e93bdd37d645e132d739c68c697f",
"version": 1,
"domain": "homekit_controller",
"title": "Bedroom",
"data": {
"AccessoryPairingID": "69:69:EE:76:87:26",
"AccessoryLTPK": "redacted",
"iOSPairingId": "redacted",
"iOSDeviceLTSK": "redacted",
"iOSDeviceLTPK": "redacted",
"AccessoryIP": "192.168.5.34",
"AccessoryPort": 35345,
"Connection": "IP"
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "zeroconf",
"unique_id": "69:69:ee:76:87:26",
"disabled_by": null
},
{
"entry_id": "0edcd1e466d68eb3608db4268622a0b6",
"version": 1,
"domain": "homekit_controller",
"title": "Downstairs",
"data": {
"AccessoryPairingID": "FE:7F:39:C0:CB:86",
"AccessoryLTPK": "redacted",
"iOSPairingId": "redacted",
"iOSDeviceLTSK": "redacted",
"iOSDeviceLTPK": "redacted",
"AccessoryIP": "192.168.5.33",
"AccessoryPort": 38955,
"Connection": "IP"
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "zeroconf",
"unique_id": "fe:7f:39:c0:cb:86",
"disabled_by": null
},
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 25 (12 by maintainers)
2023.4.0b7 has the change in case there is a chance it fixes this issue
Its a slim change that this is the issue, but its possible that the ecobee announces the wrong server name and than announces the right one.
We don’t handle that correctly in zeroconf right now
I’m fixing that in https://github.com/python-zeroconf/python-zeroconf/pull/1154
I will open a PR to aiohomekit after I get zeroconf updated.
Again its a slim chance that this the issue but its a non-zero chance so I’m mentioning it.