Making My Fence Gate Smart with Zigbee and Home Assistant
After installing an aluminum fence to enclose our backyard for the dog, one thing became clear: I needed a way to know for sure if the gates were closed before letting him out. The fence has two double gates, and while they latch securely, I didn’t want to risk one being left open by accident.


So, I decided to make the gates smart.
The Goal
Track the open/closed state of each gate in Home Assistant, so I could:
- Check status at a glance.
- Automate alerts.
- Prevent opening the dog door if a gate is open.
The Hardware
I used Aqara Zigbee door/window sensors, which are:
- Reliable
- Battery-powered
- Zigbee-based (so they integrate seamlessly with my existing Zigbee network)
These sensors use a reed switch—they detect open or closed state based on a magnet’s proximity. Like most sensors of this type, they’re indoor-only—so I needed a way to keep them protected outdoors.
The Solution
Each aluminum gate post is hollow and capped, which gave me the perfect hiding spot for the sensor. Here's what I did:
- 3D printed a tray that fits snugly inside the post.
- Mounted the Aqara sensor to the tray.
- Used silicone sealant to secure the tray inside the post—weatherproof and clean.
- Then, I 3D printed a small magnet holder, mounted to the gate leaf, so that the magnet aligns perfectly with the sensor when the gate is closed.




The Result
Now, when the gate is closed, the sensor is triggered just like on a regular door. Home Assistant shows me the status of each gate, and I can create automations like:
- Notify me if a gate is open for too long.
- Flash the lights if the dog door is opened while a gate is open.
- Include gate status in my "Dog Ready" routine.

Conclusion
A simple Aqara sensor, a few 3D printed parts, and some creative thinking turned my basic fence gates into smart gates. It’s a small upgrade that adds a lot of peace of mind—especially when you’ve got a dog who loves a good escape mission.