home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.15k stars 31.12k forks source link

Homekit controller failing to reconnect after long power cut #86279

Closed Dtrotmw closed 1 year ago

Dtrotmw commented 1 year ago

The problem

I had a long power cut yesterday and the Homekit controller which provides access to a Heatmiser NeoHub wont reconnect. The network is working fine and the router reports the hub still connected to the same IP address.
The supplier has reset the device & I've pressed "pair" on the hub. The Android app provided by Heatmiser is still working.

What version of Home Assistant Core has the issue?

Home Assistant 2023.1.6 Supervisor 2022.12.1 Operating System 9.4 Frontend 20230110.0 - latest

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Apple Homekit

Link to integration documentation on our website

https://www.home-assistant.io/integrations/homekit_controller

Diagnostics information

home-assistant_homekit_controller_2023-01-20T10-55-20.303Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @jc2k, @bdraco, mind taking a look at this issue as it has been labeled with an integration (homekit_controller) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `homekit_controller` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign homekit_controller` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


homekit_controller documentation homekit_controller source (message by IssueLinks)

Jc2k commented 1 year ago

When you say reset, have they reset HomeKit? And then you have removed the integration in HA and re-added it?

Dtrotmw commented 1 year ago

Heatmiser have reset the Homekit so it now appears as an unpaired device that I tried adding (add integration>Apple>Homekit Controller>Device Selection> Heatmiser neoHub>submit). On the page asking for the pairing code it displays

An unhandled error occurred while attempting to pair with this device. This may be a temporary failure or your device may not be supported currently: Connection closed

And it won’t accept the pairing code.

Jc2k commented 1 year ago

The log that you attached doesn't show that - can you show me a pairing failure log please?

Your log does shows /pair-verify attempts. It looks like we are either unable to hold a connection to the device or the homekit service on the device is closing the connection without answering.

So this is sounding like the last ticket you raised - #85317 (unexplained connection closed errors).

If there aren't connectivity issues with the device, and you have verified the ports being used are correct with the Service Browser app or similar like before, then I think your hub is in a weird state still and not serving HomeKit properly.

Dtrotmw commented 1 year ago

I think this is the log entry you asked for:

2023-01-20 11:42:36.667 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 491, in async_step_pair
    self.finish_pairing = await discovery.async_start_pairing(self.hkid)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/discovery.py", line 62, in async_start_pairing
    response = await self.connection.post_tlv(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 391, in post_tlv
    response = await self.post(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 355, in post
    return await self.request(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 450, in request
    resp = await self.protocol.send_bytes(request_bytes)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 81, in send_bytes
    return await result
aiohomekit.exceptions.AccessoryDisconnectedError: Connection closed
2023-01-20 11:43:03.393 ERROR (MainThread) [homeassistant.components.homekit_controller.config_flow] Pairing attempt failed with an unhandled exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/homekit_controller/config_flow.py", line 491, in async_step_pair
    self.finish_pairing = await discovery.async_start_pairing(self.hkid)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/discovery.py", line 62, in async_start_pairing
    response = await self.connection.post_tlv(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 391, in post_tlv
    response = await self.post(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 355, in post
    return await self.request(
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 450, in request
    resp = await self.protocol.send_bytes(request_bytes)
  File "/usr/local/lib/python3.10/site-packages/aiohomekit/controller/ip/connection.py", line 69, in send_bytes
    raise AccessoryDisconnectedError("Transport is closed")
aiohomekit.exceptions.AccessoryDisconnectedError: Transport is closed
Jc2k commented 1 year ago

I need more, that doesn't give me the context. It just tells me that your hub dropped the connection.

Dtrotmw commented 1 year ago

That's all that is in either log file with that timestamp (.log and .log.1). Where do I find what you need?

Jc2k commented 1 year ago

How did you get the log files you attached to the original bug report?

Dtrotmw commented 1 year ago

By selecting "enable debug logging" at the integration. The supplier issued another reset and I've now successfully added the integration, so you were right in thinking it was some wierd state in the neohub. The trouble is I've now got a second set of 49 entities with the _2 suffix. Is there any simple way I can avoid re-building everything I've used that refers to them?

Jc2k commented 1 year ago

In HA there are entities and devices. It sounds like you have duplicated entities but from your description I don't know if you have duplicate devices. Are you able to post screenshots of this from your device page?

Dtrotmw commented 1 year ago

image 2 copies of all the Heatmiser devices!

Dtrotmw commented 1 year ago

All sorted now after a session of changing all the entity names. It seems I managed to keep all the histories which was a big win. Thank you so much for all your help. it is much appreicated.