Zigbee door sensor + sonoff = garage cover? (edit- working config inside)

Hey guys, just wondering if there is any way to combine a zigbee door sensor and a sonoff running tasmota into one cover device? I converted the sonoff to a dry contact relay and am using it to activate the door. I realize i could probably hook a wired door sensor up to the sonoff, but there’s not a good place to mount one up near the motor and i really don’t want wires running along any of my walls.

write small scripts to trigger your sonoff on/off with a small delay.

Then use the template cover. Scripts are your open/close calls and use the state of your zigbee door sensor to get the door state.

1 Like

Oh awesome, thanks! I already have a script that triggers the sonoff relay for half a second, can i just use that same script for all 3 door functions? Also, I’m not familiar yet with how to build a template, will the one below from the docs page you linked work for a single “door closed” sensor?

value_template: "{{ states('sensor.garage_door')|float > 0 }}"

Depends on what your sensor returns.

Does your sensor return numeric values for open/closed or a open/close state?

Yes, the same script can be used for open and close assuming thats how your door works (most work that way). For the stop function it depends on your door. Its optional and I don’t use it as I don’t ever need to stop my door when activating from HA.

Open/close your door and while its moving activate the script again. If the door stops you can use it for the stop function. If it closes as a result you need a different sequence (simulated button press) to stop the door.

i’ll know more about the sensor when it gets here later this week :rofl:

that is how my door works, one button for up down and stop. though if the door is travelling down and you hit the button it automatically goes all the way back up, so i’ll probably just leave out the stop command.

Thanks for all of your help! I think i can probably get everything going from here

For anyone else that stumbles across this, here is what I ended up with. It’s working perfectly!

cover:
  - platform: template
    covers:
      door:
        friendly_name: "Garage Door"
        value_template: >-
          {% if is_state('binary_sensor.garage_door_opened', 'on') %}
            open
          {% else %}
            closed
          {% endif %}
        open_cover:
          service: script.activategarage
        close_cover:
          service: script.activategarage
        icon_template: >-
          {% if is_state('binary_sensor.garage_door_opened', 'on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}
script:
  activategarage:
    alias: "Open/Close"
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.garage_button
      - delay:
          milliseconds: 200
      - service: switch.turn_off
        data:
          entity_id: switch.garage_button

switch.garage_button is the sonoff, which is running Tasmota and talks to HA via MQTT.
binary_sensor.garage_door_opened is a zigbee door sensor that’s connected thru my Wink hub. It reports off when the door is closed and on when it is open

2 Likes

Thanks for sharing :slight_smile:

this is my configuration with sonoff pro and a xiaomi door/window sensor

cover:
  - platform: template
    covers:
      saracinesca:
        friendly_name: "Saracinesca"
        value_template: >-
          {% if is_state('binary_sensor.door_window_sensor_158d0001fd6296', 'on') %}
            open
          {% else %}
            closed
          {% endif %}
        open_cover:
          service: script.attivagarage
        close_cover:
          service: script.attivagarage
        stop_cover:
          service: script.attivagarage
        icon_template: >-
          {% if is_state('binary_sensor.door_window_sensor_158d0001fd6296', 'on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}
script:
  attivagarage:
    alias: "Apri/Chiudi"
    sequence:
      - service: switch.turn_on
        data:
          entity_id: switch.sonoff_garage_4

switch.sonoff_garage_4 is set as mqtt switch