Unable to connect openHAB to Homekit

Hey all,

I am running openHAB 2 on a Raspberry Pi 2, installed using the apt-get method and the web interface is interacting well with the items installed (currently some MiLights)

I’m currently in the process of integrating Homekit into the openHAB2 environment, but I am encountering some issues. It does find openHAB, but when connecting it responds with “can’t connect to device”.

Homekit is configured in the Paper UI as a ‘service’ (org.openhab.homekit) with the default port number (9154) and PIN (031-45-154). the IP address is the same as openHAB is running on (should it be?)

I have done research around this forum and found that the problem could be that it wouldn’t recognize any items, so to be sure I’ve added some test-switches, as can be seen in my home.items file:

Group   LIGHT   (All)

Switch  Lamp_RFXCom         "RFXCom"        <light>         (LIGHT)     

Switch testSwitch "My Switch" ["Lighting"]

Dimmer  Lamp_MiLight        "MiLight"       <slider>        (LIGHT)     {milight="milight1;7;brightness;27"}    
Switch  Lamp_MiLight_White  "MiLight wit"   <light>         (LIGHT)     {milight="milight1;7;whiteMode"}
Color   Lamp_MiLight_Colour "MiLight kleur" <colorwheel>    (LIGHT)     {milight="milight1;7;rgb"}
Switch  Lampen_master	    "MiLight_Master"<switch>	    (LIGHT)     {milight="bridge1;8"}

Dimmer  Lamp_MiLight2        "MiLight"       <slider>        (LIGHT)    {milight="milight1;7;brightness;27"}
Switch  Lamp_MiLight2_White  "MiLight wit"   <light>         (LIGHT)    {milight="milight1;7;whiteMode"}
Color   Lamp_MiLight2_Colour "MiLight kleur" <colorwheel>    (LIGHT)    {milight="milight1;7;rgb"}
Dimmer  Lamp_MiLight2_Party  "Partymode"     <slider>        (LIGHT)    {milight="bridge1;5;discoMode"}
Dimmer  Lamp_MiLight2_Speed  "Partyspeed"    <slider>        (LIGHT)    {milight="bridge1;5;discoMode"} 
Switch  Lampen_master       "MiLight_Master"<switch>        (LIGHT)     {milight="bridge1;8"}

Dimmer  Lamp_MiLight3        "MiLight"       <slider>        (LIGHT)    {milight="milight1;7;brightness;27"}
Switch  Lamp_MiLight3_White  "MiLight wit"   <light>         (LIGHT)    {milight="milight1;7;whiteMode"}
Color   Lamp_MiLight3_Colour "MiLight kleur" <colorwheel>    (LIGHT)    {milight="milight1;7;rgb"}

Dimmer  Lamp_MiLight4        "MiLight"       <slider>        (LIGHT)    {milight="milight1;7;brightness;27"}
Switch  Lamp_MiLight4_White  "MiLight wit"   <light>         (LIGHT)    {milight="milight1;7;whiteMode"}
Color   Lamp_MiLight4_Colour "MiLight kleur" <colorwheel>    (LIGHT)    {milight="milight1;7;rgb"}

Switch KitchenLights "Kitchen Lights" <light> (gKitchen) [ "Lighting" ]
Dimmer BedroomLights "Bedroom Lights" <light> (gBedroom) [ "Lighting" ]
Number BedroomTemperature "Bedroom Temperature" (gBedroom) [ "CurrentTemperature" ]
Group gDownstairsThermostat "Downstairs Thermostat" (gFF) [ "Thermostat" ]
Number DownstairsThermostatCurrentTemp "Downstairs Thermostat Current Temperature" (gDownstairsThermostat) [ "CurrentTemperature" ]
Number DownstairsThermostatTargetTemperature "Downstairs Thermostat Target Temperature" (gDownstairsThermostat) [ "TargetTemperature" ]
String DownstairsThermostatHeatingCoolingMode "Downstairs Thermostat Heating/Cooling Mode" (gDownstairsThermostat) [ "homekit:HeatingCoolingMode" ]


Switch Hue_lamp2 "LAMMMP" ["Lighting"] { channel="hue:0100:001788172cd5:14" }

A problem related is that I am unable to open a successful osgi-console. My start.sh file only contains the following:

#!/bin/sh

echo Launching the openHAB runtime...

DIRNAME=`dirname "$0"`
exec "${DIRNAME}/runtime/bin/karaf" "${@}"

-console=5555

I’ve added the -console=5555 as is described in multiple other topics, but there doesn’t seem to be an osgi console running. At least I cant telnet into it.

Anything that can help me a bit further is much appreciated!

If there are any questions, please do ask!

Cheers,

Niels

Hi Niels, I will jump in and dig with ya…
We are close to the same point. My configuration is the same. (I am running Pine64 v RPI) I receive the error “couldn’t add openHAB:Home couldn’t connect to this accessory”

I am curious, when you attempt to add the accessory:(openHAB) in iOS are you getting any log entries?

Hope this helps you set up your logging:
This article is helpful setting up logs: http://docs.openhab.org/administration/logging.html#karaf-console

If you are able to SSH into your openhab I have successfully launched Karaf (osgi) console with the following

sh /usr/share/openhab2/runtime/bin/client

then per this page I added log:set TRACE com.beowulfe.hap

Each time I change the HomeKit config in PaperUI I do get the following [INFO] log entries but nada when trying to connect via iOS:
15:45:58.068 [INFO ] [com.beowulfe.hap.HomekitRoot ] - Added accessory openHAB
15:45:58.080 [INFO ] [com.beowulfe.hap.HomekitRoot ] - Added accessory HommieOfficeLight
15:45:58.086 [INFO ] [pl.http.impl.NettyHomekitHttpService] - Resetting connections

All this to say “hey siri please turn on the lights” and have her say "__Kerr I am not sure I understand did you say you want to fight for your right " :grinning:

Kerr,

First of all, thanks for the response!

Haha, it does sound a bit exxagerated to go through all this trouble just to let Siri control the living room :yum:

But back to the topic, I’ve tried your sh /usr/share/openhab2/runtime/bin/client approach, without any success… Authentication failed:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Dec 11 10:22:14 2016 from gebruik-9d3iaq7.local
osmc@osmc:~$ sh /usr/share/openhab2/runtime/bin/client
client: Ignoring predefined value for KARAF_HOME
Logging in as openhab
Authentication failed
osmc@osmc:~$

Could it be that the OSMC-image is interfering with the openHAB permissions?

Niels

Did you give this one a go? We may have to wait as it looks like there is trouble with build 637 [solved] Build #637 does not start any bundles anymore

hmm, still giving me an authentication error for some reason, see log:

osmc@osmc:~$ ssh openhab@localhost -p 8101
Received disconnect from 127.0.0.1: 2: Session has timed out waiting for authentication after 120000 ms.

I’m now in the process of running the service manually, which results in the console

Hi Niels and Kerr

Did you find a solution to this issue? It seems like I have the exact same problem. Have checked the logs, and nothing in the logs when trying to pair. I observe the same as you Kerr, I see it in the log when I do configuration, but nothing when I try to pair…

Hi all. I solved this at last. For future reference I did a “smarthome:homekit clearPairings” and a “smarthome:homekit allowUnauthenticated true” from the console, and then restarted the openHAB service. After this HomeKit connected successfully.

Hey Stian,

Glad to hear you got it fixed! I’m having very little time at the moment, but I will give it a go soon!

Niels

Hi guys,

unable to connect iOs to openhab accessory since b5 version (2.0 release doesn’t solved the issue).
It was working perfectly with b4 under exactly same config.
Here is the error message in console:

17:38:50.205 [ERROR] [lfe.hap.impl.connections.HttpSession] - Could not handle request
java.lang.NullPointerException
at com.beowulfe.hap.characteristics.FloatCharacteristic.getValue(FloatCharacteristic.java:72)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.characteristics.BaseCharacteristic.makeBuilder(BaseCharacteristic.java:71)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.characteristics.FloatCharacteristic.makeBuilder(FloatCharacteristic.java:48)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.characteristics.BaseCharacteristic.toJson(BaseCharacteristic.java:61)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.json.AccessoryController.toJson(AccessoryController.java:73)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.json.AccessoryController.listing(AccessoryController.java:39)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.connections.HttpSession.handleAuthenticatedRequest(HttpSession.java:70)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.connections.ConnectionImpl.doHandleRequest(ConnectionImpl.java:51)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.connections.ConnectionImpl.handleRequest(ConnectionImpl.java:46)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.http.impl.AccessoryHandler.channelRead0(AccessoryHandler.java:47)[211:org.openhab.io.homekit:2.0.0]
at com.beowulfe.hap.impl.http.impl.AccessoryHandler.channelRead0(AccessoryHandler.java:15)[211:org.openhab.io.homekit:2.0.0]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)[211:org.openhab.io.homekit:2.0.0]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)[211:org.openhab.io.homekit:2.0.0]
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:32)[211:org.openhab.io.homekit:2.0.0]
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:299)[211:org.openhab.io.homekit:2.0.0]
at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:36)[211:org.openhab.io.homekit:2.0.0]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)[211:org.openhab.io.homekit:2.0.0]
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)[211:org.openhab.io.homekit:2.0.0]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

regards.

Hi,
When you say

I did a “smarthome:homekit clearPairings” and a “smarthome:homekit allowUnauthenticated true” from the console

What do you mean? ssh to the server (a pi3 in my case) and run that? where do you run it?

Hi,

First, ssh to your Pi with your normal user. Then run the following command. The password is habopen

ssh openhab@localhost -p 8101

after that you can type the following commands

smarthome:homekit clearPairings
smarthome:homekit allowUnauthenticated true

I tried these steps on my side but I still have the same error: "Coudn’t add openHAB"
And despite having the log set at TRACE for com.beowulfe.hap, not a single line giving me any feedback in the logs.

Ben

2 Likes

Hi,

I have now used Xcode to try to get some logs. Stripping down the unnecessary bit, here is what seems relevant (I have changed the last 4 characters of the value 32:f:40:93:xx:xx)

Feb 23 23:05:03 Ben-6S homed(CoreHAP)[1860] <Info>: [IP Accessory Server 32:f:40:93:xx:xx openHAB] Starting a reconfirm with Bonjour during pairing
Feb 23 23:05:03 Ben-6S homed(CoreHAP)[1860] <Info>: [IP Accessory Server 32:f:40:93:xx:xx openHAB] Accessory doesn't support auth, prompting user...
Feb 23 23:05:03 Ben-6S homed(HomeKitDaemon)[1860] <Info>: Accessory Browser: User already consented to adding unauthenticated accessory to home - skipping auth prompt
Feb 23 23:05:03 Ben-6S homed(CoreHAP)[1860] <Info>: Pair-setup starting for server openHAB device 32:f:40:93:xx:xx...
Feb 23 23:05:03 Ben-6S mDNSResponder[91] <Info>:  18: DNSServiceQueryRecord(400000, 8, openHAB._hap._tcp.local., SRV) START PID[1860](homed)
Feb 23 23:05:51 Ben-6S locationd[1412] <Notice>: message 'kCLConnectionMessageWatchdog' received from client 'com.apple.Home'
Feb 23 23:05:51 Ben-6S locationd[1412] <Notice>: message 'kCLConnectionMessageWatchdog' received from client '/System/Library/PrivateFrameworks/HomeKitDaemon.framework'
Feb 23 23:05:51 Ben-6S locationd[1412] <Notice>: message 'kCLConnectionMessageWatchdog' received from client 'com.apple.Home'
Feb 23 23:05:53 Ben-6S locationd[1412] <Notice>: message 'kCLConnectionMessageWatchdog' received from client 'com.apple.Home.HomeUIService'
Feb 23 23:06:03 Ben-6S homed(CoreHAP)[1860] <Notice>: __55-[HAPAccessoryServerIP _continuePairingAfterAuthPrompt]_block_invoke ### Unable to send initial Pair Setup request, received response object: (null), MIME type: Unknown, error: Error Domain=HMErrorDomain Code=54 "Failed with OSStatus code -6722 (kTimeoutErr)" UserInfo={NSLocalizedDescription=Failed with OSStatus code -6722 (kTimeoutErr), NSUnderlyingError=0x1002c48a0 {Error Domain=NSOSStatusErrorDomain Code=-6722 "kTimeoutErr" UserInfo={NSLocalizedDescription=kTimeoutErr}}}
Feb 23 23:06:03 Ben-6S homed(CoreHAP)[1860] <Info>: [CoreHAP] Invalidating HTTP client and tearing down pairing session, will reconfirm with Bonjour for 32:f:40:93:xx:xx
Feb 23 23:06:03 Ben-6S homed(CoreHAP)[1860] <Info>: invalidating HTTP client for 32:f:40:93:xx:xx
Feb 23 23:06:03 Ben-6S homed(CoreUtils)[1860] <Notice>: <private>
Feb 23 23:06:03 Ben-6S homed(CoreHAP)[1860] <Notice>: [HAP HTTP Client] Received invalidate callback from CoreUtils HTTPClient due to -6722 (kTimeoutErr)
Feb 23 23:06:03 Ben-6S homed(HomeKitDaemon)[1860] <Info>: Ignoring didStopPairingWithError:(Error Domain=HMErrorDomain Code=54 "Failed with OSStatus code -6722 (kTimeoutErr)" UserInfo={NSLocalizedDescription=Failed with OSStatus code -6722 (kTimeoutErr), NSUnderlyingError=0x1002c48a0 {Error Domain=NSOSStatusErrorDomain Code=-6722 "kTimeoutErr" UserInfo={NSLocalizedDescription=kTimeoutErr}}}) and starting a pairing interrupted timer for unpaired accessory openHAB/32:f:40:93:xx:xx
Feb 23 23:06:03 Ben-6S homed(HomeKitDaemon)[1860] <Info>: Pairing interrupted timer exists for unpaired accessory openHAB/32:f:40:93:xx:xx - skipping
Feb 23 23:06:03 Ben-6S homed(HomeKitDaemon)[1860] <Info>: WAC/Bonjour reconfirm timer exists for unpaired accessory openHAB/32:f:40:93:xx:xx - skipping
Feb 23 23:06:03 Ben-6S mDNSResponder[91] <Info>:  17: DNSServiceGetAddrInfo(osmc-1.local.) STOP PID[1860](homed)
Feb 23 23:06:03 Ben-6S mDNSResponder[91] <Info>:  18: DNSServiceQueryRecord(openHAB._hap._tcp.local., SRV) STOP PID[1860](homed)
Feb 23 23:06:11 Ben-6S locationd[1412] <Notice>: message 'kCLConnectionMessageWatchdog' received from client 'com.apple.Home'
Feb 23 23:06:46 Ben-6S homed(HomeKitDaemon)[1860] <Info>: Indicating addAccessory failure for accessory openHAB(32:f:40:93:xx:xx) with error Error Domain=HMErrorDomain Code=4 "(null)"
Feb 23 23:06:46 Ben-6S homed(CoreHAP)[1860] <Info>: Adding a WAC scan request with scan interval of 10.000000 seconds
Feb 23 23:06:46 Ben-6S homed(HomeKitDaemon)[1860] <Info>: Removing password and handlers for accessory 8718ED2D-264D-4676-B3FC-DF054744Axxx
Feb 23 23:06:46 Ben-6S homed(HomeKitDaemon)[1860] <Notice>: Failed to add accessory openHAB with error: Error Domain=HMErrorDomain Code=4 "(null)"

I am not sure I understand where 32:f:40:93:xx:xx comes from and how I could fix my issue.
Does anyone understand what the log below really means?

Ben

I am using OpenHABian and had problems to connect. Tried several tips, but this worked: I set the interface IP for the HomeKit service (configuration/ service/ HomeKit) and the next try I was successful.

hi i can not find any devices in my homekit app wat wrong

Hey Stan. that worked for me. Thanks for the advice.