Skip to content

REST service for a Raspberry Pi Zero operating an FAAC-E124 gate control unit

License

Notifications You must be signed in to change notification settings

owahlen/gatecontrol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gatecontrol

Build Status

REST service for a Raspberry Pi Zero operating an FAAC-E124 gate control unit.

Controlling a gate with Apple Hardware

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.

Homebridge configuration

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.

component diagram

Gate Hardware

The hardware that is used to control the entrance gate is a FAAC-E124 Control Unit.

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:

Circuit Diagram

These components need to be connected according to the following circuit diagram: Circuit Diagram

FAAC-E124 Control Unit Configuration

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.

Raspberry Pi Zero WH Configuration

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.

Install the gatecontrol web service

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

Start gatecontrol service at boot time

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

Environment Variables

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 running
  • PORT (8000): The port the service is listening
  • BASIC_AUTH_USERNAME: The username that must be passed to the service in a basic auth header
  • BASIC_AUTH_PASSWORD: The password that must be passed to the service in a basic auth header
  • WEBHOOK_URL (http://localhost:51828): The URL of the homebridge running the Homebridge Webhooks plugin
  • ACCESSORY_ID (gatecontrol): The accessory ID as configured as gate in the Homebridge Webhooks plugin

gatecontrol API Documentation

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.

Related Projects

About

REST service for a Raspberry Pi Zero operating an FAAC-E124 gate control unit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages