Homekit Color Temperature with Hue Bulbs

Tags: #<Tag:0x00007efecbd7f6d8> #<Tag:0x00007efecbd7f5e8> #<Tag:0x00007efecbd7f4a8>

Hello,

I’m having some difficulty getting Homekit to correctly control the color temperature of Philips hue bulbs. I’m using the newer metadata rather than tags. This is my items file:

// Wall Downlights
Group    WallDownlights                   "Wall Downlights"                                         {alexa="Endpoint.Light"}
Color    WallDownlightsColor              "Wall Downlights Color"               (WallDownlights)    {channel="hue:0210:0017887862a1:5:color", alexa="BrightnessController.brightness,PowerController.powerState,ColorController.color", homekit="Lighting, Lighting.Hue, Lighting.Brightness, Lighting.Saturation"}
Dimmer   WallDownlightsColorTemperature   "Wall Downlights Color temperature"   (WallDownlights)    {channel="hue:0210:0017887862a1:5:color_temperature", alexa="ColorTemperatureController.colorTemperatureInKelvin", homekit="Lighting.ColorTemperature"}
String   WallDownlightsAlert              "Wall Downlights Alert"               (WallDownlights)    {channel="hue:0210:0017887862a1:5:alert"}
Switch   WallDownlightsEffect             "Wall Downlights Color loop"          (WallDownlights)    {channel="hue:0210:0017887862a1:5:effect"}

However in the log I get:

2020-09-27 22:35:28.930 [WARN ] [.accessories.HomekitAccessoryFactory] - Accessory of type Lighting must have following characteristics [ON_STATE]. Found only []

2020-09-27 22:35:28.933 [WARN ] [mekit.internal.HomekitChangeListener] - Could not add device WallDownlightsColorTemperature: Missing mandatory characteristics

If I remove homekit="Lighting.ColorTemperature" from the WallDownlightsColorTemperature item it works but when I change color temperature in the home app, they set their colour temperature in RGB as opposed to using the actual CCT part of the bulb. This results in very ‘off’ looking whites (cool whites look dark blue, warm whites look pink). I have been unsuccessful in using the Lighting.ColorTemperature characteristic on the hue bulbs color temp item. Alexa on the other hand, works perfectly.

Any help is appreciated!

Thanks!

you need to mark the group as homekit item, otherwise it considers every item in the group as separate homekit add.
please try to add to group
homekit="Lighting"

i.e.

// Wall Downlights
Group    WallDownlights                   "Wall Downlights"                                         {alexa="Endpoint.Light", homekit="Lighting"}
Color    WallDownlightsColor              "Wall Downlights Color"               (WallDownlights)    {channel="hue:0210:0017887862a1:5:color", alexa="BrightnessController.brightness,PowerController.powerState,ColorController.color", homekit="Lighting.Hue, Lighting.Brightness, Lighting.Saturation"}
Dimmer   WallDownlightsColorTemperature   "Wall Downlights Color temperature"   (WallDownlights)    {channel="hue:0210:0017887862a1:5:color_temperature", alexa="ColorTemperatureController.colorTemperatureInKelvin", homekit="Lighting.ColorTemperature"}
String   WallDownlightsAlert              "Wall Downlights Alert"               (WallDownlights)    {channel="hue:0210:0017887862a1:5:alert"}
Switch   WallDownlightsEffect             "Wall Downlights Color loop"

Thanks for the response. I just tried your suggestion but when I save the file the log shows this:

2020-09-28 10:26:37.782 [WARN ] [.accessories.HomekitAccessoryFactory] - Accessory of type Lighting must have following characteristics [ON_STATE]. Found only []

2020-09-28 10:26:37.784 [WARN ] [mekit.internal.HomekitChangeListener] - Could not add device WallDownlights: Missing mandatory characteristics

The bulb has also disappeared completely from the home app. Do you know what this could be?

Thanks.

ok. let us try to add “ON” explicitly, i.e.

// Wall Downlights
Group    WallDownlights                   "Wall Downlights"                                         {alexa="Endpoint.Light", homekit="Lighting"}
Color    WallDownlightsColor              "Wall Downlights Color"               (WallDownlights)    {channel="hue:0210:0017887862a1:5:color", alexa="BrightnessController.brightness,PowerController.powerState,ColorController.color", homekit="Lighting.OnState, Lighting.Hue, Lighting.Brightness, Lighting.Saturation"}
Dimmer   WallDownlightsColorTemperature   "Wall Downlights Color temperature"   (WallDownlights)    {channel="hue:0210:0017887862a1:5:color_temperature", alexa="ColorTemperatureController.colorTemperatureInKelvin", homekit="Lighting.ColorTemperature"}
String   WallDownlightsAlert              "Wall Downlights Alert"               (WallDownlights)    {channel="hue:0210:0017887862a1:5:alert"}
Switch   WallDownlightsEffect             "Wall Downlights Color loop"          (WallDownlights)    {channel="hue:0210:0017887862a1:5:effect"}

Thanks for the reply.

This does not result in any errors in the log but all my devices have disappeared from the home app. Only the openHAB server itself is showing but says “Not Supported”?

do you have iOS 14? similar issue was reported by other users with iOS14.
i could not reproduce it myself yet.

in general, trouble shooting would be to enable TRACE log for homekit in openhab karaf with

log:set TRACE io.github.hapjava 
log:set TRACE org.openhab.io.homekit

and check in logs whether openHAB get any requests from iphone.

another things that helps sometimes - if you have apple tv or ipad then disable homekit bridge there to ensure that iphone communicates directly with openhab and not via the bridge.

Yes, I’m using iOS 14 on iPhone X. I don’t have an Apple TV or iPad set up as a bridge. I will try enabling the logs and see if there is any clues and I’ll come back and let you know. Thanks.

I’ve had the logs active for a few days now and can’t spot anything obvious that would be causing this issue.

Everything works perfectly (apart from no CT control via HomeKit) with:

Group    WallDownlightsT                   "Wall Downlights Test"                                          {alexa="Light", homekit="Lighting"}
Color    WallDownlightsColorT              "Wall Downlights Color Test"               (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:color", alexa="BrightnessController.brightness, PowerController.powerState, ColorController.color", homekit="Lighting.onState, Lighting.Hue, Lighting.Brightness, Lighting.Saturation"}
Dimmer   WallDownlightsColorTemperatureT   "Wall Downlights Color temperature Test"   (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:color_temperature", alexa="ColorTemperatureController.colorTemperatureInKelvin"}
String   WallDownlightsAlertT              "Wall Downlights Alert Test"               (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:alert"}
Switch   WallDownlightsEffectT             "Wall Downlights Color loop Test"          (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:effect"}

But as soon as I add homekit=“Lighting.ColorTemperature” to the ColorTemperature item, all my HomeKit devices turn to “No Response”:

Group    WallDownlightsT                   "Wall Downlights Test"                                          {alexa="Light", homekit="Lighting"}
Color    WallDownlightsColorT              "Wall Downlights Color Test"               (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:color", alexa="BrightnessController.brightness, PowerController.powerState, ColorController.color", homekit="Lighting.onState, Lighting.Hue, Lighting.Brightness, Lighting.Saturation"}
Dimmer   WallDownlightsColorTemperatureT   "Wall Downlights Color temperature Test"   (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:color_temperature", alexa="ColorTemperatureController.colorTemperatureInKelvin", homekit="Lighting.ColorTemperature"}
String   WallDownlightsAlertT              "Wall Downlights Alert Test"               (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:alert"}
Switch   WallDownlightsEffectT             "Wall Downlights Color loop Test"          (WallDownlightsT)    {channel="hue:0210:0017887862a1:5:effect"}

I can’t understand why this is happening and would really love some inspiration as to where to start debugging / fixing this. I have tried creating a mock color temperature only bulb but as soon as I add the homekit="Lighting.ColorTemperature" metadata anywhere, HomeKit breaks entirely. Thanks in advance.

just found this in apple homekit specification

9.21 Color Temperature
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.

basically, it says, either hue and saturation or color temperature, but not both at the same time.
could you verify whether color temperature would work without hue and saturation

Hmmm, that’s interesting since when I connect my hue bridge to HomeKit natively it can control both colour and colour temperature. In OpenHAB, if I leave out the colour temperature metadata, the colour temperature selector in the home app does work but the colours are very bad as I mentioned before. It uses the RGB channels of the bulb to simulate colour temperature rather than using the actual CCT channels / LEDs. This results in very pink looking warm whites and very blue looking cool whites. Out of curiosity I did try the colour temperature tag on it’s own on a separate mock bulb item without color but the result was the same (“No Response” in the home app). It’s strange since Alexa works perfectly.

Hi all,

i can report same Problem. As soon as you add the Colortemperature Number item Homekit is not responding anymore and there is no device in Home App available.

It’s 100% reproducable, some information:

IOS: 14.3
openhab> bundle:list | grep Homekit
295 │ Active │ 80 │ 2.5.13.202101160304 │ openHAB Add-ons :: Bundles :: IO :: Homekit
(Downloaded newest homekit bundle from 16th Jan 2021)

Item file “working” (without Colortemp, just normal brightness bulb):

Group homekit_gTW “TW” {homekit=“Lighting”}
Dimmer homekit_tw_bright “mytw_bright” (homekit_gTW) {homekit="Lighting, Lighting.Brightness "}
Log: homekit_wo_colortemp.txt (15.0 KB)

Item file not working (with Colortemp):

Group homekit_gTW “TW” {homekit=“Lighting”}
Dimmer homekit_tw_bright “mytw_bright” (homekit_gTW) {homekit="Lighting, Lighting.Brightness "}
Number homekit_tw_color “mytw_color” (homekit_gTW) {homekit="Lighting.ColorTemperature "}
Log: homekit_with_colortemp.txt (11.2 KB)

Attached are both logs with:

log:set TRACE io.github.hapjava
log:set TRACE org.openhab.io.homekit

You can easily reproduce this scenario with the Items above (no need to connect the items to channels/things).

I don’t see any obvious problems/errors in the log but i looks definitely different.

Somebody able to help? Can provide any further debug information.

i could reproduce it.
the data openhab sends to home app looks ok and according to latest public apple specification, but home app reject it with the error “Out of compliance”. it needs further investigation. maybe we need to wait for next specification release to understand how to fix.

Not sure wether this helps but i tried node red in combination with the homekit node:

Example Bulb Dimmer · NRCHKB/node-red-contrib-homekit-bridged Wiki · GitHub
node-red-contrib-homekit-bridged (node) - Node-RED

And with this node the colortemperature is working fine. So maybe this helps to figure out why openhab is not working with colortemperature setting.

good hint. i can compare both implementations - openhab native and HAP-NodeJS that used for node-red-bridge

Great, hopefully it’s only a minor thing :slight_smile:
I am happy to help.

issue identified.

  • Java-HAP library used by openHAB always sends one optional parameters as part of accessory description. It looks like this parameter accepted/ignored for all accessories but not for color temperature.
  • HAP-Node used by Node-RED never sends this parameter.
  • this parameter has not special meaning in the communication from bridge to home app.

it is difficult to say whether it is a bug of home app or of the lib. on one hand, we dont need to send it. on another hand, home app could just ignore it as it does for all other accessories.

anyway, i have submitted a fix for the lib Remove event parameter by yfre · Pull Request #134 · hap-java/HAP-Java · GitHub
but im afraid it will take some time until the fix gets merged, lib gets released and we can use fixed version in openHAB.