The Driveway Gate in Home Assistant: Control, Reed Sensors, Open-State, and Safety
The Driveway Gate in Home Assistant: Control, Reed Sensors, Open-State, and Safety
With a gate, state matters more than an "Open" button. Get a trustworthy position sensor and alerts working first, then add a local pulse with dashboard confirmation. This is the first of three high-risk zones in this module: the gate, the pedestrian gate (L6), and the garage (L7) all share the same dry-contact rules and the same need for a separate safety input.
Dry contact: no 120/240V into the gate controller
You wire the relay in as a dry contact, following the operator's own schematic. Never feed line voltage into a gate controller's control input. The electrical work is done by the gate installer or a licensed electrician: this course teaches HA logic, not soldering near the motor.
Budget around 90 minutes. Example entities: binary_sensor.driveway_gate_closed, switch.driveway_gate_pulse with local auto-off. Adjust the entity IDs to match your own install. From here on I'll shorten Home Assistant to HA.
The core rule of this module
Outdoors, automation has to be more resilient than it is indoors.
Read and diagnose state first.
Then manual control and a Plan B.
Only then automation.
A Problem from Real Life: The Gate Is Open, and HA Thinks It's Closed
The app shows the gate as "closed," but it's actually been standing open for an hour: the operator stalled halfway, and the reed sensor never sees the end position. You wired a relay into a controller input you don't fully understand: the gate starts cycling on and off in the wrong rhythm.
A driveway camera shows a picture, but it doesn't replace a reed sensor: nighttime, rain, and camera angle can all mislead you. Device state has to come from a dedicated sensor. When you see unknown or unavailable, don't guess: treat it as "I don't know" and don't send a pulse blind.
One Reed Sensor: What You Actually Know
One reed sensor confirms one end position
A reed sensor at the closed position only confirms the gate is exactly at that position. Once the magnet moves away from the sensor, you know the gate isn't fully closed: you don't yet know whether it's opening, partway open, or stalled halfway. Name the entity for what it actually measures: binary_sensor.driveway_gate_closed, not "open."
| Closed sensor | Open sensor | Interpretation |
|---|---|---|
| active | inactive | fully closed |
| inactive | active | fully open |
| inactive | inactive | an intermediate position, or in motion |
| active | active | an installation or wiring fault |
Pulse, Dry Contact, and Step Inputs
A gate controller has a pulse input, just like a button on a remote. Step-by-step inputs are common, where successive pulses cycle through: open, stop, close, stop. Another controller has separate OPEN and CLOSE inputs. Before you build a button in HA, check your controller's manual: the input's name, what a single pulse means, the required contact-closure time, and whether separate OPEN/CLOSE inputs exist.
A dry contact means the relay supplies no voltage of its own: it simply shorts the controller's own terminals, the same as a manufacturer-approved button would. Modules like the Shelly 1 Gen3 or Shelly Plus UNI work well here, wired through a relay output running in voltage-free mode: always following the specific operator's schematic.
Handle pulse duration locally, not with a delay in HA
Home Assistant could restart after turning the relay on but before the off command runs. A critical pulse shouldn't depend on a turn_on-delay-turn_off sequence inside HA. Configure a local momentary mode (auto-off, inching) on the module, and physically confirm the relay returns to inactive on its own, even if you kill the network mid-pulse.
Architecture: Four Layers
Layer 1, the gate operator: safe motion, photo-eyes, safety edges, input logic, manual release. Layer 2, the pulse module: local auto-off, a safe state after a restart. Layer 3, position sensors: at minimum, confirmation of the closed position. Layer 4, Home Assistant: shows state, raises alerts, lets you deliberately request a pulse: it never replaces physical safety devices.
Helpers and a Confirmed-Pulse Request Script
input_boolean:
remote_gate_control_enabled:
name: "Remote gate control enabled"
icon: mdi:gate-alert
initial: false
timer:
gate_pulse_lockout:
name: "Driveway gate pulse lockout"
duration: "00:00:10"
script:
driveway_gate_open_from_confirmed_closed:
alias: "Driveway gate: send pulse"
icon: mdi:gate-open
mode: single
sequence:
- condition: state
entity_id: input_boolean.remote_gate_control_enabled
state: "on"
- condition: state
entity_id: binary_sensor.driveway_gate_closed
state: "on"
- condition: state
entity_id: timer.gate_pulse_lockout
state: "idle"
- action: switch.turn_on
target:
entity_id: switch.driveway_gate_pulse
- action: timer.start
target:
entity_id: timer.gate_pulse_lockout
- action: logbook.log
data:
name: "Driveway gate"
message: "Pulse request sent from Home Assistant."
- wait_for_trigger:
- trigger: state
entity_id: binary_sensor.driveway_gate_closed
from: "on"
to: "off"
timeout: "00:00:10"
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: "{{ wait.completed }}"
sequence:
- action: notify.mobile_app_your_phone
data:
title: "Driveway gate"
message: "Sensor confirmed it left the closed position."
default:
- action: notify.mobile_app_your_phone
data:
title: "Gate: no movement confirmed"
message: "A pulse was sent, but the sensor didn't confirm movement within 10 seconds. Check the gate."
The script doesn't confirm full opening or the absence of an obstacle: only that the closed sensor stopped being active. input_boolean.remote_gate_control_enabled is a software lockout, not authorization: anyone with access to Developer Tools can bypass it. For an extra tap-to-confirm safeguard, add confirmation on the dashboard card that calls the script, not on the helper's name.
Diagnostic Alerts, Kept Separate from Control
automation:
- alias: "Gate: no closed confirmation for 5 minutes"
id: gate_no_closed_confirmation_5_minutes
mode: single
triggers:
- trigger: state
entity_id: binary_sensor.driveway_gate_closed
to: "off"
for:
minutes: 5
conditions:
- condition: state
entity_id: input_boolean.outdoor_alerts_enabled
state: "on"
actions:
- action: notify.mobile_app_your_phone
data:
title: "Driveway gate"
message: "The gate has had no confirmed closed position for at least 5 minutes."
- alias: "Gate: position sensor unavailable"
id: gate_position_sensor_unavailable
mode: single
triggers:
- trigger: state
entity_id: binary_sensor.driveway_gate_closed
to:
- "unavailable"
- "unknown"
for:
minutes: 2
conditions:
- condition: state
entity_id: input_boolean.outdoor_alerts_enabled
state: "on"
actions:
- action: notify.mobile_app_your_phone
data:
title: "Gate: no trustworthy state"
message: "The closed-position sensor is unavailable. Remote control should be treated as unreliable."
These alerts use outdoor_alerts_enabled from Lesson 1, not a global automation kill switch: turning off remote control shouldn't silence a warning about a missing closed confirmation. The for: option doesn't survive an HA restart: the countdown resets to zero.
Geofencing and Cameras: What Not to Use as State
Phone geofencing can be helpful context for a notification or for surfacing a button: it shouldn't send a command to the gate on its own. GPS lags, the radius covers the whole street, and a background app isn't always alive. A camera can support an informed decision, but it doesn't confirm that photo-eyes or safety edges are actually working.
The Gate Card: A Document Outside of YAML
Fill out a card and keep it with your outdoor map: the operator's manufacturer, the input type (step-by-step or separate OPEN/CLOSE), the required pulse duration, how local auto-off works, the number of position sensors, your Plan B with no HA, no network, no power, and how to release the gate manually. Watch the gate's state for seven days with no pulses sent from HA. Only configure a local pulse on the module once the installer has signed off on the connection.
Gate Hardware: Shelly, Nice, and Somfy in Practice
Shelly Uni (12-36V DC power, voltage-free outputs) and the Shelly 1/2.5 are the modules most often chosen for wiring into a gate operator, precisely because they offer a dry-contact output that's safe for the controller's electronics. With Nice operators, the connection typically runs through the controller's Step-by-Step terminals, with the Shelly relay cycling in sequence: open, stop, close, stop. Somfy in practice integrates two ways: officially through the Overkiz integration (if you have a TaHoma gateway), or pragmatically through the same kind of Shelly relay wired the same way as with Nice.
Detached mode on Shelly
When you use a Shelly relay both as a sensor input (reading an existing button) and as output control at the same time, switch it into detached mode: this separates the input from the output, giving you a separate sensor entity and a separate switch entity instead of one merged one.
Gate Motors: Chain-Drive, Arm-Drive, and Underground
| Motor type | Characteristics | Smart home compatibility |
|---|---|---|
| Chain/rack drive (sliding gates) | typical for sliding gates, moderate cost | good, most have an output for an external controller |
| Arm drive (swing gates) | typical for double-swing gates, needs two motors | good, though it needs the two leaves synchronized |
| Underground | attractive, hidden below grade, costlier to service | limited, fewer models with an open API |
Mechanical Safety: Photo-Eyes and Safety Edges
Gate automation never replaces mechanical safety devices
Photo-eyes (infrared sensors that detect an obstruction in the gate's path) and safety edges (pressure sensors on the leading edge of the gate) are mandatory physical safeguards, independent of Home Assistant, that stop the gate on contact with an obstacle. The automation in this lesson layers on convenience and status information, but it should never be your only layer of safety: photo-eyes must keep working even when Home Assistant is offline.
Gate Position Encoders: More Precise Than a Reed Sensor Alone
A reed sensor, as described in the main content of this lesson, only tells you whether the gate is fully closed or not, with no information about an intermediate position. More advanced gate controllers (some Nice and Somfy models) have a built-in position encoder, reporting the exact percentage open, which enables more precise automations, like a partial opening for pedestrians only, without swinging the whole gate open for a car.
Integrating with License Plate Recognition (ANPR)
For more advanced installs, a camera with automatic license plate recognition (ANPR), integrated with Frigate or dedicated software, can automatically open the gate for recognized, trusted vehicles, removing the need for a remote or an app. This approach needs good image quality from a camera aimed directly at the plate, and carries a higher technical barrier to entry than the simple reed sensor in this lesson, so treat it as a natural next step, not a starting point.
Remote Gate Control from Outside Your Home Network: Remote-Access Security
Controlling the driveway gate from outside your home network, say, to let a delivery in while you're away, requires the secure remote access described in Module 7, but with extra caution: a gate is a physical entry point onto the property, so a compromised remote-access account carries far more serious consequences than, say, compromised light control. It's worth considering an extra safeguard on this specific function, like requiring two-factor authentication for remote gate opening, even if the rest of the system doesn't demand that level of rigor.
Gate Motor Service and Maintenance: What to Do Yourself, What to Hire Out
| Task | DIY or hire a pro |
|---|---|
| Lubricating rails and mechanisms | DIY, following the manufacturer's manual, usually once a year |
| Adjusting motor force and sensitivity | usually DIY, through the motor's control panel |
| Replacing the backup battery (if fitted) | DIY, a simple swap |
| Repairing the motor mechanism or controller electronics | hire a pro, for warranty and safety reasons |
A Mechanical Backup: Manual Release When the Motor Fails
Every automatic gate needs a manual release mechanism
No matter how reliable the automation seems, every motor-driven gate should have a physical, manual release mechanism (usually a key or a release cord) that lets you open the gate by hand during a power or motor failure. Learn the exact location and how to use this mechanism on your specific gate before you need it under stress, like a sudden failure on your way out to work.
How to Test This Lesson
1. Check your controller's manual: is the input step-by-step, or does it have separate OPEN/CLOSE?
2. Physically confirm the module's local auto-off, including after an HA restart.
3. Fill out the gate card before sending your first pulse from HA.
Common Mistakes
A single sensor named "open": the gate is mid-motion, and the dashboard simply reads "open."
Critical pulse timing through a delay in HA: a restart mid-wait leaves the relay stuck active.
Geofencing as the sole trigger: the gate opens with no deliberate human decision behind it.
Practical Task
☐ Fill out the gate card: manufacturer, input type, pulse duration, Plan B.
☐ Watch the gate's state for 7 days with no pulses sent from HA.
☐ Only after that, configure the local pulse and the confirmation script.
Key Takeaways
One reed sensor confirms only one position: don't guess the rest.
Handle pulse timing locally, not through a delay in HA.
HA never replaces photo-eyes, safety edges, or the gate operator's own controller.
What's Next
Next lesson: The Pedestrian Gate, Electric Strike, Doorbell, and Intercom: What to Integrate, and What Not to Oversimplify. Same dry-contact logic, but for a people-sized entrance, not a car-sized one.