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.