Unstated is that there’s a door sensor in the mix here that provides the actual status, correct? You’re then using the switch both to mimic the door state and control the door.
Group “Switch State Control” - NUL
- Group “Door open” – AND – sustained 30 seconds
- Door sensor says door is open
- Switch status is OFF
- Group “Door closed” – AND – sustained 30 seconds
- Door sensor says door is closed
- Switch status is ON
Activity “Door Open is True”: Set switch to ON
Activity “Door Closed is True”: Set switch to OFF
So basically, if the sensor and the switch disagree for 30 seconds, the switch gets set to whatever the sensor thinks the door state is. The delay may seem odd, but remember that the closure of the door isn’t instantaneous–it takes time to go from one state to another, and then for whatever sensing to relay home the new state of the door.
Then the switch actions:
Group “Door Control” – NUL
- Group “Switch On” – AND
- Group “Switch Off” – AND
Activity: “Switch On is TRUE”: command door to open
Activity: “Switch Off is TRUE”: command door to close
You could also do this with sequences, but you’d still have to be careful about the timing of door movement, since, again, opening and closing isn’t instantaneous, and “open” and “closed” aren’t really that–they’re probably actually “closed and not in motion” and “not closed and possibly in motion either direction”.
You also need to allow time for the sensors to respond.