Docker - OH 3 - Homekit

Hello,
i have a Problem to connect over HomeKit my Openhab3

The OH3 is install with a docker-compose File in HostMode.

openhab:
image: openhab/openhab:3.2.0
depends_on:
- influxdb
- mosquitto
restart: always
volumes:
- “/etc/localtime:/etc/localtime:ro”
- “/etc/timezone:/etc/timezone:ro”
- “./data/openhab/conf:/openhab/conf”
- “./data/openhab/addons:/openhab/addons”
- data_openhab_userdata:/openhab/userdata:rw
environment:
TZ: ${TZ}
OPENHAB_HTTP_PORT: ${OPENHAB_HTTP_PORT}
OPENHAB_HTTPS_PORT: ${OPENHAB_HTTPS_PORT}
CRYPTO_POLICY: “unlimited”
EXTRA_JAVA_OPTS: “-Duser.timezone=${TZ}”
USER_ID: 999
GROUP_ID: 994
labels:
- “com.centurylinklabs.watchtower.enable=true”
network_mode: host

If I try to connect the OH3 over the Home App I can not find the OH3. The binding is install correct

_hap._tcp. - the OH3 is not in the List.

What can I do? It is a Port Problem from docker? But the oh3 is in Host Mode…

Thanks for you tip to solve the Problem.
Greating Thomas

Now, I tested the port from my pc, over telnet it is possible to access the port.

I think the docket installation is ok…
Mhhh

there are 2 steps / protocols:

  1. homekit binding advertise itself via mDNS protocol. this protocol requires support for broadcast (sending message to everyone) and port 5353. if it works you would see in as _hap._tcp. this what home app uses to find openHAB bring in first place

  2. _hap._tcp has the information about the IP address and port of the homekit binding (by default 9124). home app uses this information to connect to openHAB and to request accessory list.

so, in your case the step 1 is not working.
do you have different networks, e.g. openhab is connected per cable/ethernet and mobile is running in wifi? maybe mDNS does not get routed correctly between this network. in my case i had to enable support for it on my Unifi router.

do you have windows or mac pc? try to find mdns scanner for it and check whether you can see _hap._tcp.

e.g.

hello yfre,
thanks for your response… :slight_smile:
I use a mc and with the Discovery APP I can’t see the oh3. The oH2 is in the List. I think also the Network correct.
The Raps with Docker and OH3 have Lan.

I think the Problem is OH with HomeKit inside a Docker volume. I testing with avahi, but I can not find the correct configuration.

Thomytp

do you see openhab on the list in discovery app on mac or ios?
image

  1. if you see openhap but not _hap._tcp then the issue is with homekit binding. try to re-install it, set IP address in the homekit settings

  2. if you dont see openhab then it is a network issue. im not a docker expert but check something like docker + mdns

Hello,
is see only the OH2.5 Version:
Bildschirmfoto 2022-03-22 um 08.48.18

Ok, than it hink I looking in the right direction… There is a Port oder mDNS problem…
unfortunately, there is really little information on the subject on the www…

now, I test the port connection from my Mac with nc
→ Connection to 192.168.111.46 port 9124 [tcp/*] succeeded!

Then I think the network ist correct. I reinstall HomeKit, but no solution…

If I take a look to the log after the nc test, I see that:
New HomeKit connection from /192.168.111.46:57274

2022-03-22 14:39:03.877 [TRACE] [rver.impl.http.impl.AccessoryHandler] - New HomeKit connection from /192.168.111.46:57274

so the network seems ok, but the HomeKit service is not visible in the _hap._tcp…

i have only configure the IP from the openhab in the HomeKit config, is there a mistake?

there are 2 ports:

  1. it used for communication between home app and openHAB, after the pairing. this seems to work. As you see some connection in the logs you probably have already paired / add openhab as homekit to some iOS devices

5353 for mDNS. this is used by home app and also by discovery app to find information about all homekit bridges in your network. paired or unpaired. this does not work
i dont know how mDNS exactly communicates. not sure whether it just outgoing communication, so, dont need to be accessible from outside or also incoming communication. more important here is not the port but the way of communication - broadcast. i would google something like “docker blocks broadcast”

quick question: what is the difference to oh25? is it running also as docker on the same raspPI? it is connected to the same network and the same way?

Quick answer: The oh2.5 is installed on a separate PI, without Docker with openhabian.
There everything runs.
currently I want to migrate to OH3. everything is ready so far, only HomeKit makes problems…

i test the connect for my Mac again:
OH2.5:
nc -z -u 192.168.111.128 5353
Connection to 192.168.111.128 port 5353 [udp/mdns] succeeded!

OH3
nc -z -u 192.168.111.46 5353
Connection to 192.168.111.46 port 5353 [udp/mdns] succeeded!

it seems, all is ok… must I do anything on the configuration in openhab für HomeKit??? it’s really crazy…

if you dont see openhab (_openhab-server._tcp) in discovery app then it is a network issue, not the binding.
port is open. then it is probably broadcast.

  • please double check the host mode of the docker.
  • there were reports about ipv6 issues, if you can disable it somewhere in docker config please do so.
  • do you see any exceptions on openhab start? try to enable more logging with following command in karaf consol

log:set TRACE org.openhab.core.io.transport.mdns

how you have created a docker image? is there instructions somewhere i could follow to reproduce it on my side?

Hi All,
Sharing comments I wrote on another thread dealing with this issue.
First I describe my problem and setup.
And then I describe the changes I made to the Homekit Integration settings, which allowed the iOS Home app to finally find the OpenHAB bridge.

Hello Friends,
For a year now I’ve been using OpenHAB as a regular install (not openHABian) on Raspberry Pi 4, and I set it up successfully to work with the Homekit binding.

Today, I started using a new Intel based home server running UnRAID.
I installed OpenHAB as a docker app from the UnRAID community apps repository, and continued to manually recreate the previous OpenHAB setup I used on the Raspberry Pi 4.

I managed to properly recreate almost everything, except for the Homekit integration connection.
At the moment, when I scan the Homekit Binding’s QR code with the iOS Home app, OpenHAB is not found as a bridge.

Some info and questions:

1. what should I choose for the OpenHAB docker app Network Type? (Bridge, Host, None, Custom?).
2. I set these ports in the OpenHAB docker app: HTTP port: 8787. HTTPS Port: 7443. and I added a third port for Homekit: 9123.
3. In the Homekit Integration binding settings, what IP should I enter for Network Interface? Should I enter the main IP of the UnRAID server? or the IP of the docker container?
4. I installed the Discovery iOS app. When the docker app’s Network Type is set to Custom, the Discovery app doesn’t find `_hap._tcp` or `_openhab-server._tcp` service types.
If I set Network Type to Host, the Discovery app finds `_openhab-server-ssl._tcp.` , `_openhab-server._tcp.` and `_hap._tcp.` , but `_hap._tcp.` has no IP info and just shows “scanning”.
5. In the Homekit Integration binding settings I currently set `Use openHAB mDNS` service to false.

Can someone please help me fix the Homekit setup so that I can connect OpenHAB to the iOS Home app?

Hope someone can help.

@yfre replied to my post and suggested I do this:

you should use the IP address which is accessible from outside of the docker, i.e. main IP of the unRAID server. this is the IP home app will connect to.

i had the impression that “host” is the best network type.

I then took these steps that finally allowed the iOS Home app to find my OpenHAB bridge.

Hi @yfre ,
Thank you for your reply. I followed your advice and set the Network Type to Host and the Network Interface to the main IP of the UnRAID server.
Changing these settings didn’t help, and OpenHAB was still not found by the iOS Home app.
However, I then tried to enable `Use openHAB mDNS` and to my surprise, OpenHAB is now found by the iOS Home app.

Hope this helps others.

Hello,
I check the docker configuration again and the openhab is in host-mode.

I use this configuration for the docker-compose as a basic: OpenHAB 3 Docker Installation – Laub-Home Wiki (sorry for German)

The mDNS Service is active and IPv6 is disable on my fritz.box since 1 year, now directly in docker too.

but no entry in _hap._tcp…

the last entries from the openhab log:
2022-03-23 11:25:12.050 [TRACE] [nhab.io.homekit.internal.HomekitImpl] - start HomeKit bridge

2022-03-23 11:25:12.051 [TRACE] [nhab.io.homekit.internal.HomekitImpl] - suitable mDNS client for IP /192.168.111.46 found and will be used for HomeKit

2022-03-23 11:25:12.054 [TRACE] [thub.hapjava.server.impl.HomekitRoot] - Added accessory java.util.concurrent.CompletableFuture@5cd979[Completed normally]

2022-03-23 11:25:12.055 [TRACE] [thub.hapjava.server.impl.HomekitRoot] - Added accessory java.util.concurrent.CompletableFuture@1e67c6[Completed normally]

2022-03-23 11:25:12.057 [TRACE] [thub.hapjava.server.impl.HomekitRoot] - Added accessory java.util.concurrent.CompletableFuture@1b51a94[Completed normally]

2022-03-23 11:25:12.066 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : invoked modified: modified

2022-03-23 11:25:12.072 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : No change in target property for dependency $000: currently registered: true

2022-03-23 11:25:12.075 [TRACE] [pl.http.impl.NettyHomekitHttpService] - Bound homekit listener to /192.168.111.46:9124

2022-03-23 11:25:12.076 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : No change in target property for dependency $001: currently registered: true

2022-03-23 11:25:12.082 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : No change in target property for dependency $002: currently registered: true

2022-03-23 11:25:12.089 [TRACE] [er.impl.jmdns.JmdnsHomekitAdvertiser] - Advertising accessory OH3

2022-03-23 11:25:12.090 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : No change in target property for dependency $003: currently registered: true

2022-03-23 11:25:12.091 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : No change in target property for dependency $004: currently registered: true

2022-03-23 11:25:12.091 [INFO ] [er.impl.jmdns.JmdnsHomekitAdvertiser] - Registering _hap._tcp.local. on port 9124

2022-03-23 11:25:12.093 [TRACE] [er.impl.jmdns.JmdnsHomekitAdvertiser] - MAC:5a:ba:45:31:d2:3b Setup Id:KHWI

2022-03-23 11:25:12.093 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : No change in target property for dependency $005: currently registered: true

2022-03-23 11:25:12.100 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : Querying state active

2022-03-23 11:25:12.106 [DEBUG] [kit.internal.HomekitCommandExtension] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitCommandExtension(356)] : dm Homekit tracking 4 SingleStatic modified {org.openhab.io.homekit.Homekit}={port=9124, thermostatTargetModeHeat=HeatOn, service.scope=bundle, thermostatTargetModeAuto=Auto, name=OH3, component.name=org.openhab.io.homekit.internal.HomekitImpl, blockUserDeletion=false, networkInterface=192.168.111.46, useFahrenheitTemperature=true, service.config.category=io, service.pid=[org.openhab.homekit, org.openhab.homekit], qrCode=X-HM://0013ZMME9KHWI, service.id=649, service.bundleid=295, thermostatTargetModeCool=CoolOn, service.config.label=HomeKit Integration, component.id=357, thermostatTargetModeOff=Off, service.config.factory=false, pin=021-03-777, setupId=KHWI, useOHmDNS=true, service.config.description.uri=io:homekit} (enter)

2022-03-23 11:25:12.108 [DEBUG] [kit.internal.HomekitCommandExtension] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitCommandExtension(356)] : dm Homekit tracking 4 SingleStatic modified {org.openhab.io.homekit.Homekit}={port=9124, thermostatTargetModeHeat=HeatOn, service.scope=bundle, thermostatTargetModeAuto=Auto, name=OH3, component.name=org.openhab.io.homekit.internal.HomekitImpl, blockUserDeletion=false, networkInterface=192.168.111.46, useFahrenheitTemperature=true, service.config.category=io, service.pid=[org.openhab.homekit, org.openhab.homekit], qrCode=X-HM://0013ZMME9KHWI, service.id=649, service.bundleid=295, thermostatTargetModeCool=CoolOn, service.config.label=HomeKit Integration, component.id=357, thermostatTargetModeOff=Off, service.config.factory=false, pin=021-03-777, setupId=KHWI, useOHmDNS=true, service.config.description.uri=io:homekit} (exit)

2022-03-23 11:25:12.109 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : ImmediateComponentHolder Finished configuring the dependency managers for component for pid org.openhab.homekit

2022-03-23 11:25:12.112 [DEBUG] [nhab.io.homekit.internal.HomekitImpl] - bundle org.openhab.io.homekit:3.2.0 (295)[org.openhab.io.homekit.internal.HomekitImpl(357)] : ImmediateComponentHolder Will not enable component for pid org.openhab.homekit: holder enabled state: true, metadata enabled: true

so, solved.
30 hours of searching and trying and later understanding…

Since this is probably really an issue with Docker, here’s how you can make it work:

  • Run Openhab on the host network
  • Install Trace in Karaf Console for homkit (see Homekit installation guide).
  • In Binding: Set IP of the host, port 9214
  • Install Avahi (I would also install a browser, so you can also discovern from the host)
  • Install Discovery APP on the Apple device, openhab must appear under _hap.tcp.
  • Create service file as described above, pay attention to it: MAC must correspond to the MAC from the log, sh=must correspond to setup ID, name must be equal to the host.
  • IPV6 disabled on Fritz.box + Docker + Avahi

Here my service file

openhab3 -> DSN Host _hap._tcp 9124 some Port like HomeKit config md=openhab3

pv=1.1 Version 1.1!
id=5a:ba:35:31:d2:3b <!-- MAC → from the Trace LOG!
c#=2

s#=1
ff=0
ci=2
sf=1
sh=ABCD

My avahi-daemon.conf looks like this:

[server]
domain-name=local
use-ipv4=yes
use-ipv6=no
ratelimit-interval-usec=1000000
ratelimit-burst=1000

[wide-area]
enable-wide-area=yes

[publish]
publish-hinfo=no
publish-workstation=yes

[reflector]
enable-reflector=yes
reflect-ipv=no

[rlimits]
publish-workstation I found quite nice, so you can see in the discovery app if the service is running at all

greetings and thanks for your hints!!
ThomyTP

1 Like

Has anyone tried to setup the Homekit Integration’s Network Interface host IP address to the external IP (along with a router port forward to the unraid server), so that the Home app can work when we are outside the house?
I know Apple restricts controlling homekit devices when not connected to the home WiFi network, unless you have an Apple TV or iPad still at home, that serves as a bridge.

i tried some time back to connect via VPN to home network but even this was not working for homekit. so, i bought apple tv that is now acting as homekit bridge.

1 Like

Hi Thomas,

cool. thanks for sharing.
just to confirm my understanding - you have created a mdns service using avahi and configured it with the same values as openHAB.
the built-in openHAB mDNS is still not visible to outside.

correct, that is the configuration, and it works good…, at the moment. :slight_smile:

new informations:
the binding works only for roundebaut 12hours… after that, is see only “Refreshing” on the Home APP.
After that, I can only delete the openhab bridge from the Home APP an delete over Karaf the binding…

it is really a mystery for me, Where ist the Problem?

today I see this message in the Log:
Is that the Problem?

2022-04-01 19:47:55.593 [TRACE] [er.impl.jmdns.JmdnsHomekitAdvertiser] - Re-creating service due to change in configuration index to 352
2022-04-01 19:47:57.595 [INFO ] [er.impl.jmdns.JmdnsHomekitAdvertiser] - Registering _hap._tcp.local. on port 9124
2022-04-01 19:47:57.596 [TRACE] [er.impl.jmdns.JmdnsHomekitAdvertiser] - MAC:5a:ba:45:31:d2:3b Setup Id:KHWI

I think the avahi Service works not very well…

I hope someone can help me…
Thanks…

the logs looks ok.

Re-creating service due to change in configuration index to 352

means that configuration of some items has changed, e.g. item was added/removed or metadata was changed.
do you any errors or exceptions in logs?