Dynamic variable over a group of shutters?

Hi there,

I want to create a variable (probably String Item I guess) for habpanel that is bound to a group of shutters eg_shutters.

It should contain:
‘down’ if ALL shutters in the group are down
’up’ if ALL shutters in the group are down
’partial’ if mixed

Is there a way I can specify this dynamically in the item definition?
Or do I need to catch update commands individually?

Thank you very much

If you want non-standard states (e.g. your “partial” if mixed) you need to use a Rule. However, if you put your Rollershutters into a group it is a really simple Rule.

rule "Shutters State"
when
    Item gAllShutters received update
then
    val numUp = gAllShutters.members.filter[s|s.state == UP].size
    val total = gAllShutters.members.size

    switch numUp {
        case total: AllShutters.postUpdate("up")
        case 0:     AllShutters.postUpdate("down")
        default:    AllShutters.postUpdate("partial")
    }
end
2 Likes

Thanks a lot @rlkoshak that’s exactly what I need!