REST service for a Raspberry Pi Zero operating an FAAC-E124 gate control unit.
The goal of this project is to control an entry gate with an Apple device (e.g. iPhone or Apple Watch). More specifically the gate is represented as a HomeKit accessory and controlled with Siri or the Home app.
HomeKit requires a home hub (e.g. an Apple TV) to be installed on the local network. The home hub connects to Apple servers and allows the Home app to control HomeKit accessories even from outside the local network.
Currently, few accessories natively support HomeKit.
The Homebridge project allows integration of smart home devices
that do not natively support HomeKit. The software can be installed on a
Raspberry Pi
that is placed into the local network.
Homebridge registers with the home hub and exposes accessories to HomeKit through installable plugins.
It is configured through a web interface under http://ip_address_of_homebridge:8581.
For the gate in this project to be exposed as HomeKit accessory the
homebridge-http-webhooks plugin
needs to be installed. The
HttpWebHooks.json file
gives an example on how to configure the plugin.
Note that Basic Auth is used to secure the communication
between the gate hardware and Homebridge. The Basic Auth header string can be generated by
selecting a user/password combination and by replacing my_user and my_password in the following command.
The string xxxxxxxxxxxxxxxxxxxxxxxxxx== in the plugin configuration needs to be replaced
by the outcome of this command.
echo -n my_user:my_password | base64
Also note that ip_address_of_pi_zero needs to be replaced with the ip address
of the Raspberry Pi Zero WH mentioned below.
The components of the system are shown in the following diagram.
The hardware that is used to control the entrance gate is a FAAC-E124 Control Unit.
Since the E124 does not provide any way to interface with the Homebridge it is extended with the following hardware components:
These components need to be connected according to the following circuit diagram:

Please refer to the FAAC-E124 manual for details on the control unit. Chapter 5 of the document explains how to program the device. The following values need to be configured:
LO = E or EP
o1 = 05
o2 = 06
Setting LO to either E or EP configures the input IN 1 to operate the gate semi-automatically:
A first impulse on the input will open the gate. A second one will close it.
Configuring o1 to 05 activates output OUT 1 in OPEN or PAUSE state of the gate.
Setting o2 to 06 activates output OUT 2 in CLOSED state.
Please see the Getting started instructions for setting up the Raspberry Pi Zero WH. It is mandatory to configure the Pi Zero for remote access in the local network via SSH.
As a next step the gatecontrol web service must be installed on the Pi Zero.
This services operate the gate hardware and interfaces with the homebridge-http-webhooks plugin.
Copy the whole gatecontrol directory into the folder /home/pi on the device.
scp -r gatecontrol pi@ip_address_of_pi_zero:
Make sure python3 and all required modules are installed:
sudo apt update
sudo apt install python3
sudo pip3 install -r /home/pi/gatecontrol/requirements.txt
Adjust the file gatecontrol.service
to your needs and copy it into the folder /lib/systemd/system on the Pi Zero.
Configure it as a systemd service:
sudo systemctl daemon-reload
sudo systemctl enable gatecontrol.service
sudo systemctl start gatecontrol.service
The following environment variables can be set to configure the service.
If a variable is not defined the value in brackets is used as default.
The basic authentication is activated if both BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD are provided.
HOST(0.0.0.0): The host interface where this service is runningPORT(8000): The port the service is listeningBASIC_AUTH_USERNAME: The username that must be passed to the service in a basic auth headerBASIC_AUTH_PASSWORD: The password that must be passed to the service in a basic auth headerWEBHOOK_URL(http://localhost:51828): The URL of the homebridge running the Homebridge Webhooks pluginACCESSORY_ID(gatecontrol): The accessory ID as configured as gate in the Homebridge Webhooks plugin
The service utilizes the FastAPI framework.
It generates an OpenAPI under the URL http://HOST:PORT/docs e.g. http://ip_address_of_pi_zero:8000/docs.
- FAAC-E145-Gate-Connect - A similar project specifically for the FAAC E145 board.
