Home (HomeKit) in 2022 : best solution/approaches

i dont think it would easy to implement. it is used at many places. binding and the libraries it uses are expecting mDNS to be there for publishing of configuration changes, pairing codes, etc

See. Well it’s no issue up till now so I guess it does not make sense then. Any idea why this happens at all? That the OH announcement disappears?

personally i think it happens due very quick connect/disconnect of network interfaces. it looks like something docker related, maybe dhcp leases, or so.

on disconnect/interface down, homekit removes itself from mDNS and for some reasons miss to add itself again on connect / interface up event. we have implemented already some measures to make it more reliable, but it looks like under some circumstances it is still not working. maybe deregistration takes longer than registration and overtakes the registration on “network up” event. need more logs and troubleshooting to understand

so bit of update on this error @yfre
seems like this is only happening when there is no appletv/homepod involved.

I’ve added homepod to home, then invited the user as before and there is no issues at all and everything is working perfectly for both phones/users.

So it must have something to do with that annoying “missing remote access”

1 Like

very interesting finding. very helpful. i have not tested the invite without apple tv/homepod. let see, maybe something that can be fixed easily.

@yfre question from another area: is there a way how to transfer configured homekit from one openhab to another without need to reconfigure apple home again?

there is a backup / restore approach for openHAB

this one should copy the homekit configuration.

if you only want to copy homekit configuration and pairing then

  • copy homekit.json for pairing information. in my case it is /var/lib/openhab/jsondb/homekit.json
  • copy homekit.config for configuration. in my case it is /var/lib/openhab/config/org/openhab/homekit.config
1 Like

Hello @yfre,

i just moved from VBox to Docker and copied the files you highlighted.
I moved every file “textual configuration” as well and edited only the homekit.cfg (new ip-adress).
Unfortunately the Items do not answer in homekit. Do you have any idea what went wrong?
OH logged that everything is ok:

2022-12-14 13:34:02.037 [INFO ] [mekit.internal.HomekitChangeListener] - Created 131 HomeKit items in instance 1 (no change from prior configuration).
2022-12-14 13:34:02.804 [INFO ] [mekit.internal.HomekitChangeListener] - Created 52 HomeKit items in instance 2 (no change from prior configuration).

the port (9123) is also forwarded from docker.

Hello Jonas,

please check with iOS discover app whether you can see openhab as described here

home app works as follows:

  • it sends multicast mDNS request to find homekit devices in the network
  • it connects to IP addresses it gets from mDNS and port 9123

so, in your case, either multicast is not working (often blocked by vbox, docker or routers) or the IP address exposed via mDNS is not correct one. both can be checked with discover app

Hello

i cannot see homekit there … :frowning:
Guess i will have to dig into docker even deeper …

What a shame net:host is not possible on docker mac.

EDIT: i found this thread:

I also exposed 5353 in the docker config but it did nothing.
i do not even see openhab service in dns viewer …
But i can reach OH via Browser and even send commands to items through the console.

and my docker conf:

openhab:
    image: "openhab/openhab:milestone"
    container_name: openhab
    restart: always
    ports:
      - "8080:8080"
      - "8443:8443"
      - 8101:8101
      # 8101 samsung tv
      - 8009:8009
      # 8009 chromecast (klingel)
      - 3671:3671
      #- 3671:3671/udp
      # 3671 knx router - set nat = true
      - 5007:5007
      # 5007 language protocol server
      - 5353:5353
      # 5353 mdns for homekit
      - 6524:6524/udp
      - 1012:1012
      - 9123:9123
      # 9123 Homekit
      - 123:123  
      # 123 ntp time server    
    volumes:
      - "./openhab/openhab_addons:/openhab/addons"
      - "./openhab/openhab_conf:/openhab/conf"
      - "./openhab/openhab_userdata:/openhab/userdata"
    environment:
      CRYPTO_POLICY: "unlimited"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"

Do i have to add the ip adress the container got assigned from docker into the config maybe?

here is some of the mdns logs (trace)

2022-12-14 15:12:06.478 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - Registering new service _openhab-server._tcp.local. at 172.18.0.10:8080 (334ba370b830.local.)
2022-12-14 15:12:06.487 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - Registering new service _openhab-server-ssl._tcp.local. at 172.18.0.10:8443 (334ba370b830.local.)
2022-12-14 15:12:07.060 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - ip address change: added [172.18.0.10/16], removed
2022-12-14 15:12:09.135 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - mDNS service has been stopped (334ba370b830.local.)
2022-12-14 15:12:09.165 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - mDNS service has been started (334ba370b830.local. for IP 172.18.0.10)
2022-12-14 15:12:09.168 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - Registering new service _openhab-server._tcp.local. at 172.18.0.10:8080 (334ba370b830.local.)
2022-12-14 15:12:09.175 [DEBUG] [ansport.mdns.internal.MDNSClientImpl] - Registering new service _openhab-server-ssl._tcp.local. at 172.18.0.10:8443 (334ba370b830.local.)

thanks @yfre
so it seems like, that pairing warning is back in another different manner :wink:
It’s definitely not happening as before every couple of minutes when home hasn’t had homepod in it.

So what I have done was:

  1. working and non warning solution i’ve transfered to new openhab dedicated machine
  2. reconfigured Home app (it was necessary, as “old” home appliance was “unavailable” after transfer → i think because it was not able to match ID’s somewhere but I did it by copying those homekit.jsons as @yfre suggested
  3. everything working as before, invited people can operate and interact with Home app thorough openhab binding without any issues
  4. this is occasionally in the log

:person_shrugging:

2022-12-16 08:38:17.205 [WARN ] [.server.impl.connections.HttpSession] - Exception encountered while verifying pairing
java.lang.Exception: Unknown user: BF8FF1CD-7AD4-4614-AEDA-84B1768C960A
        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) [?:?]
2022-12-16 08:41:06.040 [WARN ] [.server.impl.connections.HttpSession] - Exception encountered while verifying pairing
java.lang.Exception: Unknown user: BF8FF1CD-7AD4-4614-AEDA-84B1768C960A
        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) [?:?]

interesting.
the message means, there is a device in your network then sends request to openHAB but it was not paired with that instance of openHAB. there is also the magic Apple does homekit sharing via iCloud.
please try following

  • check in homekit.json whether you have an entry with the user ID. just search for “84B1768C960A”. probably you will not find anything. but just to be sure.
  • try to restart all apple devices, iphone, ipad, appletv, homepad, macs. maybe this will help.

in general, the error can be ignore if everything working fine.

I cannot confirm this. I have an Apple TV in the mix and OH3 still stops publishing hap tcp from time to time.