If you are struggling to get it working with SSH as I described here …
There is a second possibility using sshpass to restart Homekit on regulary basis:
install sshpass in your openHAB
Open a bash to your openHAB and install sshpass:
If you use docker: open terminal → “start with command” → type in “bash” → hit return
create rule
rule "Homekit Bundle restart"
when
Time cron "0 0 8 1/1 * ? *" or // daily 08:00h
Time cron "0 0 16 1/1 * ? *" // daily 16:00h
then
logInfo("Homekit", "Homekit-Bundle-Restart")
executeCommandLine(Duration.ofSeconds(6), "sshpass", "-p", "habopen", "ssh", "-oStrictHostKeyChecking=no", "-oUserKnownHostsFile=/dev/null", "-p8101", "openhab@localhost", "bundle:restart", "org.openhab.io.homekit")
end
.
When rule is executed you should see in the log:
[INFO ] [rg.openhab.core.model.script.Homekit] - Homekit-Bundle-Restart
[INFO ] [mekit.internal.HomekitChangeListener] - Created x HomeKit items in instance 1 (no change from prior configuration).
I tested this on my OH3.x and OH4.x - and it is working well.
All my problems with missing connection(s) to HomeKit are gone.
After one month, I had not a single disconnect. The code seems to react on the many changes on IPv6 addresses due to privacy extensions, causing the race condition described by @yfre more frequently.
Running my NAS on IPv4 only is acceptable for now, but in the long run I’d rather see the issue fixed. Either the code should react only on changes for the bound address, whether it is IPv4 or v6, and ignore other addresses or, ideally, the race condition should be fixed or mitigated.
with regards to ipv6 changes. in the past, homekit was listening to only one ip address and ignoring all other. but there was a valid use case with changes on multiple interfaces, so, i have added this functionality… probably, i need to make it configurable, e.g. if IP address provided, listen only to it, otherwise to all interfaces.
I tried to disable IPv6 in the openHAB network configuration and enable “use openHAB mDNS service” for HomeKit. But then it will still print things like