Smart Gate Controller

Introduction

Welcome to the Gate Controller user manual. The Gate Controller is powered by a Sonoff SV device and utilisesESPHome for seamless integration with Home Assistant. This flexible setup allows users to tailor the configuration to their specific requirements. For instance, users can employ ESPHome API or MQTT to establish integration with Home Assistant.

 

 

Important Note:

Please exercise caution when performing updates on the Sonoff SV. Incorrect updates may disrupt the Over-The-Air (OTA) functionality. While this does not permanently damage the unit, rectifying faulty updates will require the use of an FTDI adapter.

 

 

Getting Started

Your Gate Controller comes pre-installed with a basic configuration, which allows you to connect to your Wi-Fi networkusing the Captive Portal. While it’s possible to use the device for direct integration with Home Assistant at this stage, we recommend updating it with custom settings to better suit your configuration, and for added security.

 

 

Initial Setup

Hardware Connections

Before powering up the unit (or connecting the 12V Power), ensure that you made all the necessary hardware connections. Also make sure the unit is isolated from touching any components within the Centurion Gate motor enclosure.

(Connect these first)

 

●              Pin 1: Status - WHITE - Connect to “Status” on D5.

●              Pin 2: Ped - BLUE - Connect to “Ped” on D5. (Optional)

●              Pin 3: Trig - YELLOW - Connect to “Trg” on D5 (This can be connected together with traditional remote receiver)

 

 

Power Supply Connections:

(Connect these last)

 

●              GND - BLACK: Connected to “COM” on D5

●              12V - RED: Connected to “AUX 12V OUT” on D5

 

 

 

Once the unit is properly connected and powered up, proceed to the next step: connecting the unit to your Wi-Fi network.

 

Connecting the unit to WiFi

1.     Using a Laptop or SmartPhone, search for the WiFi Access point “Sonoff-Gate”.

2.     Enter Password: ‘password’

3.     Once connected, using a browser navigate to 192.168.4.1 or http://sonoff-gatecontroller.local

4.     This will lead you to a configuration page where you can select the SSID of your Wi-Fi Access Point, as well as enter your WiFi Password. Once configured, the device will connect to your Wi-Fi network and be assigned an IP Address.

1.     To verify the successful connection, you can access the newly assigned IP address (typically found on therouter’s DHCP page) using a laptop or smartphone connected to the same Wi-Fi network.

 

Troubleshooting

In the rare event that the configuration is incorrect, and the device cannot connect to the configured Access Point, it will automatically advertise the “Sonoff-Gate” access point after 1-2 minutes.

 

By navigating to the newly assigned IP Address “http://new_ip_address” or “http://sonoff-gatecontroller.local”,you will be presented with the following screen:

 

 

This screen will be used to upload the new custom firmware, facilitating the connection to ESPHome in later steps.

 

Installing ESPHome on Home Assistant:

(If ESPHome has been installed already, this step can be skipped)

 

On Home Assistant, navigate to Settings | Add-Ons.

From the Add-On Store, select ESPHome and click install to install it.

 

Once installed, be sure to start the plugin and select the “Show in sidebar” to get the ESPHome icon on the left in the sidebar:

 

 

ESPHome can be accessed by clicking on

 

 

If this is your first device, it will also prompt you to provide the WiFi Credentials that the device should connect to. It will automatically save that to the ‘secrets’ file.

 

Here you can give a Custom name to your new device. Next you will be prompted to connect to the device. Since we will NOT be connecting directly to the device at this stage, you can click “SKIP THIS STEP”:

 

 

One the next screen, be sure to select “ESP8266”:

 

 

The next screen will give you an encryption key. You should copy this for later use. It needs to be used when you update the ‘custom’ configuration to the device. The next step to “INSTALL” can however be skipped as we will do this later.

 

 

Your newly created device will appear on the Dashboard (based on the name that was used in the 1st step):

 

 

In the next step you will be configuring the code for your respective device as well as the environment (Wifi AP, IPAddress, etc). We will then install the new Firmware on the device.

 

You can copy the latest version of the code from: https://github.com/HomeAutomationsXYZ/GateControl/blob/main/Configs.yaml

 

Please be sure to update all the required [VARIABLES] in the file with your own configuration. Some variables, like the WiFi Credentials will be saved in the SECRETs file, which can be accessed by clicking on the top right of the ESPHomemain screen. This is an easy and secure way to store certain credentials that will be re-used for various devices:

 

 

Now you can click on the “EDIT” button to get to the code editor:

 

 

Key Settings to Update

 

To fully customise your Gate Controller experience, consider updating the following settings:

 

1.     Static IP Address: Configuring a static IP address makes future updates via ESPHome on Home Assistantmore convenient. (This can be done via your router or ESPHome Configuration)

2.     Removing the Captive Portal: Given that this device controls access to your property via your gate, having the Captive Portal capability can pose a security risk. In the event of a Wi-Fi connection loss, it will “advertise” its own access point, potentially allowing unauthorised users to connect. An alternative is to add at least a strong WebServer password (https://esphome.io/components/web_server.html) that will prevent users from triggering the gate.

3.     Custom Names: Personalise your setup with custom names that align with your preference or naming scheme.

4.     MQTT and/or HA API: Enable MQTT or update the Home Assistant API keys to align the device with your specific configuration needs.

5.     OTA Password: For ease of setup, there is no OTA Password configured. Please add an OTA Password toensure that only you can perform updates “Over-The-Air”.

This code can be replaced by copying and pasting the provided code from GitHub. Please make sure that you configure at least:

●              Wifi SSID

●              Wifi Password

●              MQTT Section (If required)

●              OTA Password (For more secure OTA capability)

●              API Encryption Key (For added security)

 

(For now, it may be a good idea to keep the Captive Portal, in case some of the Wifi Configuration turns out to beincorrect). For additional security you should add the Web Server authentication.

 

Click “Manual Download” to download the firmware file to your computer.

 

Once it’s downloaded, navigate to the IP Address of the gate controller using a web browser: (http://[ip_on_your_network] OR http://sonoff-gatecontroller.local )

 

Under OTA Update, select “Choose File” and browse to the binary file that was downloaded in the previous step. Click Update to update to the latest firmware. The progress will be shown on the right:

 

An “Update Successful!” message will be displayed once the update is complete. The device will restart once the update is complete to ensure that the latest firmware is loaded.

 

From here on, the device can be managed from ESPHome in the Home Assistant application. Any future updatesshould be possible by selecting the ‘Wirelessly” option when updating the firmware.

 

 

Integrating device into Home Assistant

When the device is on and configured as per the previous steps, it should appear under “Settings | Devices & Services” as a newly Discovered Device:

 

Here you can click “Configure” and will be presented with:

 

The remaining steps is to add the device to your dashboard and/or configure automations based on the device status.

 

 

 

Disclaimer:

●    Make use of a gate “Safety Beam” when remotely closing the gate.

●    Ensure the unit is isolated from touching any electrical or metal mechanical items.

●    Ensure the gate motor is within WiFi reach of the Access Point.

●    Be sure to add an OTA Password and Encryption Key for security purposes.

●    Be sure to add Authorization to the WebServer component if you keep that.

 

 

References

●    Github Repository for code: https://github.com/HomeAutomationsXYZ/GateControl

●    ESPHome Captive Portal: https://esphome.io/components/captive_portal