[SOLVED] Bind switch to other switches state

Dear All,

I would like to bind somehow a switch to a logical combination of other switches. So I would like to indicate if “Anyone at home” or “Everyone at home”.

For example let me say I have two switches in my items file:
Switch MeHome “Me” {channel…}
Switch WifeHome “Wife” {channel…}

An I would like to have two switches like:
Switch AnyoneHome “House is not empty” {channel=MeHome OR WifeHome }
Switch EveryoneHome “Everyone is at home” {channel=MeHome AND WifeHome }

The question is if I can do it with some logical binding similar to tha above pseudo syntax or I only can do it with rules and state changes for example?

If the rule is the only option I think I can implement it. But if I could do some kind of binding to a logical combination of other items please let me know how to do it.

Thank you in advance!

You can use a rule that checks who’s home then update your proxy item.

Example:

rule "Presents"
when
    Item MeHome received update  or
    Item WifeHome received update 
then
    if(MeHome.state == ON && WifeHome.state == ON){
        EveryoneHome.sendCommand(ON)
        }
    else(MeHome.state == ON || WifeHome.state ==ON){
        AnyoneHome.sendCommand(ON)
        }
end
    

Or your can use two group items. One with Or and one with AND.
See the group items docs for how to do that.
No need for rules

4 Likes

Good idea Vincent.:+1:

Why do I always pick the hard way.:thinking::stuck_out_tongue_winking_eye::laughing:

Thats exactly what I wanted, thanks!
I already read the doc some time ago but this group state was not clear for me… until now…

Thanks!