How To: Driveway Swing Gate Automation (Shelly 1 + BFT) - Working Perfectly with states!
New Home Assistant user & first time poster. I’m posting this hoping to help anyone looking to set up an automated smart driveway gate. It also helps remind me if I need to redo something!
All you need is your gate & motor, access to the control board, and a Shelly 1. No need for a reed switch or to solder an existing remote. Firstly, thanks to the many others who have posted the guides, tips and tricks I’ve used to get this up and running.
Background: a couple of weeks ago I got sick of not knowing if our garage door and driveway gate were open or closed when out and about, and sick of the useless (slow, flaky, can’t add other users) implementation of BFT’s U-control App to control the driveway gate. It’s also helpful to open and close the gate remotely for tradesmen, and to know if the gate is open when we’re away. All the standard good stuff.
Anyway, after a bit of reading here and on other sites, and watching a few Youtube vids, I installed Home Assistant on a spare Pi 3B+ and wired the Shelly 1 and a reed switch into our garage door. Worked great!
Inspired, I then reinstalled Home Assistant on an NUC in a virtualbox. Even better than the Pi (faster, easier to backup the virtual disc than a microSD card). So far so good.
Further inspired, it was time to tackle the driveway gate. There are a few scattered tutorials here and elsewhere, but fewer for gates than for garages. Perhaps more folks have garage doors compared to driveway gates?
Anyway the gear is:
- Gate motor: BFT Kustos Ultra BT A40 (Swing gates motors and kit - Kustos ultra BT A | Bft)
- Gate control and power board: BFT Thalia (THALIA)
- Shelly 1 (powered from 12V in my case, but your board should also have 24V or 110/240V)
Wire your Shelly’s power terminals directly onto your gate control board’s power. Most have a 24V DC auxiliary output. I initially used a 240V feed, since something was wrong with my board’s voltage. I subsequently wired in a spare 12V DC adapter to the board’s 240V feed … either way - get that Shelly powered up!
Using the Shelly app, integrate your new Shelly into your wifi and LAN. I kept mine on stock firmware rather than tasmota, and am using mqtt. I named the Shelly “Shelly-BFT” as a custom mqtt prefix using the Shelly’s on-board config page.
You’ll also need to set the Shelly as a “detached switch”, power on default mode “Off”, Timer: “Auto Off” after 0.5 seconds, and in the Shelly App, set Input State to “Add input state identifier to the power button”.
(Turn off the power). Wire the ‘0’ and ‘I’ terminals of the Shelly to the two terminals on your gate’s control board which are able to send a “start” command. In the Thalia’s case this is terminals #60 (COM) and #61 (IC 1). On the Thalia, the IC 1 can be user configured. I set mine to “Start I”, which closes the contact momentarily (0.5sec) and starts the motor.
Finally, wire the ‘SW’ input of the Shelly to the terminal #26 of the Thalia (AUX output N.O) and terminal #27 to the L(-). You can also use terminals #20 and #21.
(turn power back on). Using the Thalia’s controls, set terminals #26 and 27 (or #20 and 21 if you used those) to “Aux logic= 1 - SCA GATE OPEN LIGHT output”. This setting keeps the contact closed during gate opening and with the leaf open, intermittent during closing, and contact is open with leaf closed. In other words - it will tell you when the gate is open, closing and closed!
To get the switch to register in HA (via mqtt), use the following in configuration.yaml:
# Driveway Gate - platform: mqtt name: "BFT-Gate" command_topic: "shellies/Shelly-BFT/relay/0/command" state_topic: "shellies/Shelly-BFT/input/0" qos: 1 retain: false payload_open: "on" payload_close: "on" payload_stop: "on" state_open: "1" state_closed: "0"
- Add this to your customize.yaml file:
cover.bft_gate: device_class: gate
You can then add the entity “cover.bft_gate” to your dashboard:
To get a nice coloured switch, which opens the gate and holds it open (depending on the Logic you have your gate set to) and which changes to a red open-gate icon when the gate is open, and flashes open and closed as the gate closes (just like an alarm closing light would), use the following (with custom-button addon installed from HACS):
type: custom:button-card entity: cover.bft_gate name: Open Gate and Hold icon: mdi:gate styles: card: - height: 150px show_state: true show_name: true show_icon: true tap_action: action: call-service service: automation.trigger service_data: entity_id: automation.open_gate_and_hold state: - value: closed color: rgb(72,116,156) #sets the colour to the default Lovelace navy blue icon: mdi:gate - value: open color: red icon: mdi:gate-open
- Finally, you can set up a trigger for an automation to open the gate as you’re returning home, using a standard automation and trigger call with your cell phone(s’) location.