Couldn't connect to Homekit Bridge

Hi!

I’ve been using Homekit integration for 9 month but after upgrade to 2021.4 it stopped working. Then I removed integration and created new in configuration.yaml:

homekit:
  name: "HKTest"
  port: 51839
  filter:
    include_entities:
      - demo.demo

Also removed homekit.HASH.state in /config/.storage dir. After that I’ve restarted HA and tried to add accessory in new home, but connection failed.

Logs from HA:

2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.characteristic] set_value: Name to HKTest
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to default
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.characteristic] set_value: FirmwareRevision to 2021.4.6
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.characteristic] set_value: Manufacturer to Home Assistant
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.characteristic] set_value: Model to Bridge
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to homekit.bridge
2021-04-27 13:58:40 INFO (SyncWorker_30) [pyhap.accessory_driver] Loading Accessory state from `/config/.storage/homekit.ad65359f92ea85c57c86481ce7440b33.state`
2021-04-27 13:58:40 DEBUG (MainThread) [homeassistant.components.homekit] Driver start for HKTest
2021-04-27 13:58:40 INFO (MainThread) [pyhap.accessory_driver] Starting accessory HKTest on address 192.168.88.252, port 51839.
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.accessory_driver] Starting server.
2021-04-27 13:58:40 DEBUG (MainThread) [pyhap.accessory_driver] Starting mDNS.
2021-04-27 13:58:41 DEBUG (MainThread) [pyhap.accessory_driver] Starting accessory HKTest
2021-04-27 13:58:41 DEBUG (MainThread) [pyhap.accessory_driver] AccessoryDriver for HKTest started successfully
2021-04-27 13:58:41 INFO (MainThread) [homeassistant.components.homekit.util] Pincode: 395-11-469

I haven’t seen any logs when Home app tried to connect. Curl example (url in Safari from iOS also works):

➜  ~ curl 192.168.88.252:51839
{"status": -70402}%

Could you help please?

Did you try with demo.demo literally?

Yes. It was the last step in my research.

demo. is no valid domain and so I think this is the reason why.

There is an error in documentation?

Fascinating. I never read the page to the end. Anyway, I would try it with an existing entity.

Tried to add only occupancy sensors, saw it in logs, but Home App still can’t connect.

homekit:
  name: "HKTest"
  port: 51839
  filter:
    include_entity_globs:
      - binary_sensor.*_occupancy
2021-04-27 17:51:51 DEBUG (MainThread) [homeassistant.components.homekit] Driver start for HKTest
2021-04-27 17:51:51 INFO (MainThread) [pyhap.accessory_driver] Starting accessory HKTest on address 192.168.88.252, port 51839.
2021-04-27 17:51:51 DEBUG (MainThread) [pyhap.accessory_driver] Starting server.
2021-04-27 17:51:51 DEBUG (MainThread) [pyhap.accessory_driver] Starting mDNS.
2021-04-27 17:51:52 DEBUG (MainThread) [pyhap.accessory_driver] Starting accessory HKTest
2021-04-27 17:51:52 DEBUG (MainThread) [pyhap.accessory_driver] AccessoryDriver for HKTest started successfully
2021-04-27 17:51:52 INFO (MainThread) [homeassistant.components.homekit.util] Pincode: 649-50-529
2021-04-27 17:51:52 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_bathroom_occupancy=off; friendly_name=Датчик движения_occupancy, device_class=motion @ 2021-04-27T17:51:04.954845+03:00>
2021-04-27 17:51:52 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_dressing_room_occupancy=off; friendly_name=Датчик движения_occupancy, device_class=motion @ 2021-04-27T17:51:04.955956+03:00>
2021-04-27 17:52:36 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_bathroom_occupancy=off; battery=100, illuminance=7, illuminance_lux=7, linkquality=244, occupancy=False, temperature=26, voltage=3065, friendly_name=Датчик движения_occupancy, device_class=motion @ 2021-04-27T17:51:04.954845+03:00>
2021-04-27 17:52:36 DEBUG (MainThread) [pyhap.characteristic] set_value: BatteryLevel to 100.0
2021-04-27 17:52:40 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_dressing_room_occupancy=off; battery=100, illuminance=0, illuminance_lux=0, linkquality=248, occupancy=False, temperature=25, voltage=3065, friendly_name=Датчик движения_occupancy, device_class=motion @ 2021-04-27T17:51:04.955956+03:00>
2021-04-27 17:52:40 DEBUG (MainThread) [pyhap.characteristic] set_value: BatteryLevel to 100.0

So that there are no misunderstandings: The ‚home‘ app detected the HA bridge properly? (QR code)

It starts connecting after QR code scan, after 2 minutes the error appears and there is no any messages in logs. That’s strange because even I use curl I see messages.

Would you please try ‚naked‘?


homekit:
  name: Home Assistant
  filter:
    include_entities:
      - binary_sensor.motion_bathroom_occupancy


All logs were before adding accessories in Home app, after adding there is no logs.

2021-04-27 23:20:21 DEBUG (MainThread) [homeassistant.components.homekit] Begin setup HomeKit for Home Assistant
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: Name to Home Assistant
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to default
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: FirmwareRevision to 2021.4.6
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: Manufacturer to Home Assistant
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: Model to Bridge
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to homekit.bridge
2021-04-27 23:20:47 DEBUG (MainThread) [homeassistant.components.homekit.accessories] Add "binary_sensor.motion_bathroom_occupancy" as "BinarySensor"
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: Name to Датчик движения_occupancy
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to default
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: FirmwareRevision to 2
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: Manufacturer to Xiaomi
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: Model to Aqara human body movement and illuminance sensor (RTCGQ11LM)
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to binary_sensor.motion_bathroom_occupancy
2021-04-27 23:20:47 DEBUG (MainThread) [homeassistant.components.homekit.accessories] binary_sensor.motion_bathroom_occupancy: Found battery level
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.characteristic] set_value: ChargingState to 2
2021-04-27 23:20:47 INFO (SyncWorker_14) [pyhap.accessory_driver] Loading Accessory state from `/config/.storage/homekit.04990aff84a8d10940d12952c6198f3c.state`
2021-04-27 23:20:47 DEBUG (MainThread) [homeassistant.components.homekit] Driver start for Home Assistant
2021-04-27 23:20:47 INFO (MainThread) [pyhap.accessory_driver] Starting accessory Home Assistant on address 192.168.88.252, port 21063.
2021-04-27 23:20:47 DEBUG (MainThread) [pyhap.accessory_driver] Starting server.
2021-04-27 23:20:48 DEBUG (MainThread) [pyhap.accessory_driver] Starting mDNS.
2021-04-27 23:20:48 DEBUG (MainThread) [pyhap.accessory_driver] Starting accessory Home Assistant
2021-04-27 23:20:48 DEBUG (MainThread) [pyhap.accessory_driver] AccessoryDriver for Home Assistant started successfully
2021-04-27 23:20:48 INFO (MainThread) [homeassistant.components.homekit.util] Pincode: 019-51-142
2021-04-27 23:20:48 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_bathroom_occupancy=unavailable; restored=True, supported_features=0, device_class=motion, friendly_name=Датчик движения_occupancy @ 2021-04-27T23:20:46.907566+03:00>
2021-04-27 23:21:00 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_bathroom_occupancy=off; friendly_name=Датчик движения_occupancy, device_class=motion @ 2021-04-27T23:21:00.468720+03:00>
2
2021-04-27 23:21:28 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state binary_sensor.motion_bathroom_occupancy=off; battery=100, illuminance=7, illuminance_lux=7, linkquality=123, occupancy=False, temperature=26, voltage=3065, friendly_name=Датчик движения_occupancy, device_class=motion @ 2021-04-27T23:21:00.468720+03:00>
2021-04-27 23:21:28 DEBUG (MainThread) [pyhap.characteristic] set_value: BatteryLevel to 100.0

Failed the connection once more?

I’m not sure I understand how taking off his clothes would help

It still can’t connect.

Have you tried rebooting your router?

Of course I’ve tried.

In case someone stumbles upon the same issue - restarting the phone & homeassistant fixed it for me.