Help for the new Introduction of profiles


(M) #1

Hello,
I understand that i can use the new introduced profiles as a kind of masterswitch for different single items.

I have currently following rule in my setup

rule "set hue group2 onoff"
    when
    Item switch_hueonoffgroup2 changed
then
    if (switch_hueonoffgroup2.state == OFF) {
            sendCommand(Hue_switch_colorlamp1, OFF)
            sendCommand(Hue_switch_colorlamp2, OFF)
            sendCommand(Hue_switch_colorlamp3, OFF)
            createTimer(now.plusSeconds(40), [ | sendCommand(Hue_switch_colorlamp1, OFF) ])
            createTimer(now.plusSeconds(40), [ | sendCommand(Hue_switch_colorlamp2, OFF) ])
            createTimer(now.plusSeconds(40), [ | sendCommand(Hue_switch_colorlamp3, OFF) ])
    }else {
            sendCommand(Hue_switch_colorlamp1, ON)
            sendCommand(Hue_switch_colorlamp2, ON)
            sendCommand(Hue_switch_colorlamp3, ON)
            createTimer(now.plusSeconds(40), [ | sendCommand(Hue_switch_colorlamp1, ON) ])
            createTimer(now.plusSeconds(40), [ | sendCommand(Hue_switch_colorlamp2, ON) ])
            createTimer(now.plusSeconds(40), [ | sendCommand(Hue_switch_colorlamp3, ON) ])
    }
    logInfo("set hue group2 onoff", switch_hueonoffgroup2.state.toString)
end    

Can I exchange this rule with a profile and how???


(Vincent Regaud) #2

First you could create a group containing these three items then your rulle would much simpler:

rule "set hue group2 onoff"
when
    Item switch_hueonoffgroup2 changed
then
    if (switch_hueonoffgroupColor2.state == OFF) {
        LightsGroup2.sendCommand(OFF)
        createTimer(now.plusSeconds(40), [ | LightsGroup2Switch.sendCommand(OFF) ])
    }else {
        LightsGroup2.sendCommand(ON)
        createTimer(now.plusSeconds(40), [ | LightsGroup2Switch.sendCommand(ON) ])
    }
    logInfo("set hue group2 onoff", switch_hueonoffgroup2.state.toString)
end    

Or even simpler:

rule "set hue group2 onoff"
when
    Item switch_hueonoffgroup2 changed
then
    if (switch_hueonoffgroup2 == NULL || switch_hueonoffgroup2 == UNDEF) return; //DO NOTHING
    LightsGroup2.sendCommand(switch_hueonoffgroup2.state.toString)
    createTimer(now.plusSeconds(40), [ | LightsGroup2Switch.sendCommand(switch_hueonoffgroup2.state.toString) ])
    logInfo("set hue group2 onoff", switch_hueonoffgroup2.state.toString)
end    

For profile, we would need your item definitions, please


(M) #3

Items

Switch Hue_switch_colorlamp1 "colorlamp1 Schalter" (group_house_switch_light){ channel="hue:0210:00178821b3ed:1:color" }

Switch Hue_switch_colorlamp2 "colorlamp2 Schalter" (group_house_switch_light){ channel="hue:0210:00178821b3ed:2:color" }

Switch Hue_switch_colorlamp3 "colorlamp3 Schalter" (group_house_switch_light){ channel="hue:0210:00178821b3ed:3:color" }


Switch switch_hueonoffgroup2 "Hue onoff Group2" <switch>

(Vincent Regaud) #4

Have you tried this:

Switch Hue_switch_colorlamp1 "colorlamp1 Schalter" (group_house_switch_light){ channel="hue:0210:00178821b3ed:1:color" [profile="follow", item="switch_hueonoffgroup2" }

I don’t know if it will work.
You can achieve the same thing with groups and no rule:

Group:Switch switch_hueonoffgroup2 "Hue onoff Group2" <switch>

Switch Hue_switch_colorlamp1 "colorlamp1 Schalter" (group_house_switch_light, switch_hueonoffgroup2){ channel="hue:0210:00178821b3ed:1:color" }
Switch Hue_switch_colorlamp2 "colorlamp2 Schalter" (group_house_switch_light, switch_hueonoffgroup2){ channel="hue:0210:00178821b3ed:2:color" }
Switch Hue_switch_colorlamp3 "colorlamp3 Schalter" (group_house_switch_light, switch_hueonoffgroup2){ channel="hue:0210:00178821b3ed:3:color" }

(M) #5

yes but didn’t work


(Vincent Regaud) #6

Worth a try… Sorry


(M) #7

No worries :slight_smile: You help me a lot…

If I want your shortened rule

rule "set hue group2 onoff"
when
    Item switch_hueonoffgroup2 changed
then
    if (switch_hueonoffgroup2 == NULL || switch_hueonoffgroup2 == UNDEF) return; //DO NOTHING
    LightsGroup2.sendCommand(switch_hueonoffgroup2.state.toString)
    createTimer(now.plusSeconds(40), [ | LightsGroup2Switch.sendCommand(switch_hueonoffgroup2.state.toString) ])
    logInfo("set hue group2 onoff", switch_hueonoffgroup2.state.toString)
end    

How do I need to set the items right?


(Vincent Regaud) #8

You need to set the items this way:

Group:Switch switch_hueonoffgroup2 "Hue onoff Group2" <switch>

Switch Hue_switch_colorlamp1 "colorlamp1 Schalter" (group_house_switch_light, switch_hueonoffgroup2){ channel="hue:0210:00178821b3ed:1:color" }
Switch Hue_switch_colorlamp2 "colorlamp2 Schalter" (group_house_switch_light, switch_hueonoffgroup2){ channel="hue:0210:00178821b3ed:2:color" }
Switch Hue_switch_colorlamp3 "colorlamp3 Schalter" (group_house_switch_light, switch_hueonoffgroup2){ channel="hue:0210:00178821b3ed:3:color" }

And then the rule is even simpler:

rule "set hue group2 onoff"
when
    Item switch_hueonoffgroup2 changed
then
    if (switch_hueonoffgroup2 == NULL || switch_hueonoffgroup2 == UNDEF) return; //DO NOTHING
    createTimer(now.plusSeconds(40), [ | switch_hueonoffgroup2.sendCommand(switch_hueonoffgroup2.state.toString) ])
    logInfo("set hue group2 onoff", switch_hueonoffgroup2.state.toString)
end    

But why are you sending the same command to the same items 40s later?