Announcing some improvements to the Homekit plugin for openHAB 2

Tags: #<Tag:0x00007f616e4de3e8> #<Tag:0x00007f616e4de2f8> #<Tag:0x00007f616e4de208>

Thank you, yes of course.

21:43:18.189 [TRACE] [.server.impl.http.impl.LoggingHandler] - READ PooledUnsafeDirectByteBuf(ridx: 0, widx: 196, cap: 352) [/]:

21:43:18.190 [TRACE] [ions.LengthPrefixedByteArrayProcessor] - Received message of length 196. Existing buffer is 0
21:43:18.192 [TRACE] [ions.LengthPrefixedByteArrayProcessor] - Attempting to read message of length 196
21:43:18.192 [TRACE] [ions.LengthPrefixedByteArrayProcessor] - Read complete message
21:43:18.193 [TRACE] [ions.LengthPrefixedByteArrayProcessor] - Returning 1 results
21:43:18.194 [DEBUG] [a.server.impl.http.impl.BinaryHandler] - Received data [/]:
PUT /characteristics HTTP/1.1
Host: openHAB._hap._tcp.local
Content-Length: 58
Content-Type: application/hap+json

21:43:18.194 [INFO ] [ver.impl.http.HomekitClientConnection] - 204 /characteristics
21:43:18.197 [DEBUG] [a.server.impl.http.impl.BinaryHandler] - Sending data [/]:
HTTP/1.1 204 No Content
Content-type: application/hap+json
Connection: keep-alive

21:43:18.197 [TRACE] [.server.impl.http.impl.LoggingHandler] - WRITE PooledUnsafeDirectByteBuf(ridx: 0, widx: 105, cap: 256) [/]:

Hope there are no secrets inside :slight_smile:
This is switching off the “LED Stripe”.

the log looks correct for me. the “Off” event is communicated correctly to home app.

if you say "ledStripeSwitch never changed " what that means? how you check this? in basic ui / paper ui?

I checked this in paper ui and with smarthome:status in karaf console…
I will create some new items next week to do more testing and logging.

Hm, read again… I switched inside the Home App, should be communicated from Home App to openHAB.

sorry, you are right. the communication is from home app to OH.

basically this line

says “0” (=Off) was sent from home app to OpenHAB for accessory with ID 1189018796 (you can check accessories IDs in karaf with “homekit listAccesories”)

this line

is the response from openHAB to home app saying “the change was successful”
there is nothing more in the log.

1 Like

I’ve checked the aid, it’s the same as in listAccessoires. I also checked the difference between the working switch and the other one. The working is sending true and false value, the non-working 0 and 1.

could you please do in karaf
homekit printAccessory 1189018796
homekit printAccessory working_switch_aid

and paste results here?

thanks a lot for helping to troubleshoot this.

It is identical.
Sorry for the screenshot. I’ve found no way to copy text on my iPad from ssh…

Edit: seem I was wrong. Here is the complete tracelog from the working switch. It also sends 0/1 and later there is another entry with true/false witch is missing in the other case.

ok. so, both ways - single line and group have created identical HomeKit items. communication seems to be ok as well. i would really check the other side - items -> things. maybe device does not accept “On” event and set it back to “off”.

Ok, thank you. Will test it next week at home and give feedback than.

Can anyone give me some hints how to use the name property?
Is it used to set the name how the item is presented on the iphone or am I not understanding this correctly?

Switch  Homekit_Pumpe     {homekit="Switchable.OnState,"}

by default HomeKit add-on uses the label of the openHAB item as the name in home app on iphone. i.e. you can write something like

Switch Homekit_Pumpe "Pumpe1" {homekit="Switchable.OnState}

in case the name of the item is dynamic, one can use the name property like this

Group  gPumpeGroup     			             {homekit = "Switchable"}
Switch  Homekit_Pumpe      (gPumpeGroup)     {homekit = "OnState}
String  Pumpe_Name	       (gPumpeGroup)     {homekit = "Name"}

in this case, the name of the accessory in home app will be the value of the item “Pumpe_Name”.

btw, you can also use “Valve” accessory for the pump. it will give you different icons in home app on iphone, e.g.

1 Like

@webjochen have you found the correct garage door opener configuration?

this one works for me:

Group  gGarage    						"Garage Group"       									{homekit = "GarageDoorOpener"}
Switch garage_obstruction 				"Garage Obsruction" 							(gGarage) 		{homekit = "ObstructionStatus"}
Switch garage_target 					"Garage Door Target State" 							(gGarage) 		{homekit = "TargetDoorState"}
String garage_current 					"Garage Door Current State" 							(gGarage) 		{homekit = "CurrentDoorState"}

and sitemap

Switch item=garage_obstruction label="Garage Obstruction"
Switch item=garage_target label="Garage Target"
Switch item=garage_current label="Garage Current" mappings=["OPEN"="OPEN", "OPENING"="OPENING", "CLOSED"="CLOSED", "CLOSING"="CLOSING",  "STOPPED"="STOPPED"]

Are you sure? The compiler says: The item of CurrentDoorState has to be CLOSE instead of CLOSED. On the official site Homekit Addon it is also mentioned as CLOSED. Could that be an error?

it was a bug/typo in the implementation. it was fixed 3 days with this commit

depending on which version you have you need to use “CLOSE” or “CLOSED”.
however, this mapping is configurable.
you can add this line to homekit.cfg to make your mapping, e.g. to “CL” instead of “CLOSE/CLOSED”

here are the all names for mapping

doorCurrentStateOpen = "OPEN"
doorCurrentStateOpening = "OPENING"
doorCurrentStateClosed = "CLOSED"
doorCurrentStateClosing = "CLOSING"
doorCurrentStateStopped = "STOPPED"
doorTargetStateClosed = "CLOSED"
doorTargetStateOpen = "OPEN"
1 Like

Hi eugen @yfre,
I’ve got the On Characteristic working. I’ve found the solution in another thread. I completly commented the thing (Group and all Items) out and in, than it works.
Now I have the next problem, hope you can help.
My device I want to include into homekit is an Aeotec LED Stripe ZW121.
I have a

  • Dimmer for Brightness (0-100%)
  • Switch for On/Off
  • Color
  • Dimmer for White Color (0 (cold) - 100% (warm))

I can create a rule to convert the temperature Item from dimmer (0-100) to number (-50 - 400). But the documentation says, I should never use color and color temperatur in combination with hsb.

What is the best way to bring the device into homekit?

Edit: not tested, but I think I need a proxy Item (Color) and expose this to homekit. In a rule I need to split it into the temperature dimmer in case it is white and color in other cases.

the limitation is from Apple. apple writes in the spec

Color Temperature
This characteristic describes color temperature which is represented in reciprocal megaKelvin (MK-1) or mirek scale. (M = 1,000,000 / K where M is the desired mirek value and K is temperature in Kelvin). If this characteristic is included in the ”8.23 Light Bulb” (page 147), ”9.44 Hue” (page 179) and ”9.82 Saturation” (page 197) must not be included as optional characteristics in ”8.23 Light Bulb” (page 147). This characteristic must
not be used for lamps which support color.

this limitation is however not enforced by homekit binding, i.e. you can try it out and add Color Temperature, Hue and Brightness to the same accessory. Maybe it will work in home app. if not, i would split this one device in 2 different “lighting” accessories: one with Hue and brightness and another one with Color Temperature.

Hi eugen,
can’t get it to work.

Group ledStripe "Aeotec LED Stripe" {homekit="Lighting"}
Switch ledStripeSwitch "Schalter" (ledStripe) {homekit="Lighting.OnState"}
Color ledStripeProxyColor (ledStripe) {homekit="Lighting.Hue, Lighting.Brightness, Lighting.Saturation"}
openhab> homekit printAccessory 1189018796
1189018796 Aeotec LED Stripe
    Service Type: 00000043-0000-1000-8000-0026BB765291
      : class io.github.hapjava.characteristics.impl.common.OnCharacteristic
      : class io.github.hapjava.characteristics.impl.lightbulb.HueCharacteristic
      : class io.github.hapjava.characteristics.impl.lightbulb.BrightnessCharacteristic
      : class io.github.hapjava.characteristics.impl.lightbulb.SaturationCharacteristic

This seems to be ok.
I’ve no linking to any “real” thing. On/Off and Dimming works as aspected. But choosing color is strange.

If I choose a color, the Item in background change also. But when I pull up my finger from the color chooser, the “bubble” jumps to an other position (the fullcolor position).

According to the documentation I tried also 3 Dimmer-Items, each for Hue, Saturation und Brightness, but it throws a error message, it is not supported.

Thanks for your help again,

i can confirm: your configuration is correct and i could reproduce your issue. it does not happen always but time to time.

it is an issue in the implementation of the binding. i have an idea to fix it but not sure whether it is a correct fix. so, opened a question in the developer channel.

thank you
it works with your sitemap,
but how do i do it when i have two items in openhab
open and close garage door
and one item for the state open and closed

it depends on your setup. i have a garage motor, which get “targetState”, and i have “contactSensor”, which is the current state.

if you dont have contact sensor that reports the door status, then you can have a rule which get triggered by TargetState changes sets currentState = CLOSING/OPENING and after sometime currentState=CLOSED/OPEN

1 Like