Shelly2.5 Garagedoor opener with 4 states on a Hörmann ProMatic2

This is my Shelly2.5 garagedoor opener with four states in a custom button-card attached on a Hörmann Promatic2 sectional door. Single button open-stop-close and monitoring its state.

closed
opening
open
closing

Hardware needed
Shelly2.5 (prob the newer 2pm will work too)
Some Wiring
1x Reed contact* (in used the ABUS MK2000W - NC)
*the Hörmann has a build-in contact that is needed for the second ‘sensor’

Shelly2.5 setup:
setup is relay mode giving it two channels
timers: auto OFF with 1 second
power on default: OFF
appliance type: relay
button type: detached switch
*settings are for both channels

From the entities that are being created now in home-assistant you are going to need the ‘input’ channels and the ‘switch’ channel form the given Shelly2.5 wich in my case i named:
binary_sensor.garage1_1_input , binary_sensor.garage1_2_input , switch.garage1_1

Promatic2 setup
On the printboard of the promatic2 there is a dipswitch. [additional image1] for the internal contact to work you should set no 2 to ON (read manual if things differ for your print-board as you may have other settings)

Connecting the Shelly2.5 on the Promatic2
the shelly is powered from the onboard 24V DC of the promatic
The external sensor in attached to the door-rails and runner (close to the promatic) [additional image2]
the terminals are being attached as can be seen in the drawing below: [and additional images3+4]

The Home Assistant part

Button Card by @RomRider to be found here: https://github.com/custom-cards/button-card

After adding button-card in home assistant create a card:

type: custom:button-card
color_type: card
action_name: run
tap_action:
  action: call-service
  service: switch.turn_on
  service_data:
    entity_id: switch.garage1_1
entity: sensor.garage_status
lock:
  enabled: true
name: Garagedoor
show_state: false
show_label: true
state:
  - value: open
    label: DOOR OPEN
    color: red
    icon: mdi:garage-open-variant
    styles:
      card: null
  - value: opening
    label: DOOR IS OPENING
    color: orange
    icon: mdi:arrow-up-bold-box
    styles:
      card:
        - animation: blink 2s ease infinite
  - value: closing
    label: DOOR IS CLOSING
    color: orange
    icon: mdi:arrow-down-bold-box
    styles:
      card:
        - animation: blink 2s ease infinite
  - value: closed
    label: DOOR IS CLOSED
    color: green
    icon: mdi:garage-variant-lock

Next add script below to configuration.yaml:
*cleaned up the yaml code: Jan 19-2023

template:
  - trigger:
      - platform: state
        entity_id:
          - binary_sensor.garage1_1_input
          - binary_sensor.garage1_2_input
    sensor:
      - name: Garage_Status
        unique_id: Garage_status
        state: >
          {% if (trigger.to_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage1_1_input') %}
            closed
          {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage1_1_input') %}
            opening  
          {% elif (trigger.to_state.state == 'off' and trigger.entity_id == 'binary_sensor.garage1_2_input') %}
            open         
          {% elif (trigger.to_state.state == 'on' and trigger.from_state.state == 'off' and trigger.entity_id == 'binary_sensor.garage1_2_input') %}
            closing            
          {% endif %}

Additional images and disclaimer

This is not the first script for automating and monitoring a garagedoor but on other posts and scripts i ran into the fact that for a noob as myself, things are not always explained in as we call it ‘Jip & Janneke’ language… i.e… in easy language,this goes there …
Anyhow I tried explaining things in a way i would understand it myself :slight_smile:

That said most of the scripting came from other posts and people who tried similar (and did not work for me) and then i crafted them together with help of a friend. I have no clue anymore where al the pieces came from so if you find some of your work here, thank you for it and lets hope we can help many others with this compiled version!

image1:

image2:

image3:

image4:

5 Likes

This is fantastic, champion :v:! I did recreate this and it works like a charm! :slight_smile:
I can confirm it works with a Shelly Plus 2PM, and FYI, I have Hörmann ProMatic3.
The only difference on ProMatic2 vs ProMatic3: in the ProMatic2 schematic, the integrated contact sensor naming is R-, whereas on the ProMatic3 schematic, its simply 0

FYI, I noticed, that in your template sensor, you have off for the ABUS magnet sensor (binary_sensor.garage1_2_input) if the garage door is open. You can set the output to invert in the Shelly configuration, then the ABUS will be on if the garage is open.

I did that and also added an else statement, in case something goes wrong.
Notice the changes in my open and closing elifs below

# Sensor garage
- trigger:
    - platform: state
      entity_id:
        - binary_sensor.garage_closed
        - binary_sensor.garage_open
  sensor:  
    - name: Garage status
      unique_id: Garage_status
      state: >
        {% if (trigger.to_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_closed') %}
          closed
        {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_closed') %}
          opening
        {% elif (trigger.to_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_open') %}
          open
        {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_open') %}
          closing
        {% else %}
          unknown
        {% endif %}

Instead of inverting the output in shelly, the correct sensor to buy would be ABUS FU7350W.

Your work is really amazing. No more “have I closed the garage?” thinking for me (my garage is about 30m away). Thank you!! :star_struck:

1 Like

I noticed, that the ABUS sensor bounces (instead of on to off it goes on-off-on-off and the same vice-versa). Hence, I debounced the ABUS sensor in HA (unfortunately, there is no setting for this in Shelly) with an additional binary_sensor. There might be a more elegant way to do this directly in the garage_status sensor, however the below works for me.
Also, I did reconfigure the closed and open state, it polls the state of the open&closed sensors instead to rely on the trigger-to-state feature. I think the latter would break the garage-status if you restart HA.

Here is my optimised sensor including debouncing:

# Sensors garage
- binary_sensor:
    - name: Garage open debounced
      unique_id: Garage_open_debounced
      state: >
        {% if (states('binary_sensor.garage_open') == 'off') %}
          off
        {% elif (states('binary_sensor.garage_open') == 'on') %}
          on
        {% else %}
          unknown
        {% endif %}
      delay_off:
        seconds: 1
      delay_on:
        seconds: 1    

- trigger:
    - platform: state
      entity_id:
        - binary_sensor.garage_closed
        - binary_sensor.garage_open_debounced
  sensor:  
    - name: Garage status
      unique_id: Garage_status
      icon: mdi:garage-variant
      state: >
        {% if (states('binary_sensor.garage_closed') == 'on' and states('binary_sensor.garage_open_debounced') == 'off') %}
          closed
        {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_closed') %}
          opening
        {% elif (states('binary_sensor.garage_open_debounced') == 'on' and states('binary_sensor.garage_closed') == 'off') %}
          open
        {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_open_debounced') %}
          closing
        {% else %}
          unknown
        {% endif %}
1 Like

Hi, looks like the perfect solution for me too, perfect project. Only problem: I have a Hormann A445 control. I currently have a Fibaro z-wave puls relais attached as ‘puls button’ on the X2 connection of the A445. I think a Shelly should be a solution for me too if connected to X3 connection of my A445. Do you know hor to wire the Shelly for a Hormann A445 ?

Hi Michel,

The wiring would stay the same i guess as you want a puls to be send and monitor its state.
Trail and error (pref. with a multimeter :slight_smile: ) and the schematics for your door-opener is the way to go!

Hi! Awesome documentation,.exactly what I needed. Seems to be my next autumn errand :wink:

May I ask you what wires you used? Looking at the clamp colors it would be 0.75 (grey) and 1.0 mm2 (red)?

I used 1.5mm2 but this is all 24V so dont you worry :grin:

Thanks for this detailed explanation. I just finished up the hardware part on my ProMatic 3 and the controls work like a charm, I can now use my Apple Watch to open and close the door while I’m still on my bike. Absolutely great!

Only thing I can’t seem to get working is the custom card. It keeps giving me garage_status = unavailable. I did follow fair_dinkum’s advice to use the ABUS FU7350W, but I think the code as supplied doesn’t quite work with that. I have tried many combinations of ‘on’ / ‘off’ / Shelly inverted input, but to no avail. Anyone has an idea? Both sensors (the Closed sensor on the ProMatic and the ABUS Open sensor) do respond when the door opens/closes, so the sensors work. Not sure if it is in the HA code, or the Shelly setup.

Shelly setup on both Outputs. Currently Input (0) is not inverted, Input (1) is inverted. I am using a Shelly Plus2PM running firmware 1.0.3.

What is the status of each of the sensors in dev tools? Are those sensors at least showing on and off? That needs to work properly before you can work on the combo status sensor (Garage_Status)
I modified the code if you see my post above, with debouncing and not relying on the trigger-to-state, instead I use the state of each sensor. I had problems with the reliability when the sensor was not debounced.

Hi fair_dinkum, thanks for helping out! Yes, I have also tried your debounced code because I would like to use that in the end as well. But as it didn’t work, I thought to first make it work with the original, less-complex, code and then to change to the debounced code.

Great point about the sensor values. I now think that is where things are not going right. See screenshot. Dev Tools reports both sensors’ current state to be a DateTime format, rather than an on/off state. I checked this with actually opening/closing the door: the state is simply the DateTime stamp when the sensors detect a change. And both the open and close sensors are once more confirmed to trigger when the door reaches opened and closed states (sending the timestamp instead of on/off status).

Because the code is expecting the binary sensors to be either on/off and not a DateTime format, the output is simply incompatible with the code and doesn’t compute further, is that right?

I can’t find any other entities in Shelly that change on/off when the open/close sensors detect a change. However, the other features of Shelly, like OverHeating/OverPowering are signals of the on/off type and not of the DateTime type.

I have looked a thousand times in the Shelly, but I can’t find how to change the sensor output from DateTime to be on/off. Any idea?

I think you renamed the wrong sensors with a friendly name binary_sensor or something like that…
I also have event_sensors for my Shelly Dimmer Switch, but all other Shelly do not have event_sensors?

These are simply the wrong sensors that you are looking at, you are right they must be off the type of binary_sensor but the ones you shared above are event sensors with a friendly name binary_sensor - that does not work.

Can you post a screenshot of all entities of this Shelly? (Settings → Devices and Services → Shelly → [your_shelly] → XX entities, the you will see a list of all entities for this device.

(FYI, I have 28 entities for my Shelly 2 Plus 2PM device)

I got a step further! Turned out that having the Shelly set to ‘button’ instead of ‘switch’, sends DateTime states of the events, rather than on/off states of the sensors. So now my 2 sensors actually report on/off and they do so accordingly with the door status (both in Shelly and HA environments):

Door Closed: ProMatic sensor = ON, ABUS sensor = OFF
Door Open: ProMatic sensor = OFF, ABUS sensor = ON

Next thing is that I can’t get your debounced code to work. When I open and close the door, the binary_sensor.garage_open_debounced sensor value is always OFF, it never goes to ON, also not when I open/close the door. The custom button card therefore always shows the sensor.garage_status to be ‘unknown2’ (I renamed the unknown in the garage sensor IF statement to unknown2 not to be confused with the unknown in the debounced sensor IF statement). See below for the exact code that is now in the config.yaml. I am breaking my head on it :confused:

template:
- binary_sensor:
    - name: Garage open debounced
      unique_id: Garage_open_debounced
      state: >
        {% if (states('binary_sensor.garage_open') == 'off') %}
          off
        {% elif (states('binary_sensor.garage_open') == 'on') %}
          on
        {% else %}
          unknown
        {% endif %}
      delay_off:
        seconds: 1
      delay_on:
        seconds: 1    

- trigger:
    - platform: state
      entity_id:
        - binary_sensor.garage_closed
        - binary_sensor.garage_open_debounced
  sensor:  
    - name: Garage status
      unique_id: Garage_status
      icon: mdi:garage-variant
      state: >
        {% if (states('binary_sensor.garage_closed') == 'on' and states('binary_sensor.garage_open_debounced') == 'off') %}
          closed
        {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_closed') %}
          opening
        {% elif (states('binary_sensor.garage_open_debounced') == 'on' and states('binary_sensor.garage_closed') == 'off') %}
          open
        {% elif (trigger.to_state.state == 'off' and trigger.from_state.state == 'on' and trigger.entity_id == 'binary_sensor.garage_open_debounced') %}
          closing
        {% else %}
          unknown2
        {% endif %}

That should be an easy fix. In the screenshot above, you can see the entity name is binary_sensor.shellyplus2pm_d4…

And in your config, you use a different name in the templates-section etc: binary_sensor.garge_open.

Go to your shelly (in HA) and rename those two cryptic-named binary sensors (click on the cogwheel of the entity and then you can rename it) to the speaking names binary_sensor.garge_open and binary_sensor.garge_closed
Right now, they have a friendly name but the “real name” is cryptic - thats why it does not work. I think it works without rebooting HA, but it does not harm if you reboot :slight_smile:

Thank you so much! The card started working the moment I changes the entity IDs, not just the (friendly) names. The only thing not working is the tap-function. When I tap, nothing happens (also not after the lock disappears). Instead, I made a simple button card, toggling the Shelly Switch controlling the door movement. Is this another naming thing I did wrong?

Simple button card

show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
entity: light.shellyplus2pm_d4d4da09c92c_switch_0
name: Garage
show_state: false
icon: mdi:garage

button-card code:

type: custom:button-card
color_type: card
action_name: run
tap_action:
  action: call-service
  service: switch.turn_on
  service_data:
    entity_id: switch.garage1_1
entity: sensor.garage_status
lock:
  enabled: true
name: Garage
show_state: false
show_label: true

tap_action:
  action: call-service
  service: switch.turn_on
  service_data:
    entity_id: switch.garage1_1

The binary_sensor is a detached sensor if you configured it correctly, so the switch is independent.

You can see in your code with the simple button card, that the entity is completly different. Its a light. Not sure if it works because you cannot use the service switch.turn_on for a light entity. Maybe you could get it work when using the service light.turn_on, however I’d rather recommend you go into your shelly config (actually not in HA but in shelly itself) and reconfigure the “light” so that it is a generic switch instead of a light - its misleading. Then, once reconfigured and reboot of HA, you should see the proper switch entity in HA and you can use that for the button-card.

Fabulous, it is complete now! Thanks once more for your support! Very much appreciated. I got it working completely and I learned a lot along the way how things work.

You’re welcome! Thats whats the community here is about :ok_hand:t2:

hello everyone,

For some time now I have implemented this wonderful solution for my garage home automation (same version hormann promatic2 of the guide).

At first everything seems to work correctly but after some time I notice continuous disconnections of the shelly with the wifi AP. These disconnections would not be a problem except that when the shelly completely loses connection with the wifi and consequently with HA, I often find the garage open as if the shelly resets and switches the device opening the garage.
This is really a problem. i have reset from scratch and rechecked everything as per the guide several times but the same problem always happens

On the one hand I am trying to upgrade the wifi network (mesh network) to avoid the disconnection of the shelly with my network but the problem is that I don’t want it to open the garage

What do you think could be the cause/solution to the problem.

thank you all very much!

What have you set for the state if there is a power loss in the Shelly settings itself? There is on, off or reset previous state (I have it set to off).

I understand power loss is not the same as wifi-loss but it would be news to me that on a wifi-loss, that the status is been reset??
Also, what does the log say in HA, do you see the trigger in the logbook?