Colorpicker - dimmer slider not preserved across power on/off states

  • Platform information:

    • Hardware: Rapsberry Pi 3 Model B
    • OS: OpenHabian 2.4.0 (Raspbian stretch)
    • Java Runtime Environment: Zulu Embedded 8.25.0.76
    • openHAB version: 2.4.0
  • Issue of the topic:

I have an LED strip controller (Magichome) running the Tasmota firmware. Openhab is configured to interface with it using MQTT v1 binding (I’d already got a number of other Tasmota devices working successfully with the v1 binding so don’t want to switch to the v2 binding if I can avoid it).

Almost everything is working fine with the LED strip through the Basic UI: I can power it on and off from a Switch element, and also from the ^ and v buttons on a Colorpicker element; and I can control color and dimming through the Colorpicker element (on the color wheel and the dimmer slider on the Colorpicker).

The problem is that when I power off, and then on again, the dimming slider on the Colorpicker element is set to 100%. This doesn’t match the setting in the device - the device powers on at the dimmer level it had when it powered off.

How can I get the dimmer slider to match?

Items:

Color   Kitchen_UtilLight "Utility" <lightbulb> 
Switch  Kitchen_UtilLightPwr 
 {mqtt=">[mosquitto:tasmota/kitchen/lights/sonoff-ledutil/cmnd/POWER:command:*:default],
        <[mosquitto:tasmota/kitchen/lights/sonoff-ledutil/stat/POWER:state:default]", autoupdate="false"}
Color   Kitchen_UtilLightCol 
 {mqtt=">[mosquitto:tasmota/kitchen/lights/sonoff-ledutil/cmnd/HSBCOLOR:command:*:default],
        <[mosquitto:tasmota/kitchen/lights/sonoff-ledutil/stat/RESULT:state:JSONPATH($.HSBColor):.HSBColor.]", autoupdate="false"}

Sitemap:

  Switch item=Kitchen_UtilLightPwr label="Utility" icon="light"
  Colorpicker item=Kitchen_UtilLight label="Utility" icon="colorwheel"

Rules:

rule "LED command intercept"
when
    Item Kitchen_UtilLight received command
then
    if (receivedCommand instanceof OnOffType) {
        logInfo("LED intercept", "Received OnOffType")
        Kitchen_UtilLightPwr.sendCommand(receivedCommand)
    }
    else if (receivedCommand instanceof HSBType) {
        logInfo("LED intercept", "Received HSBType")
        Kitchen_UtilLightCol.sendCommand(receivedCommand)
    }
 end

Tasmota console log (Power on, dim to 50%, power off, power on):

16:24:16 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/RESULT = {"POWER":"ON"}
16:24:16 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/POWER = ON
16:24:28 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/RESULT = {"POWER":"ON","Dimmer":50,"Color":"7F7F7F","HSBColor":"0,0,50","Channel":[49,49,49]}
16:24:28 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/RESULT = {"POWER":"ON","Dimmer":50,"Color":"7F7F7F","HSBColor":"0,0,50","Channel":[49,49,49]}
16:24:52 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/RESULT = {"POWER":"OFF"}
16:24:52 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/POWER = OFF
16:24:57 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/RESULT = {"POWER":"ON"}
16:24:57 MQT: tasmota/kitchen/lights/sonoff-ledutil/stat/POWER = ON

Have you tried without the else if?

Example:

rule "LED command intercept"
when
    Item Kitchen_UtilLight received command
then
    if (receivedCommand instanceof OnOffType) {
        logInfo("LED intercept", "Received OnOffType")
        Kitchen_UtilLightPwr.sendCommand(receivedCommand)
    }
    if (receivedCommand instanceof HSBType) {
        logInfo("LED intercept", "Received HSBType")
        Kitchen_UtilLightCol.sendCommand(receivedCommand)
    }
 end

I’ve resolved it myself - no time to post solution now, but will followup later.

, autoupdate="false"

That’s your problem…
Remove it

I don’t want to highjack your post but as I’m running the same setup (MagicHome Ctrl w/Tasmota) I wanted to inform you/others about my config WITH MQTT2.4. it took me ages to switch to the new version…

Thing topic OfficeLED1 "OfficeLED indirekte Beleuchtung" @ "Office" {
    Channels: 
        Type switch : power1 "indirekte Beleuchtung" [ stateTopic="stat/LED_Office/POWER", commandTopic="cmnd/LED_Office/POWER", on="ON", off="OFF"]
        Type colorHSB : hsbcolor1 "LED Licht" [ commandTopic="cmnd/LED_Office/HSBColor", transformationPattern="JSONPATH:$.HSBColor"]
        Type dimmer : dimmer1 "Dimmer Office" [ commandTopic="cmnd/LED_Office/DIMMER", transformationPattern="JSONPATH:$.Dimmer"]
        Type string : irsensor1 "Infrarot Empfaenger" [ stateTopic="tele/LED_Office/RESULT", transformationPattern="JSONPATH:$.IrReceived.Data"]
    }
//MagicHome LED Stripes mit Tasmota fw LED_Office 192.168.1.142
        Switch LED_Office "indirekte Beleuchtung [MAP(OnOff.map):%s]" <light> (gLicht) { channel= "mqtt:topic:myBroker:OfficeLED1:power1"}                   
        Color LED_Office_Color_tasmota2   "LED Licht" { channel= "mqtt:topic:myBroker:OfficeLED1:hsbcolor1", autoupdate="false"} 
        Dimmer LED_Office_Dimmer "Dimmer Office [%.0f %%]" { channel= "mqtt:topic:myBroker:OfficeLED1:dimmer1"}
        String LED_Office_IR "Infrarot Empfaenger" { channel= "mqtt:topic:myBroker:OfficeLED1:irsensor1"}

thanks to your post I tried autoupdate=“false” which solved the problem that the selections within the colorpicker popup always jumps back to an initial setting.
you can see I do not read the color and dimmer values via MQTT, I do only send commands. as I don’t change color or luminosity from outside of openhab I can live without reading those setting. it previously worked under MQTT1x but not in my 2.4 installation, no idea why…

        Type colorHSB : hsbcolor1 "LED Licht" [ commandTopic="cmnd/LED_Office/HSBColor", transformationPattern="JSONPATH:$.HSBColor"]
        Type dimmer : dimmer1 "Dimmer Office" [ commandTopic="cmnd/LED_Office/DIMMER", transformationPattern="JSONPATH:$.Dimmer"]

You can loose the transformationPattern, it only works with stateTopic

Thanks for all the suggestions. The problem was within the return path for the HSB color status.

The original was:

The fault was in the matching pattern at the end - this needs to be .*HSBColor.*