OH3 HomeKit bug? fails after network down/up

Greetings. I have an OH server connected to the UPS, but not a network switch (since there is not enough UPS power). I noticed that in the event of a power outage and restoration, the HomKit stops working (all devices are unavailable). All other OH services continue to operate normally. It seems that the loss of a network connection for a long period leads to such a situation.

2 Likes

Just had exactly this - network connection wire was pulled; replacing it restored connectivity, but Homekit devices all still absent.

SImilar machine with homebridge survived ok.

Update: I fixed it temporarily by using the console:

openhab> bundle:services |grep Homekit
openHAB Add-ons :: Bundles :: IO :: Homekit (273) provides:
[org.openhab.io.homekit.Homekit]
openhab> bundle:restart 273

I wonder if this is actually the root cause of a lot of the homekit add-on instability.

@11169 @nigel_magnay thank you for the reporting and investigation.
the fix is submitted, so, with the next release homekit binding should survive network losses.

1 Like

This doesnā€™t solve my issue.

and what kind of issue you have?

After running for 1-2 days HomeKit returns ā€œNo responseā€ for each accessories. Iā€™m on OH3.1 stable. No matter how many times I reboot OH server, HomeKit canā€™t connect to OH.

if restarts does not help then it is either network issue or ios device has changed his ID/address

Yes, i went through this. The following condition met. FYI. I have done this for 3 times already until i fed up to do as i always need to reconfigure all the rooms for accessories. Yes, Use private WiFi is always OFF

`

  • if you see openHAB bridge and sf is equal 1 but you dont see openHAB in home app, probably you home app still think it is already paired with openHAB. remove your home from home app and restart iOS device.

`

Also, this is a case where HomeKit and Openhab has already completed pairing and working for 1-2 days. My previous message refered to this didnt work:

openhab> bundle:services |grep Homekit
openHAB Add-ons :: Bundles :: IO :: Homekit (273) provides:
[org.openhab.io.homekit.Homekit]
openhab> bundle:restart 273

sorry, still no sure i got it correctly.
just to confirm my understanding.
you have 2 issues:

  1. you lose homekit accessories after 2-3 days and openHAB restart does not help.
    this is strange. openhab restart should fix it. only if the pairing got lost, e.g. for some reasons ios device got different id or homekit.json file lost ā€œuserā€ entry
  2. the commands to restart bundle does not work for you.
    which of two commands is not working?
    bundle:services |grep Homekit
    or
    bundle:restart <id_your_got_from_first_command>
  1. you lose homekit accessories after 2-3 days and openHAB restart does not help.
    this is strange. openhab restart should fix it. only if the pairing got lost, e.g. for some reasons ios device got different id or homekit.json file lost ā€œuserā€ entry

Apparently this is the case

  1. the commands to restart bundle does not work for you.
    which of two commands is not working?
    3.bundle:services |grep Homekit*
    or
    4.bundle:restart <id_your_got_from_first_command>*
  1. is working, 4 is working but it doesnt resolve the issue. I am still getting ā€œNo Responseā€

ok. got you. yes, if restart of openHAB does not solve it, then restart of the bundle or my latest fix for network disruption will not fix it.

if private address is disable, then the homekit.json file got broken. find on openHAB server the file homekit.json and check whether it has ā€œuserā€ entry in it.
alternative, check the openhab log file - it should have record with ā€œUnknown userā€ or so.

there were several report about broken homekit.json file. but we could not reproduce it or fix it. it happens randomly.
the only workaround

  • pair ios device
  • ensure you have ā€œuserā€ entry in homekit.json
  • make a copy of/backup homekit.json
  • next time you get ā€œno responseā€ restore the homekit.json file and restart OH (or only the bundle)
1 Like

Alright. I reconfigure everything and see whether the issue happens again. Will try your fix and see whether the problem will reoccur. Cheers

Had exactly the same behaviour and found this. So backed-up homekit.json and when it happened again, the user part was missing. Stopped OH, re-added just the user part

"user_32:some more numbers and :": {
      "class": "java.lang.String",
      "value": "some value"
    }

into homekit.json - started OH - and everything was online again. I setup logging at that point but hadnā€™t had any issues from that point on ā€¦ happily online for 4 or 5 weeks now ā€¦

Iā€™m using homepod mini if that makes any difference ā€¦

@lsafelix75 @crnjan
this PR

will add homekit binding setting to disable deletion of the user information by binding. this will also blocks unpairing, but if setup is done then usually you dont unpair/re-pair

it is still not 100% clear whether the user information gets deleted from homekit.json by binding or by something else. but with this setting we could at least exclude binding from potential root causes.

1 Like

After re-paired last night and this morning wokeup with ā€œno responseā€ error. and @crnjan is right, the following field and value is missing:

"user_32:some more numbers and :": {
      "class": "java.lang.String",
      "value": "some value"
    }

i know it is painful to re-pair. but could you please check following

  • if homekit accessories are working now, check homekit.json for user entry. you can make a copy of the entry/file if you like
  • if the user entry is there, try to find our what could have deleted itā€¦ e.g. try to restart openHAB, repeat step from last night or just wait until next morning. any hints what could be root cause would help to fix this issue.

Would it help to lock the file on filesystem level? Ie chown to root and set to read only?

maybe, but only if you complete done with the setup. homekit binding stores there not only the user but also the count of accessories and configuration version. every time you add new homekit accessories it would update the count and increase the configuration version.

1 Like

Thanks @yfre for implementing this change, thatā€™s exactly the error pattern I observed: After every restart of my Unifi switch (and therefor loss of network connection) openHAB HomeKit was down.