[SOLVED] Trouble sending Colorpicker value as HSB via MQTT to SmartThings

@Kees_van_Gelder from what I can tell “hue” & “saturation” make up the “color” value and the L refers to a “power level” value rather than “color lightness”. It appears that people refer to the colour as HSL which is incorrect as the L does not stand for “lightness” at all. From what I can tell colour is still in HSB and the B is a power level value which would make sense as that would control the brightness of the lights. I hope that makes some sense… my head hurt just writing this! :sweat:

This is going to make my rule a bit more complicated too as I need to post to two MQTT topics “color” and “level”. So I have to grab the Colorpicker values convert the the H add it to S and post to “color” and then grab the B and post that to the “level” topic.

FYI

These are the values that can be changed using the ST API

This is the code from the ST App

    "colorControl": [
        name: "Color Control",
        capability: "capability.colorControl",
        attributes: [
            "hue",
            "saturation",
            "color"
        ],
        action: "actionColor"
    ],

    "levels": [
        name: "Switch Level",
        capability: "capability.switchLevel",
        attributes: [
            "level"
        ],
        action: "actionLevel"
    ],

    "relaySwitch": [
        name: "Relay Switch",
        capability: "capability.relaySwitch",
        attributes: [
            "switch"
        ],
        action: "actionOnOff"
    ],

def actionColor(device, attribute, value) {
    switch (attribute) {
        case "hue":
            device.setHue(value as float)
        break
        case "saturation":
            device.setSaturation(value as float)
        break
        case "color":
            def values = value.split(',')
            def colormap = ["hue": values[0] as float, "saturation": values[1] as float]
            device.setColor(colormap)
        break
    }
}

So I’m going to try and create a rule that does the following: