[Homekit] RGB Lighting reverts to previous setting

Hi.
So… I want to control my LED Strip (WS2812) with OpenHAB and Homekit (using the addon in OH2). When I use basic UI (or iOS OpenHAB app) everything works as a charm. However, when I’m using Homekit, there are some problems.

Firstly, usually I can’t change the color – it automatically goes back to the previous one in a fraction of a second. Nevertheless, the brightness and ON/OFF commands work in a propoer way.
And the second problem – when it is possible to change the color, I can only change colors with the same diameter as the one set in the beggining, therefore I can’t for example turn the color from red to white (because white is in the middle of a color circle in iOS). It is sometimes possible with Siri but sometimes only with OpenHAB app/UI.

My settings are:

led.items

Color TVLedLight  "Bed Color" <colorlight> [ "Lighting" ]
String TVLedLightColor {mqtt=">[<CENSORED>:command:*:default]"}

led.rules (NOTE: tried also without this rule and the problem still occurred – logs below are performed with the rule disabled)

import org.openhab.core.library.types.*

rule "Set RGB value TVLedLight"

when

        Item TVLedLight changed

then

        val hsbValue = TVLedLight.state as HSBType

        val brightness = hsbValue.brightness.intValue

        val redValue   = ((((hsbValue.red.intValue * 255) / 100) * brightness) / 100).toString

        val greenValue = ((((hsbValue.green.intValue * 255) / 100) * brightness) / 100).toString

        val blueValue  = ((((hsbValue.blue.intValue *255) / 100) * brightness) / 100).toString

        val color = redValue + "," + greenValue + "," + blueValue

        sendCommand( TVLedLightColor, color )

end

And the sitemap is with the Colorpicker element which sets HSB value. What is important – there is no problem with OpenHAB control – everything works flawlessly. However, Homekit makes trouble. Sometimes it works but only 3-4 times and then it fails.

Theretically I still can change colors etc., but no changes are made – at most it blinks in the desired color but then changes again, usually reverts to previous settings. It also makes no difference if I use Siri or not.

Of course there is possibility that it is Homekit/iOS’ bug, not the OpenHAB2 Homekit addon one but I can’t check it (or I don’t know how to do it).

And the logs, when I say to Siri „turn the LED white”, are like this:

21:17:02.732 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘TVLedLight’ received command 0,54,100
21:17:02.733 [INFO ] [ap.impl.http.HomekitClientConnection] - 204 /characteristics
21:17:02.739 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘TVLedLight’ received command 0,0,0
21:17:02.742 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.744 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.750 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘TVLedLight’ received command ON
21:17:02.760 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.768 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.770 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘TVLedLight’ received command 0,54,0
21:17:02.774 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.775 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.778 [INFO ] [marthome.event.ItemStateChangedEvent] - TVLedLight changed from 0,54,0 to 0,54,100
21:17:02.778 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.778 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.780 [INFO ] [marthome.event.ItemStateChangedEvent] - TVLedLight changed from 0,54,100 to 0,0,0
21:17:02.787 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.787 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.791 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.792 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.807 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.809 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.812 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.817 [INFO ] [impl.connections.SubscriptionManager] - Publishing changes for 1539965154
21:17:02.821 [INFO ] [marthome.event.ItemStateChangedEvent] - TVLedLight changed from 0,0,0 to 0,0,100
21:17:02.825 [INFO ] [marthome.event.ItemStateChangedEvent] - TVLedLight changed from 0,0,100 to 0,54,0

My guess is the OpenHAB generates too many publishing changes events and goes stupid but of course I can be wrong.

Hi,

I have exactly the same issue. The Color changes momentarily and switched back to what it was. Other functions work. In the logs you can see a second event triggering it back to the original.

Did you manage to fix this,

Nope, I’ve given up.

It is strange - wonder what is sending the second event for it to change back. I plan to try it with something other than HomeKit (possible amazon / but it means I have to purchase an amazon dot). As I don’t think it’s OpenHab, seems to be a HomeKit binding bug possibly.

Ok I got it working some what(can’t use the programmes)

Device protocol LD382A
Device Driver FADING

Also in control make sure the Color saturation is set to max or we see just white light. But it kind of works. I can use Siri to change via name of the colours.

Hope it helps

I don’t understand. What did you do exactly?

The above for your thing config

In control for item make sure saturation is 100% or the light will stay white

Hope this helps

Oh, I’m using DIY LED Strip with TCP Binding (for OH 1.x), so unfortunately can’t get any use of this.

But thanks, maybe it will solve someone else’s problem :slight_smile: