Split out states from multiple contact sensors


(Mike Penda) #1

Hello. I’m writing an app which checks the status of mutiple contact sensors. I’ve set the input to “mutiple: true” so I can just select the ones I want. The problem is notification when one is open. When I check the state, I see (open, closed, closed, open, closed), and I can get a similar list of display names. But how to I subscript this list? I used:
def doorState = doors.currentContact
I tried using “$doorState[1]” but that doesn’t work…I just get (open, closed,…)[1].
Is there a way?
Thanks.


(Mike Penda) #2

Figured it out. Loop through the multiple door contact item using “allDoors.eachWithIndex” and get each switch.
I just thought I’d update this in case another newbie like me is looking.