I built a full-featured ESPHome gate controller with an FSM — sharing the project
Hey all,
After a lot of iteration I’ve open-sourced my ESPHome gate controller and wanted to share it here. It started as a simple gate project but grew into something much more.
Most ESPHome gate setups I came across are relay toggles that trigger an existing commercial controller. Mine is different — it directly drives an H-bridge motor IBT-02 and handles all the control logic itself. The core is a finite state machine (11 states) that manages the full cycle: opening, closing, auto-close countdowns, obstacle handling, and fault recovery.
The FSM is built on the excellent esphome-state-machine external component by Mikhail Diatchenko (@muxa). It’s what makes this whole thing possible in pure YAML with no custom C++. Big thanks to Mikhail for creating it, if you haven’t seen it, it’s a great component for any project that needs proper state management.
Some highlights:
- Soft start/stop PWM ramping (less mechanical stress)
- Auto-close with configurable countdown
- Current-based obstacle detection via INA260 (reverses automatically)
- Time-based position tracking that learns your gate’s travel time, and adjusts for a changing battery voltage
- Position control through the HA cover slider
- Jog buttons (hold-to-operate, dead man’s switch) for setup
- 5-layer endstop overrun safety system
- Full physical control panel (MCP23017) — works without HA
Runs on an ESP32 with everything in YAML. Uses the muxa/esphome-state-machine external component for the FSM.
Needed components ESP32, MCP23017, INA260, IBT_02 (or any H-bridge really)
README has wiring, setup, all HA entities, and troubleshooting. MIT licensed.
Would love to hear from anyone doing similar projects or if you find it useful. Feedback and PRs welcome!