openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[homekit] All accessories are in "No response" state after upgrade to iOS 16.2 (and Home upgrade) #13949

Closed georgo closed 1 year ago

georgo commented 1 year ago

Expected Behavior

Homekit accessories are available in Home app.

Current Behavior

Hi,

today I upgraded all my devices (incl. my home hub - Apple TV) to iOS 16.2 - Home app asks to upgrade it self, so I did it. Since then, all openHAB accessories are in state "No response"

I tried completely remove homekit from openHAB, incl. deletion of homekit.json file in jsondb directory and called clearPairings

After I try re-pair openHAB again in Home, it successfully find bridge, find all accessories, but all of them remains in "No response" state.

What I noticed in homekit.json is user:

  "user_2e:bd:52:5e:c5:73EF874ABF-3C30-4B6A-86CB-80D3D97A9D12": {
    "class": "java.lang.String",
    "value": "[REDACTED]"
  }

But during pairing, my log i flooded with following error:

2022-12-13 23:12:19.900 [WARN ] [.server.impl.connections.HttpSession] - Exception encountered while verifying pairing
java.lang.Exception: Unknown user: 1EAA342F-4183-49E7-B84E-1055D8D73E95
    at io.github.hapjava.server.impl.pairing.PairVerificationManager.stage2(PairVerificationManager.java:113) ~[bundleFile:?]
    at io.github.hapjava.server.impl.pairing.PairVerificationManager.handle(PairVerificationManager.java:51) ~[bundleFile:?]
    at io.github.hapjava.server.impl.connections.HttpSession.handlePairVerify(HttpSession.java:127) [bundleFile:?]
    at io.github.hapjava.server.impl.connections.HttpSession.handleRequest(HttpSession.java:56) [bundleFile:?]
    at io.github.hapjava.server.impl.connections.ConnectionImpl.doHandleRequest(ConnectionImpl.java:56) [bundleFile:?]
    at io.github.hapjava.server.impl.connections.ConnectionImpl.handleRequest(ConnectionImpl.java:49) [bundleFile:?]
    at io.github.hapjava.server.impl.http.impl.AccessoryHandler.channelRead0(AccessoryHandler.java:52) [bundleFile:?]
    at io.github.hapjava.server.impl.http.impl.AccessoryHandler.channelRead0(AccessoryHandler.java:17) [bundleFile:?]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) [bundleFile:4.1.72.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [bundleFile:4.1.72.Final]
    at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61) [bundleFile:4.1.72.Final]
    at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:370) [bundleFile:4.1.72.Final]
    at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66) [bundleFile:4.1.72.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) [bundleFile:4.1.72.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [bundleFile:4.1.72.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [bundleFile:4.1.72.Final]
    at java.lang.Thread.run(Thread.java:829) [?:?]

^^ where it appears to be more user ids in logs

Possible Solution

I have no idea, what changed in 16.2 in technical terms, but here is some article about it: https://9to5mac.com/2022/10/25/ios-16-2-new-architecture-home-app/ and https://www.homekithelper.net/tips/ios-16-matter-thread-new-architecture

Steps to Reproduce (for Bugs)

  1. Upgrade Apple devices to newest production iOS/iPadOS/...
  2. Open Home app, go to Home settings and upgrade your home (FYI there is no turning back)
  3. openHAB becomes unresponsible

Environment

Running openHAB 3.4.0.M6 (but it didn't work in 3.4.0.M4 either) in docker on Raspberry Pi, with host network mode This is my homekit.cfg:

org.openhab.homekit:port=9123
org.openhab.homekit:pin=123-45-679
org.openhab.homekit:networkInterface=192.168.96.8
org.openhab.homekit:useOHmDNS=false
org.openhab.homekit:blockUserDeletion=false
org.openhab.homekit:name=openHAB

Before upgrade to iOS 16.2 everything works perfect.

ktgeek commented 1 year ago

Can confirm, on zulu's jdk 17, and no issues (in the 8 minutes since my last message)

ccutrer commented 1 year ago

https://github.com/ccutrer/openhab-addons/releases/tag/homekit-20221220-02 should work for 3.4.0+Java 11, but I have not tested it since I require the other unreleased features in my local environment.

update org.openhab.io.homekit https://github.com/ccutrer/openhab-addons/releases/download/homekit-20221220-02/org.openhab.io.homekit-3.4.0-SNAPSHOT.jar
sfranzis commented 1 year ago

Thanks for fixing this. It basically now works for me and my devices stay available. šŸ‘ Two points:


2022-12-21 08:05:39.889 [INFO ] [er.impl.jmdns.JmdnsHomekitAdvertiser] - Registering _hap._tcp.local. on port 9123
2022-12-21 08:05:39.891 [INFO ] [mekit.internal.HomekitChangeListener] - Created 12 HomeKit items in instance 1.
2022-12-21 08:05:41.930 [WARN ] [erver.impl.pairing.PairVerifyManager] - Unknown user: 9C4F9D96-B222-4F9F-AF61-AFCBFF9C8876```
schariwari commented 1 year ago

for me it works now with the Java11 version. KUDOS!

sfranzis commented 1 year ago

Noob question: How can I verify, the update command worked? In /var/lib/openhab/tmp/kar/openhab-addons-3.4.0/org/openhab/addons/bundles/org.openhab.io.homekit/3.4.0/ I still see the version from Dec-19.

ccutrer commented 1 year ago

Noob question: How can I verify, the update command worked?

In /var/lib/openhab/tmp/kar/openhab-addons-3.4.0/org/openhab/addons/bundles/org.openhab.io.homekit/3.4.0/ I still see the version from Dec-19.

The path you listed is just the temporary copy extracted from the kar distributed with openHAB. To see what's currently running, you use bundle:list | grep HomeKit from the console. I believe they're stored at /var/lib/openhab/cache/org.eclipse.osgi/<bundle id>/<no idea>/bundleFile, where bundle id is the the id shown from the bundle:list command.

ccutrer commented 1 year ago

Thanks for fixing this. It basically now works for me and my devices stay available. šŸ‘

Two points:

  • After clicking around in openhab a bit I had the 'no response' state one time again. Restarting the binding helped.

  • I still get the unknown user message in the logs.



2022-12-21 08:05:39.889 [INFO ] [er.impl.jmdns.JmdnsHomekitAdvertiser] - Registering _hap._tcp.local. on port 9123

2022-12-21 08:05:39.891 [INFO ] [mekit.internal.HomekitChangeListener] - Created 12 HomeKit items in instance 1.

2022-12-21 08:05:41.930 [WARN ] [erver.impl.pairing.PairVerifyManager] - Unknown user: 9C4F9D96-B222-4F9F-AF61-AFCBFF9C8876```

Yup, that's okay to happen once (per additional user or hub) associated with your Home. Basically, these devices have a public/private key that's permanently associated with them, and when you pair a new HomeKit accessory they now just try to "login" to it to see if the accessory still has their information stored. All we have to do is respond "nope, no idea who you are", and then they'll go through the first device that paired asking it to ask the accessory to add them. Originally we were giving a 500 error instead of an auth error in this scenario.

As long as you're not seeing this warning repeatedly in the log, you're fine.

stValDor commented 1 year ago

Hey @ccutrer thank you so much for the swift fix. I can confirm that it works now. šŸ˜ƒ

However, I would like to give a hint to those using dockerhub container openhab/openhab:latest. Somehow, just updating jar from the console did not help. For my instance. Hence backuped all my things and item files, cleared the containers local storage and pulled a fresh image. After installing the homekit plugin, it gave be a pairing error (unknown user) - however, the update via console worked after pairing and all items are available now.

Again - thanks sooo much !

JacekKac commented 1 year ago

i have problems after updating to update org.openhab.io.homekit https://github.com/ccutrer/openhab-addons/releases/download/homekit-20221220-02/org.openhab.io.homekit-3.4.0-SNAPSHOT.jar everythinkg is working but my thermostat items are gone... probably because the TempSensor are gone ;)

[INFO ] [mekit.internal.HomekitChangeListener] - Created 13 HomeKit items in instance 1.

openjdk 11.0.9 2020-10-20 LTS OpenJDK Runtime Environment Zulu11.43+88-CA (build 11.0.9+11-LTS) OpenJDK Client VM Zulu11.43+88-CA (build 11.0.9+11-LTS, mixed mode) openhab: Version: 3.4.0.M4 (Build)

TempSensor group/items:

items.replaceItem({ type: 'Group', name: `gRoom${i}_TempSensor`, label: `Czujnik temperatury ${i}`, tags: [`Room${i}`], category: 'temperature', groups: [`gRoom${i}`], metadata: {homekit: `TemperatureSensor,Battery` } } );
    items.replaceItem({ type: `Number`, name: `TempSensor${i}_CurrentTemp`, label: `Temperatura aktualna`, tags: [`Room${i}`], category: `temperature`, groups: [`gRoom${i}_TempSensor`,`gRoom${i}`,`gRoom${i}_termostat`], metadata: { homekit: `TemperatureSensor.CurrentTemperature,Thermostat.CurrentTemperature`, ga: { value: 'thermostatTemperatureAmbient', config: {roomHint: roomlabels[i], structureHint: roomlabels[0]}}, stateDescription: { value: ` `, config: { pattern: `%.1f Ā°C`} } }, channels: { [`mqtt:topic:mymqttbroker:Temp_${i}:temperature`]: {} } });
    items.replaceItem({ type: `Switch`, name: `TempSensor${i}_BatteryLow`, label: `Niski poziom baterii`, tags: [`Room${i}`], category: `temperature`, groups: [`gRoom${i}_TempSensor`,`gRoom${i}`,`gRoom${i}_termostat`], metadata: { stateDescription: { value: ` `, config: { pattern: `%s`} }, homekit: {value: `TemperatureSensor.BatteryLowStatus,Battery.BatteryLowStatus`}}  });
    items.replaceItem({ type: `Number`, name: `TempSensor${i}_Battery`, label: `Poziom baterii`, tags: [`Room${i}`], category: `temperature`, groups: [`gRoom${i}`,`gRoom${i}_TempSensor`,`gRoom${i}_termostat`], metadata: { stateDescription: { value: ` `, config: { pattern: `%.1f %%`} }, homekit: {value: `Battery.BatteryLevel`} }, channels: { [`mqtt:topic:mymqttbroker:Temp_${i}:battery`]: {} } });
    items.replaceItem({ type: `Switch`, name: `TempSensor${i}_FaultStatus`, label: `Czujnik temperatury`, tags: [`Room${i}`], category: ``, groups: [`gRoom${i}`,`gRoom${i}_TempSensor`,`gRoom${i}_termostat`], metadata: { stateDescription: { value: ` `, config: { pattern: `%s`} }, homekit: {value: `TemperatureSensor.FaultStatus`} }, channels: { [`mqtt:topic:mymqttbroker:Temp_${i}:availability`]: {} } });

2022-12-22 14:16:52.485 [WARN ] [.accessories.HomekitAccessoryFactory] - Cannot instantiate accessory implementation for accessory TemperatureSensor
java.lang.reflect.InvocationTargetException: null
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitAccessoryFactory.create(HomekitAccessoryFactory.java:192) ~[?:?]
        at org.openhab.io.homekit.internal.HomekitChangeListener.createRootAccessories(HomekitChangeListener.java:457) ~[?:?]
        at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
        at org.openhab.io.homekit.internal.HomekitChangeListener.applyUpdates(HomekitChangeListener.java:297) ~[?:?]
        at org.openhab.io.homekit.internal.Debouncer.tryActionOrPostpone(Debouncer.java:102) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.NoSuchMethodError: 'org.openhab.core.library.types.QuantityType org.openhab.core.library.types.QuantityType.toUnitRelative(javax.measure.Unit)'
        at org.openhab.io.homekit.internal.HomekitTaggedItem.getConfigurationAsQuantity(HomekitTaggedItem.java:430) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitCharacteristicFactory.getTemperatureStep(HomekitCharacteristicFactory.java:306) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitTemperatureSensorImpl.getMinStepCurrentTemperature(HomekitTemperatureSensorImpl.java:78) ~[?:?]
        at io.github.hapjava.services.impl.TemperatureSensorService.<init>(TemperatureSensorService.java:30) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitTemperatureSensorImpl.<init>(HomekitTemperatureSensorImpl.java:41) ~[?:?]
        ... 15 more
2022-12-22 14:16:52.495 [WARN ] [mekit.internal.HomekitChangeListener] - Cannot create accessory Item:gRoom2_TempSensor (Type=GroupItem, Members=4, State=NULL, Label=Czujnik temperatury 2, Category=temperature, Tags=[Room2, _DYNAMIC_], Groups=[gRoom2])  HomeKit type: 'TemperatureSensor' characteristic: 'Empty'
2022-12-22 14:16:52.503 [WARN ] [.accessories.HomekitAccessoryFactory] - Cannot instantiate accessory implementation for accessory Thermostat
java.lang.reflect.InvocationTargetException: null
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitAccessoryFactory.create(HomekitAccessoryFactory.java:192) ~[?:?]
        at org.openhab.io.homekit.internal.HomekitChangeListener.createRootAccessories(HomekitChangeListener.java:457) ~[?:?]
        at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
        at org.openhab.io.homekit.internal.HomekitChangeListener.applyUpdates(HomekitChangeListener.java:297) ~[?:?]
        at org.openhab.io.homekit.internal.Debouncer.tryActionOrPostpone(Debouncer.java:102) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.NoSuchMethodError: 'org.openhab.core.library.types.QuantityType org.openhab.core.library.types.QuantityType.toUnitRelative(javax.measure.Unit)'
        at org.openhab.io.homekit.internal.HomekitTaggedItem.getConfigurationAsQuantity(HomekitTaggedItem.java:430) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitCharacteristicFactory.getTemperatureStep(HomekitCharacteristicFactory.java:306) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitThermostatImpl.getMinStepCurrentTemperature(HomekitThermostatImpl.java:137) ~[?:?]
        at io.github.hapjava.services.impl.ThermostatService.<init>(ThermostatService.java:53) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitThermostatImpl.<init>(HomekitThermostatImpl.java:84) ~[?:?]
        ... 15 more
2022-12-22 14:16:52.513 [WARN ] [mekit.internal.HomekitChangeListener] - Cannot create accessory Item:gRoom3_termostat (Type=GroupItem, Members=22, State=NULL, Label=Termostat 3, Category=heating, Tags=[_DYNAMIC_, Room3], Groups=[gRoom3])  HomeKit type: 'Thermostat' characteristic: 'Empty'
2022-12-22 14:16:52.521 [WARN ] [.accessories.HomekitAccessoryFactory] - Cannot instantiate accessory implementation for accessory Thermostat
java.lang.reflect.InvocationTargetException: null
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
        at org.openhab.io.homekit.internal.accessories.HomekitAccessoryFactory.create(HomekitAccessoryFactory.java:192) ~[?:?]
        at org.openhab.io.homekit.internal.HomekitChangeListener.createRootAccessories(HomekitChangeListener.java:457) ~[?:?]
        at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
ccutrer commented 1 year ago

The toUnitRelative method missing is indicative that you're not actually running 3.4.0. That method was introduced in core about two months ago.

ztalbot2000 commented 1 year ago

Hi all,

I moved the error to hang off of the accessory instead of in storedValues. My b_unresponsive branch in GitHub is up to date. I'm still unsure of the homebridge update function with an error condition as per the docs. It really does not seem to do anything. Also 'self' is supposed to be used within an exec. There really was no affect. My testing shows this works though there are way too many log messages and they need to be cleaned up. I'll do more testing tomorrow. Everything was submitted with no-verify so tests are also screwed up because of the excess logs. ttyl, John