Same rule for different rooms

val numON = MyGroup.members.filter[itm | itm.state == ON].size
if(size > 0){
    // then
}

If you want to do something for all members of the Group that are ON

MyGroup.members.filter[itm | itm.state == ON].forEach[itm |
    // then
]

I didn’t notice before that the original is a series of if statements, not if else. But I think you are on the right track. Put the Items into a Group and loop through the members of the Group checking each room one by one. Use Design Pattern: Associated Items.