Rule 1 button switch 2 modes

(Michiel) #1

hi i’m stuck with a rule i’m trying to make.
I have a two button switch
mihome:86sw2:158d000XXXXXXX:ch2

A have a HUE lamp with 2 channels

E2Lbedlamp_dimmer_colortemp  and  E2Lbedlamp_dimmer

E2Lbedlamp_dimmer_colortemp set to 100% is romantic light
E2Lbedlamp_dimmer_colortemp set to 0% is goed for reading

When I trigger mihome:86sw2:158d000XXXXXXX:ch2 I want to switch between 0% and 100% !

This should not be that difficult.

Below 2 attempts

The seconds works one time , the first one is not responding at all

rule "Switch lamp mode"

when
    Channel "mihome:86sw2:158d0001641c68:ch2" triggered 
then
  switch (E2Lbedlamp_dimmer_colortemp) {
		case "0" : {
                                   E2Lbedlamp_dimmer_colortemp.sendCommand(100)
                       }
               case "100" : {                           
			          E2Lbedlamp_dimmer_colortemp.sendCommand(0)
                   }
        }
end
rule "Switch lamp mode"

when
    Channel "mihome:86sw2:158d0001641c68:ch2" triggered 
then
     if (E2Lbedlamp_dimmer_colortemp == 0) {E2Lbedlamp_dimmer_colortemp.sendCommand(100)}   else {E2Lbedlamp_dimmer_colortemp.sendCommand(0)}
  }
  
end
0 Likes

(Rossko57) #2

In your switch() and if() statements, you probably are interested in Item.state

0 Likes

(Michiel) #3

Thank you rossko,

The rule below did the trick

rule "Switch bedlamp mode"
when
    Channel "mihome:86sw2:158d000xxxxxxx:ch2" triggered 
then
 if (E2Lbedlamp_dimmer_colortemp.getStateAs(OnOffType) == OFF) {E2Lbedlamp_dimmer_colortemp.sendCommand(100)} else {E2Lbedlamp_dimmer_colortemp.sendCommand(0)}
end
0 Likes