This implements a garage door or gate with one button, which works based on the following logic
- Door open > Press button > Door closes
- Door closed > Press button > Door opens
- Door stopped halfway when it was busy moving towards the open posistion > Press button > Door closes
- Door stopped halfway when it was busy moving towards the closed posistion > Press button > Door open
This configuration does the following
- Door open > Press close > Door closes
- Door closed > Press open > Door opens
- Door stopped halfway when opening > Press close > Door closes
- Door stopped halfway when closing > Press close > Door open > Open endstop makes it trigger again > Door closes
Assumptions
- No manual input (Other than throgh the ESP) will be done when the door is busy moving based on a command received from HA. (See TODO section)
TODO
- Add a safety mechanism (beam) to block comand from executing
- Implement a timeout - If the door is MANUALLY stopped mid-movement, it will assume the OPEN state.
- Allow manually reversing a command (By original remote/switch):
IMPORTANT: Most doors also reverses as a safety feature if something is blocking it from moving to the desired position
- Door is at endstop (Closed in this example)
- HA says move (Open door in this example)
- Door starts moving (Opening in this example)
- ESP detects door is no longer at endstop and sends status to HA (Open in this example)
- Manual/Safety intervention stops the door
- Manual/Safety intervention moves the door (Closing in this example)
- ESP stops all commands assuming manual/safety intervention occurred
- Send status to HA (Closed in this example)