Increase and Decrease Color (Policelight)


I am using Yeelights with this item config:

Switch  Light_YeeLight1_OnOff          "Kugellampe"         <wallswitch>  (gYeelight1,gWohnzimmerlicht_Schalten)            {channel="yeelight:wonder:0x000000000531dd46:color"}
Color   Light_Yeelight1_Color          "Kugel Farbe"        <colorpicker> (gYeelight1,gWohnzimmerlicht_Farbe)               {channel="yeelight:wonder:0x000000000531dd46:color"}
Dimmer  Light_Yeelight1_Farbtemperatur "Farbtemperatur"     <slider>      (gYeelight1)                                      {channel="yeelight:wonder:0x000000000531dd46:colorTemperature"}

I am trying to create something like an Police-Light, so fading an color from high to low and back.

So i added a Dimmer-Item to the Color-Channel:

Dimmer  Light_Yeelight1_ColorDimmer    "Kugel Farbestärke [%s]"      <slider> (gYeelight1)                                    {channel="yeelight:wonder:0x000000000531dd46:color"}

I tried to increase and decrease it with item.sendCommand(DECREASE), but that didnt work. So what worked was item.sendCommand(item.state as Number - 1).

The Problem:
If i declare the channel as above as an Color Item AND and Dimmer Item, then if i decrease or increase the dimmer after a second it will get back to 100. It seems, that the Color Item always set it back.

Any ideas, what i didnt unterstand?

Thank you!

Why would you want to use the same channel as Color Item AND Dimmer Item?
Dimmer Item is a subset of Color Item, and Switch Item is a subset of Dimmer Item, so you should be able to switch a color Item with ON/OFF, and a Slider bound to a color Item should increase/decrease the brightness.

INCREASE/DECREASE as command has to be implemented by the binding or the hardware itself. But of course you could use a rule like this:

rule "increase - decrease"
    Item myDimmerItem received command
    if(!(receivedCommand instanceof Number)) {
        switch receivedCommand {
            case INCREASE : {
                if((myDimmerItem.state as Number) < 96) myDimmerItem.sendCommand((myDimmerItem.state as Number) + 5)
            case DECREASE : {
                if((myDimmerItem.state as Number) > 4) myDimmerItem.sendCommand((myDimmerItem.state as Number) - 5)