[SOLVED] Cycle through different Light setups with Scene Switch

Hi,
I succesfully set up a Scene Switch to control an RGB Light Strip.

However, what I would like to achieve is that if I turn it on it cyles through different preset Scenes

I am using the Scene Switch as follows:

rule "Kitchen Switch"

when Item Zwave_Switch_SceneNumber received update
then
switch(Zwave_Switch_SceneNumber.state.toString) {
        case "1.0": {
		Kitchen_LightStrip_Toggle.sendCommand(ON)
                }
		case "3.0": {
		Kitchen_LightStrip_Toggle.sendCommand(OFF)
		}
	  
    }
end	

The result should be something like:

rule "Kitchen Switch"

//Light Setting 1 
Kitchen_LightStrip_Color.sendCommand("290,88,9")
Kitchen_LightStrip_Dimmer.sendCommand("50")
//Light Setting 2
Kitchen_LightStrip_Color.sendCommand("230,88,9")
Kitchen_LightStrip_Dimmer.sendCommand("50")
//Light Setting 3
Kitchen_LightStrip_Color.sendCommand("230,88,9")
Kitchen_LightStrip_Dimmer.sendCommand("100")

when Item Zwave_Switch_SceneNumber received update
then
switch(Zwave_Switch_SceneNumber.state.toString) {
        case "1.0": {
if Kitchen_LightStrip_Toggle is OFF send Command ON
  Set light to the last light setting it was at

if Kitchen_LightStrip_Toggle is ON and set to Light Settiung 1
Switch from Light Setting 1 to Light Setting 2

if Kitchen_LightStrip_Toggle is ON and set to Light Settiung 2
Switch from Light Setting 2 to Light Setting 3

if Kitchen_LightStrip_Toggle is ON and set to Light Settiung 3
Switch from Light Setting 3 to Light Setting 1

                }
		case "3.0": {
		Kitchen_LightStrip_Toggle.sendCommand(OFF)
		}
	  
    }
end	

How do I accomplish what I am looking for??
Thanks for the help!

Hi

I think I’ve got something very similar running happily.

Try adapting this rule :-

Repeat rule while a trigger matches a given state UI

I’ve actually taken it a stage further now.

I’ve added a ColourPicker to the RGB lights and replaced each RGB command with a single HSL ColorPicker command.

It’s now much easier to tweak the colour of each step.

I’ve added a dummy widget next to the colour picker in HabPanel, so that I can see the HSL values for each colour I want to use.

It’s just a matter of putting that value into a ColourPicker command.

bathroomcolour.sendCommand("97,100,100")

Introduce a virtual item “scenenumber” of Number type and change that on every switch toggle, then change your rule to get triggered on changes to that new item.

1 Like

I did as you suggested.
So i implemented the virtual item and came up with this rule:

when
Item Kitchen_LightStrip_SceneNumber received command
then
    switch (Kitchen_LightStrip_SceneNumber.state) {
        case 1: {
            logInfo("Kitchen Switch", "Activate Lightsetting 1")
        }
        case 2: {
           logInfo("Kitchen Switch", ""Activate Lightsetting 2")
        }
        case 3: {
             logInfo("Kitchen Switch", ""Activate Lightsetting 3")
        }
    }
end

now how do I count up when I press the switch probably something like:

case "1.0": {
Kitchen_LightStrip_Toggle.sendCommand(ON)
 val lightstrip_scenenumber = lightstrip_scenenumber + 1
Kitchen_LightStrip_SceneNumber.postUpdate(lightstrip_scenenumber)
}

Is that somewhat correct? How do I tell the rule, that it has to go back to 1 after it has reached 3?

Thanks…

Not quite.

var Number x = lightstrip_scenenumber.state + 1
lightstrip_scenenumber.postUpdate(x)

Now come on, that’s basic programming skills, isn’t it ?
if (x == 3) x = 1
Don’t forget to lightstrip_scenenumber.postUpdate(x)

Thank you all for your input. This is what I came up with:

var Number kitchenScene = 1
val Number maxKitchenScene = 3

rule "Kitchen Switch"
when 
Item Zwave_Switch_SceneNumber received update
then
	switch(Zwave_Switch_SceneNumber.state) {
        case 1.0: {
        if(Kitchen_LightStrip_Toggle.state==OFF)
        {Kitchen_LightStrip_Toggle.sendCommand(ON)
        else {
            if (kitchenScene >= maxKitchenScene) {
                kitchenScene = 1
                Kitchen_LightStrip_SceneNumber.postUpdate(kitchenScene)}
             else{
                kitchenScene = kitchenScene + 1
                Kitchen_LightStrip_SceneNumber.postUpdate(kitchenScene)}
        }}
		case 3.0: {
		Kitchen_LightStrip_Toggle.sendCommand(OFF)}
		case 2.0: {
    	Kitchen_SinkLight.sendCommand(ON) }    
		case 4.0: {
		Kitchen_SinkLight.sendCommand(OFF)}
		
    
    }
end	

rule "Scene Selector Kitchen Strip"

when
Item Kitchen_LightStrip_SceneNumber changed
then
    switch (Kitchen_LightStrip_SceneNumber.state) {
        case 1: {
            logInfo("Kitchen Switch", "Scene 1")
//Some color
        }
        case 2: {
           logInfo("Kitchen Switch", "Scene2")
//Some color
        }
        case 3: {
             logInfo("Kitchen Switch", "Scene 3")
//Some color
        }
    }
end

It is working. I hope that this is the correct way to do it.