Smart garage door with OpenHAB2

german

In one of the last articles, I already described why I would like to make my home smart. With this article I show you my second project. I’ll talk about the first one later.

As already mentioned, I would like to be able to use my phone to operate a few functions of the garage door. Here is a complete list of what I imagine:

  • see on the phone whether the gate is open or closed
  • open / close the gate with the mobile phone
  • save money for more remote controls
  • save money for batteries
  • sending a notification when nobody is in the house and the garage is open
  • maybe make sure that the gate opens when I come home by car

That’s all in all not a little and not even implemented quickly. In addition, for example, a Hörmann garage door drive requires an additional board ( called UAP1) to elicit the door, whether it is open or closed. Even directed commands such as opening and closing, can only be implemented with this board. Since I do not want to buy them at the moment, I limit myself to the functions that can be implemented without it. Maybe an article on the missing functions will follow later.

The first and essential thing I need is to be able to open and close the gate. But for security reasons, you have to see the gate when you operate it. Therefore, a camera is required to see the gate on a smartphone when you control it.

This is the plan for the first project. Now it’s time to choose the components. Since in the final stage of development a UAP1 from Hörmann is to be used to give directional commands (open, close, stop) at least three relays are required. In addition, a WLAN camera.

These are some components and if everything is to be able to run individually over WLAN, it is to consider whether it is not cheaper to use a Raspberry Pi.

I decided to use a Raspberry Pi Zero W and matching relays in this case. However, since I found no camera software for a Raspberry Pi in a first research, which a few functions more than just a stream to transfer, I have installed the Camera App Ip webcam on a discarded smartphone. This provides an HTTP interface with a lot of camera settings to use. Among other things, this provides the ability to turn the light on and off, which proves to be very useful when it’s dark.

Let’s start with the implementation. Let´s start to control the drive. How I wired the whole system I show you here in a small video. !!!Attention when connecting the drive to the relay. Here are 230V. Be sure to disconnect beforehand!!!

Control garage door drive

First of all, we need a way to control the GPIOs of the Raspberry Pi, which are conntected to the relays. Since this is still to connect via network to the hub, I’ve been looking for a software that can do both. Here my first choice fell on WebIoPi, which I already used successfully on a Raspberry Pi 3B. Unfortunately it did not run on the Raspberry Pi Zero W. So I searched for an alternative and found it in express-gpio-rest-api by Juan Gesino. This also offers the possibility to activate a pin for a specified time, which is necessary for the control of the drive, as it simulates the manual operation of a wall button.

How to install this software you can read on the page express-gpio-rest-api by Juan Gesino. Then configure the whole thing as a service. For this I created the file /etc/systemd/system/expressserver.service with the following content.

[Unit]
Description=node application on expressserver to provide gpio rest api
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=centos
ExecStart=node /home/pi/express-gpio-rest-api/app.js

[Install]
WantedBy=multi-user.target

Then activate the service with:

systemctl enable expressserver

And then start with

systemctl start expressserver

After that, you should be able to send commands to the Raspberry Pi.

As described in the video pin 11 is connected to the relay. Therefore, we have to set up an item which can activate the relay for a short moment and then deactivate it again. For this I created the file /etc/openhab2/items/garage.items and added the following entry.

Switch MoveGarage { http=">[ON:GET:http://192.168.2.112:3000/blink/11/5]" }

To make sure that the line is entered correctly, you should check /var/log/openhab.log if everything is ok.

Last but not least, in the HABPannel you have to create a button that activates the created item MoveGarage and always sends the command ON. As can be seen here, the following URL is called via GET request: http://192.168.2.112:3000/blink/11/5

ButtonMoveGarage

Add the camera

As already mentioned, I have installed an app to have a camera, which provides a stream. To integrate this, I created a frame in HABPannel, and entered the stream.

FrameVideoStream

Control the light

To control the light of the camera app you can use the path /enabletorch and /disabletorch to switch the light on or off.

For this you have to create an item again, which I configured in the file
/etc/openhab2/items/garage-cam.items.

Switch Camera_light { http=">[ON:GET:http://192.168.2.20:8080/enabletorch] >[OFF:GET:http://192.168.2.20:8080/disabletorch]" }

I then integrated this item into the HABPannel. This requires a switch (switch)

SwitchLight

Conclusion

Everything is easy to set up, only controlling the garage door drive was a bit more complex. The interface can also be configured nicely and looks good.

Now that we have archived this state, we can strike out some of our requirements:

  • see on the phone whether the gate is open or closed
    • by camera
    • by status
  • open / close the gate with the mobile phone
  • save money for more remote controls
  • save money for batteries
  • sending a notification when nobody is in the house and the garage is open
  • maybe make sure that the gate opens when I come home by car

As I mentioned, I plan to integrate a Hörmann UAP1 later on. Therefore you just need some relays more(one per Possible command). Also some Items to configured and used in the panel. Hopefully I can demonstrate this later.

Leave a comment