Combining multiple door sensors


1) Give a description of the problem
I have a few doors that have recessed door sensors and I’d like to marry them to their appropriate light switches. I was hoping I could combine them into one piston instead of having to make one piston for each door. Just for simplicity sake.

I’m able to make a single piston linking a door to a sensor, but I’m not sure how to combine them? Unless it’s better to make them all independent?

2) What is the expected behaviour?
Opening a door turns on a light and closing the door turns off the light. These are doors like the electrical panel closet, the utility room, the pantry etc. Doors that I would probably never close and still need the light to be on.

3) What is happening/not happening?
I really don’t know what I’m doing. :smiley:

**4) Post a Green Snapshot of the piston![image|45x37]
Here is a single door piston I made that appears to be working.

5) Attach logs after turning logging level to Full


You will need to create two lists with your devices. You will need to create them using an expression rather than selecting them in order to ensure they are in corresponding order (unless you naming convention just works out OK). Then look for contact changes and save corresponding device into a new variable. Using indexof and arrayitem you can get to the corresponding dimmer to turn it on. Hope this makes sense. I can try to create a sample for you later when I have time.


That would be great if you have some free time. I appreciate the help. What you said might have well have been Latin. :smiley:


Try this. To set your list of sensors/lights, just edit the expression. As soon as you type ‘[’ you will get a list of all your devices. Just make sure to put the sensor list and light list in the same order.

I tested this and it worked for my short list.


I’d say leave them separate.


My two cents? Combining them will actually make the logic more complex, and the possibilities more limiting.

The reason I say this is each time any of the triggers happens, the entire code runs top to bottom… Executing anything allowed by conditions.