Zoos ZEN17 Relay Garage Door Opener with two binary sensors

I am new to Home Assistant (previously used HomeSeer). I have a ZEN17 relay that I’m trying to use to as a garage door opener. I can toggle it without issue and have it configured for a momentary contact. How would a card be set up for this through the configuration.yml?

Switch: switch.garage_door_1
Binary sensor 1 (closed when door fully open): binary.sensor.garage_door_1_open
Binary sensor 2 (closed when door is fully closed): binary.sensor.garage_door_1_closed

When sensor 1 goes from closed to open, door is closing
When sensor 2 goes from closed to open, door is opening
When sensor 1 is closed, door is open
When sensor 2 is closed, door is closed

Any help would be greatly appreciated. I found plenty of threads on this topic for one sensor, but none for two.

I have the same device and love it.

You use a cover for what you are after:
Cover - Home Assistant (home-assistant.io)

How did you set up your cover? I have not found one that does quite what I am looking for

Put this into your configuration.yaml file (updating the entity names for your instance):

cover:
  - platform: template
    covers:
      garage_door:
        device_class: garage
        friendly_name: "Garage Door"
        value_template: >-
          {% if is_state('binary_sensor.universal_relay_window_door_is_open','on') %}
            Open
          {% else %}
            Closed
          {% endif %}
        open_cover:
          service: switch.turn_on
          data:
            entity_id: switch.universal_relay_1
        close_cover:
          service: switch.turn_on
          data:
            entity_id: switch.universal_relay_1
        stop_cover:
          service: switch.turn_on
          data:
            entity_id: switch.universal_relay_1
        icon_template: >-
          {% if is_state('binary_sensor.universal_relay_window_door_is_open','on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %} 
2 Likes

Thanks for sharing your template. For folks seeing this thread in the future, below is the template I landed on as of May’24. I’m using relay 1 on the ZEN17, and a ZSE43 tilt sensor for open/close state detection.


My ZEN17 is configured as below:

  • Relay 1 wired as NC for normally closed operation. I want the circuit to be always closed so I still get the usability of the momentary switch that came with my garage door opener. It has a button to turn on the light which I use regularly. Needs to be powered (closed circuit) to work. soon, I’ll install NC magnetic reed switches as redundant close/open detection.
  • parameters 2 and 3: 11 “On/Off report (Dry contact switch/sensor)”
  • parameter 7: Relay 1 auto turn-on timer set to 1 second
  • with this configuration, the relay is on by default in my UI, and when turned off, the ZEN17 turns it back on in 1 second.

configuration.yaml:

cover:
  - platform: template
    covers:
      garage_door:
        unique_id: test_cover
        device_class: garage
        friendly_name: "Garage Door"
        value_template: >-
          {% if is_state( 'binary_sensor.garage_tilt_is_open' ,'on') %}
            Open
          {% else %}
            Closed
          {% endif %}
        open_cover:
          service: switch.turn_off
          target:
            entity_id: switch.garage_universal_relay_1
        close_cover:
          service: switch.turn_off
          target:
            entity_id: switch.garage_universal_relay_1
        stop_cover:
          service: switch.turn_off
          target:
            entity_id: switch.garage_universal_relay_1
        icon_template: >-
          {% if is_state('binary_sensor.garage_tilt_is_open','on') %}
            mdi:garage-open-variant
          {% else %}
            mdi:garage-variant
          {% endif %}
1 Like

Once I add this to my configuration.yaml, how do I make use of it? My old garage door controller code from a couple years ago broke when I upgraded HA so I’m looking for some new code. Not sure how to make use of this. Any tips would be greatly appreciated! TY!

Thank you for this code been looking how to use my zen16 for a while and this was it! i got this all set up and noticed that even when its closed if i tell alexa to close it, it opens it. bypassing the 4 digit code used to open it with voice. is there a way to prevent this? or did i just do it all wrong?

I don’t think you did anything wrong. I don’t use alexa to control my garage door so I never noticed that bug, but it’s a bug. I only use the UI to control my garage. The UI greys out the close button if the garage is already closed.

The template is merely representing a relay + sensor as a cover. commands ‘open’, ‘close’, ‘stop’ are all converted to ‘turn_off’ under the hood.

I’m sure this is fixable in a number of different ways… just not sure how off the top of my head or which is the most elegant.

I did some back and forth with ChatGPT and it suggested adding conditions to the open_cover and close_cover target entity IDs. This way, Home assistant still sends the switch.turn_off service, but if the garage door is already in the desired state, it sends it to an entity_id that doesn’t exist, so nothing happens. That’s what we want.
I haven’t tested this yet in my home, can you try and post back if it works/doesn’t work?


Link to ChatGPT chat:


Revised configuration.yaml:

cover:
  - platform: template
    covers:
      garage_door:
        unique_id: test_cover
        device_class: garage
        friendly_name: "Garage Door"
        value_template: >-
          {% if is_state( 'binary_sensor.garage_tilt_is_open' ,'on') %}
            Open
          {% else %}
            Closed
          {% endif %}
        open_cover:
          action: switch.turn_off
          target:
            entity_id: >-
              {% if not is_state('binary_sensor.garage_tilt_is_open', 'on') %}
                switch.garage_universal_relay_1
              {% else %}
                none
              {% endif %}
        close_cover:
          action: switch.turn_off
          target:
            entity_id: >-
              {% if is_state('binary_sensor.garage_tilt_is_open', 'on') %}
                switch.garage_universal_relay_1
              {% else %}
                none
              {% endif %}
        stop_cover:
          action: switch.turn_off
          target:
            entity_id: switch.garage_universal_relay_1
        icon_template: >-
          {% if is_state('binary_sensor.garage_tilt_is_open','on') %}
            mdi:garage-open-variant
          {% else %}
            mdi:garage-variant
          {% endif %}
  • edited to replace ‘service’ with ‘action’ to comply with the new standards effective a few months ago

Cheers!

Thank you so much this has been racking my brain for days! it does work with voice assistant and within automations. I need to start using chatgpt for sure. thank you again.

my next quest is using a shelly plus uni to read the differences in voltage that is put out by the obstruction sensors and send a notification that the door didnt go down. should be easy enough. waiting on the uni to get here on monday.

thank you again.

Be careful with this. It was trained on old HA info and may not even get you close to a real answer in many situations as shown by @2carlos needing to change service to action.

It can get much worse than that as time goes on.

You can refer to this recent thread for a discussion on this.
Prompts used when asking AI to code yaml for you? - Configuration - Home Assistant Community