Smart Garage – Impulse-Based Garage Door Integration with Ventilation Control

Smart Garage – Impulse-Based Garage Door Integration with Ventilation Control

Hey everyone! :waving_hand:

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.

Open in HACS

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

:door: 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

:wind_face: 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

:cloud_with_rain: Rain Auto-Close (optional)

  • Closes the door when rain is detected
  • Configurable delay (won’t close a just-opened door)
  • Push notification before closing

:shield: 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

:bar_chart: 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

:globe_showing_europe_africa: 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) :white_check_mark: Required
Limit switch bottom :star: Recommended
Limit switch top :star: Recommended
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)

Open in HACS

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:

  1. Basic: Name, control switch, pulse timing
  2. Sensors: Limit switches, vibration sensor, external button (all optional)
  3. Safety: Accidental-open protection settings
  4. Ventilation: Enable/disable
  5. 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 :white_check_mark:, HACS Validation :white_check_mark:, CodeQL :white_check_mark:, Ruff Lint :white_check_mark:
  • Quality Scale: targeting Silver tier
  • ConfigEntryNotReady, HomeAssistantError, available property, PARALLEL_UPDATES, diagnostics
  • Bilingual README (English + German)
  • YAML-based issue templates with diagnostics upload field

Links


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! :folded_hands:

Tags: garage-door, impulse, homematic-ip, ventilation, humidity, custom-integration, hacs

1 Like

Just FYI: you don’t. The template cover does that for you.

Thanks for the hint! You’re right that a template cover handles basic open/close/stop. The main reason this exists as a dedicated integration is what goes beyond that: pulse counting with limit switch sync (the same toggle cycles through 4 states, so “close” might need 1 or 3 pulses depending on position), state persistence across restarts, command serialization for RF relays that miss rapid pulses, and especially the built-in humidity-based ventilation control with rain auto-close — which would be a pretty complex set of automations to maintain otherwise.