Smart Garage – Impulse-Based Garage Door Integration with Ventilation Control
Hey everyone! ![]()
I’d like to share my custom integration Smart Garage for controlling impulse-based garage doors — the kind where a single relay press cycles through Open → Stop → Close → Stop → Open.
If you’ve ever tried to automate this type of garage door in Home Assistant, you know the challenge: there’s no separate “open” and “close” command — just a single toggle impulse, and you need to keep track of where the door actually is. That’s exactly what this integration solves.
GitHub: thokoh74-DE/smart-garage
The Problem
Most impulse-based garage door motors (Hörmann, Marantec, Chamberlain, Sommer, Novoferm, etc.) work with a simple toggle mechanism: one press opens, next press stops, next press closes, next press stops, and so on. There’s no way to send a dedicated “close” command — you have to know the current state and count the pulses.
Using a simple switch.toggle automation breaks as soon as someone presses the physical wall button, the state gets out of sync after a restart, or you try to reverse direction mid-travel and the pulse count gets confused.
The Solution: Pulse-Counting State Machine
Smart Garage uses a pulse-counting state machine that:
- Tracks a sync state (last confirmed position from a limit switch) and a pulse counter
- Derives the current door state from
sync_state + (pulse_count mod 4) - Resets the counter to 0 whenever a limit switch confirms fully closed or fully open
- Persists state across HA restarts via
RestoreEntity - Handles direction reversal automatically (e.g. Open → Stop → Open sends 3 pulses: Close → Stop → Open)
- Enforces a configurable minimum inter-pulse gap to prevent RF relays from missing pulses
- Serializes commands so rapid clicking (Open → Stop → Open) never sends overlapping pulses
Features
Cover Entity
- Full cover control: open, close, stop, set_position
- Live position estimation during movement
- Accurate state even after HA restarts or physical button presses
Humidity-Based Ventilation Control (optional)
This was my main motivation for building the integration: my garage gets damp, and I wanted it to automatically ventilate when conditions are right.
- Calculates absolute humidity and dew point from indoor/outdoor temperature + humidity sensors
- Automatically opens the door to a small ventilation gap (configurable, e.g. 2s ≈ 10 cm)
- Only ventilates when:
- Indoor absolute humidity exceeds outdoor by a configurable threshold
- Someone is home (presence entity)
- Sun is up (between sunrise and sunset)
- It’s not raining
- Manual ventilation switch for direct control
- Closes automatically when conditions change
Rain Auto-Close (optional)
- Closes the door when rain is detected
- Configurable delay (won’t close a just-opened door)
- Push notification before closing
Safety
- Accidental opening protection: if the door is in ventilation position and somehow opens fully (e.g. mechanical issue), it detects this and auto-closes with notification
- This only triggers for automatic/manual ventilation — never for an explicit open command from the UI or physical button
Diagnostics
- Pulse count sensor (resets to 0 on limit switch sync — great for debugging)
- Mirror sensors for limit switches, vibration sensor, control switch
- Current state with position percentage
- Full diagnostics dump downloadable from the device page
Multilingual
- Full German + English translations
- Entity IDs always use English suffixes
- Display names follow your HA system language
Hardware
I built this for Homematic IP hardware, but it works with any impulse-based setup:
| Device | Purpose |
|---|---|
| HmIP-PCBS | Switching actuator (relay) — sends the impulse |
| HmIP-FCI6 | Contact interface — ch1 = limit switch bottom, ch2 = limit switch top |
| HmIP-STV | Tilt/vibration sensor — detects door movement |
Any other hardware combination works too, as long as you have a Home Assistant switch or button entity that triggers your motor.
Requirements
| Component | Required? |
|---|---|
| Switch or button entity (relay) | |
| Limit switch bottom | |
| Limit switch top | |
| Vibration sensor | Optional |
| Temp + humidity sensors (indoor + outdoor) | Optional (for ventilation) |
| Rain sensor | Optional (for rain auto-close) |
| Presence entity | Optional |
The integration degrades gracefully: without climate sensors → no ventilation entities are created. Without rain sensor → no rain auto-close. It works with just a control switch.
Installation
HACS (recommended)
Or manually: HACS → Integrations → ⋮ → Custom repositories → add https://github.com/thokoh74-DE/smart-garage as Integration.
Manual
Copy custom_components/smart_garage/ to your HA config/custom_components/ folder and restart.
Setup
The integration has a 5-step config flow that guides you through everything:
- Basic: Name, control switch, pulse timing
- Sensors: Limit switches, vibration sensor, external button (all optional)
- Safety: Accidental-open protection settings
- Ventilation: Enable/disable
- Climate: Temperature/humidity sensors, rain sensor, thresholds (all optional)
After setup, there’s a menu-based options flow with 4 independent sections — edit only what you need without clicking through everything.
Every setting has an inline description explaining what it does, so you don’t need to constantly refer to the documentation.
How the Ventilation Logic Works
This is the part I’m most proud of. The integration doesn’t just look at relative humidity — it calculates absolute humidity (actual grams of water per cubic meter of air), because that’s what matters for effective ventilation.
Example: Your garage is at 22°C / 65% relative humidity = 12.6 g/m³ absolute. Outside it’s 18°C / 72% = 11.3 g/m³. Even though the outdoor percentage is higher, the outdoor air actually contains less water. Opening the door removes moisture from the garage.
The integration checks every 15 minutes (configurable) and only opens the ventilation gap when:
- AH difference exceeds your threshold (default: 5 g/m³)
- Indoor relative humidity is above your threshold (default: 55%)
- Someone is home, sun is up, no rain
Quality
- All GitHub Actions green: Hassfest
, HACS Validation
, CodeQL
, Ruff Lint 
- Quality Scale: targeting Silver tier
ConfigEntryNotReady,HomeAssistantError,availableproperty,PARALLEL_UPDATES, diagnostics- Bilingual README (English + German)
- YAML-based issue templates with diagnostics upload field
Links
- GitHub: GitHub - thokoh74-DE/smart-garage: A Home Assistant custom integration for **impulse-based garage doors** – the kind where a single relay press cycles through *Open → Stop → Close → Stop → Open*. Designed for **Homematic IP** hardware (HmIP-PCBS, HmIP-FCI6, HmIP-STV) but works with any impulse-driven garage door motor. · GitHub
- Documentation (EN): smart-garage/README.md at main · thokoh74-DE/smart-garage · GitHub
- Dokumentation (DE): smart-garage/README_DE.md at main · thokoh74-DE/smart-garage · GitHub
- Changelog: smart-garage/CHANGELOG.md at main · thokoh74-DE/smart-garage · GitHub
- Issues / Feature Requests: Issues · thokoh74-DE/smart-garage · GitHub
I’ve been using this daily on my own garage for a while now and it’s been working reliably. The trickiest part was getting the pulse timing right for Homematic IP hardware (they need ~1.5–2s between pulses or they miss signals), but that’s now configurable and well-tested.
Feedback, bug reports, and feature requests are very welcome — either here or on GitHub! ![]()
Tags: garage-door, impulse, homematic-ip, ventilation, humidity, custom-integration, hacs