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) [/192.168.199.41:49937]:
B2006D1D64FBE65860BEA4E55AAD162648CB2F04E1012207563732CE0716858FD9D3E91EBF15E02618630BA50DA2CF4EA97555A6372C94E0759729869C4697FAD2F4F992ABA8E6D37DBF9279460AC3D8DDE16381CB462A48A7B813FBB33BDBB99168E508619F8A56910BED0D4B7618804FF93010D4085F36B0FBB8588C6443772FC4611D355A78F1CA878F194DA30DA2F5102B7A256AEAE599A0C4BCCC2E34DC6823017C17E6B14FBF41A26DDAD7798EEF3BB50C6DBF9B5A42D2013636235E4F3A6A9E43

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 [/192.168.199.41:49937]:
PUT /characteristics HTTP/1.1
Host: openHAB._hap._tcp.local
Content-Length: 58
Content-Type: application/hap+json

{"characteristics":[{"aid":1189018796,"iid":9,"value":0}]}
21:43:18.194 [INFO ] [ver.impl.http.HomekitClientConnection] - 204 /characteristics
21:43:18.197 [DEBUG] [a.server.impl.http.impl.BinaryHandler] - Sending data [/192.168.199.41:49937]:
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) [/192.168.199.41:49937]:
57005EE21D4A82E72DE4B5074AC8FFA9076731AAC82C9E112AAB49D6E3E33FA180C7CBCFC72927A149157F743BABB56DCD08CDCE2BD81D4763182DCBBEE7E13FCB037849B13BFA36317C20C8E842E6BC43A92C92159739F1C1C46E02C0B859EC11A41E0E45F387E543

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

@danil
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.

interesting.
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,Switchable.name=Pumpe1"}

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.
image
image

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”
doorCurrentStateClosed="CL"

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
Services:
    Service Type: 00000043-0000-1000-8000-0026BB765291
    Characteristics:
      : 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.

ezgif.com-video-to-gif

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,
Daniel

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