Ditec VIVAH car gates, the Shelly Plus 1 and openHAB

And here comes my next home automation project: integrating our entrance gates, controlled by a Ditec VIVAH unit, to be able to operate them from our BTicino wall switches and mobile phones. To achieve that, we’ll use a Shelly Plus 1 to integrate the gates into our openHAB home automation server, which is already connected to the BTicino MyHome automation system. For mobile app we have the choice of using the openHAB apps or the Shelly apps, which we’ll both have a look at. And while I did not set that up yet, of course the gates could then be also controlled by other means provided by openHAB, such as the Alexa voice assistant or automated rules.

In addition to controlling the gates we also want to be able to see remotely if they are opened or closed. For this, we’ll use the Plus 1 to read the status of the VIVAH’s gate open indicator light, a neat solution that saves us from having to install a physical sensor.

In this post I’ll cover:

  • How to wire the Shelly Plus 1 into the Ditec VIVAH, and how to configure it for controlling the gates
  • The openHAB data model used
  • A custom openHAB widget for controlling the gates
  • Setting up the BTicino controls
  • A comparison of the openHAB and Shelly mobile apps for this particular use case

Let’s start with an overview of the planned solution. All elements are connected via our local network, including the Shelly Plus 1, which is wired to the VIVAH controller and hooks up wirelessly. To open or close the gates, BTicino controls send their commands to openHAB (1) via the OpenWebNet Binding, which forwards them to the VIVAH controller via the Shelly Plus 1 and the Shelly Binding (2). For controlling the gates remotely we can either use the openHAB app, which connects through the myopenhab.org cloud service (3), or the Shelly app, which also relies on their cloud service (4). 

UPDATE Nov 05, 2023: if you are interested in controlling the car gates from Apple HomeKit, check out my newer post on that topic.

As first step towards this solution, we’ll need to figure out how to wire the Shelly Plus 1 to the Ditec VIVAH.

Connecting the Shelly Plus 1 to the Ditec VIVAH

The Ditec VIVAH has a number of terminals that allow it to be controlled from external devices, which are well-documented in its installation manual. The first relevant terminal is the step-by-step circuit, which when closed activates the opening, stopping or closing of the gates, depending on their current status. The second is the one for powering the gate open indicator light, which we’ll misuse as sensor to determine whether the gates are opened or closed.

Since we have been using Shelly actuators already to wirelessly integrate a few other devices, it was a natural choice to have a look at the Shelly Plus 1, their go-to device for garage doors and entrance gates. And after some research, it turned out to be the ideal device for integrating the Ditec VIVAH. Very helpful was the information provided in Shelly’s knowledge base for the device. The Plus 1 can run on a power supply of 24V DC, an output which the VIVAH provides. Additionally the Shelly comes with a dry-contact relay, meaning it is independent of the device’s power supply and therefore ideal to switch the separate step-by-step circuit of the VIVAH. And it can integrate a switched circuit and report its status, which we can use to connect to the terminals for the gate open indicator light.

The following diagram shows the resulting wiring. To power the Plus 1, the VIVAH’s 24V DC output (terminal 0 and 1) are connected to the Plus 1’s L(-) and N(+) terminals. For triggering the step-by-step action, the VIVAH’s control circuit (the 1 and the 5) are connected to the Plus 1’s relay terminals (0, 1). And finally, the gate open indicator lamp terminal (13) is connected to the Plus 1’s switch terminal (SW).

The inside of the VIVAH’s enclosure is quite spacious, making it no problem to fit in the Shelly Plus 1:

Configuration of the Shelly Plus 1

After the Shelly Plus 1 is connected to the VIVAH, you can start setting it up in the Shelly app. The device’s user manual provides more information on that.

Once set up in the app, we can adapt the configuration to suit the control of our car gates, changing the following settings:

  • Timer: the VIVAH only needs a short activation of the step-by-step circuit to initiate action. Therefore we set the auto-off timer of the Shelly to one second. If an on command is sent by the Shelly app or other controls, the Plus 1 will then close the step-by-step circuit for a second and open it again, making it ready for the next command and action.
  • Relay Type: we set this to Detached, meaning the switch input for the Plus 1 will not control the relay, since we are using the switch input to read the status of the gate open indicator light and not for a switch that should trigger any action.
  • Power On Default: we set this to off, because we do not want the Plus 1 to trigger an action when it is starting up.
  • Input State Display: we activate the option to “Add input state identifier to the power button”. This only affects the display in the Shelly app, and gives us a neat indicator on the power button displayed there, showing whether the gates are open or close.
  • Invert Switch: this inverts the signal of the gate open indicator lamp, i.e. then the switch will be shown as on/green when the gate is closed and off/red when the gate is opened.

The following screenshots show these settings in the Shelly iOS app:

Having completed the setup of the Plus 1, we can now continue to importing it to openHAB.

Integrating the Shelly Plus 1 into openHAB

We can now import the Plus 1 into openHAB, either using the auto-discovery feature of the binding or by adding it manually. After we have imported it, we get a Thing with a few channels giving us access to operation and status of the device:

Most relevant are the Power, which allows us to trigger the step-by-step operation, and the Input/Button, which reads the status of the gate open indicator light. From the Thing we then can create an Equipment in our functional model, with Points that represent each of the channels. Note that since we have inverted the switch, we are calling the Point for the status the Gate Closed Indicator in the data model.

The basic data model is now in place and we are ready to connect the entrance gates to our virtual and physical controls.

Controlling the Gates from openHAB

So far I have used openHAB mainly as integration platform and used the openHAB user interface for testing purposes only, but now I wanted to use this project to dive a bit deeper into the topic. An important part of the openHAB user interface are widgets, which display information and allow control of the Items in the data model. Some basic widgets come with the system and many others can be installed from the openHAB market place. When looking for a neat way to present the entrance gates on the user interface I found the Garagedoor widget. However, that widget is designed only to be used in lists, and not in other parts of the user interface where standalone or cell widgets are required. So I decided to use this opportunity to learn a bit more about widgets and write my own version to be used in those places.

GarageDoorButton: a simple widget to display status of a garage door and a button to activate its operation

You can download the GarageDoorButton widget I created from the openHAB market place as add-on, see these instructions for more information. If you have any questions or comments use the corresponding community thread. The documentation of the widget’s configuration can also be found both on the market place and the community thread.

To link the widget with the data model we previously created, we set its control item to the Point for the step-by-step operation, and the sensor item can be linked to the gate closed indicator. However, since that indicator is originally intended to drive a lamp, and that lamp is intended to flash while the gate is moving, the indicator consequently also flashes back and forth between on and off while the gates are moving. To make for a nicer visual presentation, the widget also supports a dedicated state for showing the gate is moving, and I created a proxy item for translating the on/off state of the gate closed indicator to an open/moving/closed state. This step is optional and you can also skip ahead to the next section if the visual presentation is not that important to you.

The flow of information for determining the gate status, from the VIVAH gate controller to the proxy item in openHAB.

The following screenshot show the proxy item and its state description metadata, defining the three states OPEN, MOVING and CLOSED.

To translate the on/off status of the gate closed indicator, we need to setup a rule that reacts to changes in its status. The rule executes a script, which uses a timer to detect if the indicator is still flashing or has already reached its final state and then sets the status of the proxy item accordingly. You can download the script here. When using the script you have to adapt the variables set in the beginning with the names of the items you created in the data model. UPDATE Nov 05, 2023: if you are interested in controlling the car gates from Apple HomeKit, check out my newer post on that topic for an updated version of the script.

For a short explanation how the script works: basically each status change triggers the script and resets the timer and also sets the status of the gate to MOVING. The timer is set to 2 seconds, much longer than a cycle of the lights flashing while the gate is moving. Only when the gate has reached its final position and the lights stop flashing, the timer will run through and set the final state of the proxy item to OPEN or CLOSED.

The following screenshots show the rule and script:

With the proxy item in place we can link the widget with the items from the data model:

And this concludes the control from openHAB user interface. We’ll now continue first with setting up a physical wall switch from our BTicino system and then have a look at the mobile apps available to control the gates.

Controlling the Gates from BTicino

In previous posts, I have already written extensively about setting up software configuration of our BTicino MyHome automation system, and its integration into openHAB.

The control of the entrance gates follows the design pattern introduced in that post, using CEN messages for scenarios to connect the physical BTicino wall switch, an L4652/2, to the gates using openHAB. Since we already covered this earlier, I will not go into too much details, but only show you two screenshots, one of the configuration of the wall switch, and a second of the rule in openHAB that connects it with the gates:

The configuration of the wall switch in the My Home Suite. We assigned scenario with A=9, PL=2 and virtual button=7 to triggering the operation of the car gates.

In openHAB we create a rule triggered by this scenario and send an ON command to the Point for the step-by-step operation we created earlier.

If everything so far was setup correctly, we should now be able to trigger the step-by-step operation of the car gates from our BTicino wall switch.

The openHAB App vs. the Shelly App

UPDATE Nov 05, 2023: if you are interested in controlling the car gates from Apple HomeKit, check out my newer post on that topic.

So far we did not really have a use case for using mobile apps to control our home automation. Inside our home we control lights and shutters mostly from our BTicino wall switches, plus the recently added Shelly wireless buttons and Alexa voice control.

However, for the entrance gates it would be quite handy to be able to open them from our phones when we approach by car, so I had a look at both the openHAB apps (Android, iOS) and Shelly apps for this purpose. Especially important for this use case is to have quick access to the controls on the phone - accessing them in some hidden sub-menu of the app would be neither comfortable nor safe while driving.

In terms of connectivity, both apps rely on the respective cloud services to connect, which from a security perspective is a good approach because you don’t have to expose your system to the Internet, but on the other hand adds a layer of  complexity and potential source for instability. For example, while openHAB itself runs very stable, we have experienced issues with it loosing and not re-establishing the connection to the myopenhab.org cloud service. This is a known issue experienced by many users and is discussed in the openHAB community (e.g. here and here), but currently no resolution seems to be in sight. While there are workarounds available, I have not tried them yet and am not sure how reliable they are. Compared to that, the Shelly app has been working flawlessly so far, so this point clearly goes to Shelly.

For ease-of-use, Shelly for sure makes the setup easier with a new user interface coming out-of-the-box. The openHAB apps require you to setup your user interface via their Basic UI, which is a lot of effort but gives tons of flexibility and customization options.

However, for quick access to the controls, Shelly wins again, since on iOS they support widgets, which can be placed directly on your home screen and can control relays such as the Plus 1. Unfortunately the widget neither supports the input state display for showing whether the gate is opened or closed nor the auto off timer, so you’ll have to manually deactivate the button after activating it. Still, if you can live with those limitations, the widget provides the quickest access to control the gates.

The only advantage I can see in the openHAB app, is that it gives us access to our whole home automation system, so not only the Shelly components but also our BTicino system and data from our weather station. However, since currently the entrance gates are our only real use case for the mobile app, we’ll stick with the Shelly for now. But if our needs evolve and expand in the future, we’ll for sure take a closer look at the openHAB apps again.

Final Words

I am quite happy how this project turned out. Fortunately both the Shelly Plus 1 and the Ditec VIVAH’s interfaces are well-documented, and, after putting in the research and planning, the connection worked as expected from the get go. Then the integration into openHAB and our BTicino MyHome automation system was a breeze, thanks to our previously laid foundation.

With the control from mobile apps I entered territory that was new to me, but again with the Shelly app it was quite easy to manage. The setup of the openHAB apps still intimidates me a bit, but I think there is a lot of potential and for sure I’ll have a closer and deeper look at them in the future.

For now and as always, if you have any comments or questions, feel free to contact me.