Implementing a cover using various components?

I have a Wemo Maker that is controlling a garage door and a sensor that detects when the door is Open. I’ve got it working as a momentary switch in Home Assistant and I have notifications working for when it’s up (and up too long).

What I’d really like to do is make a template that allows me to use it (and ultimately expose it in HomeKit) as a Cover along the lines of cover.command_line ( where I can issue the open and close commands and determine status.

Ultimately, I’d like to add a tilt sensor as well so I’d want to combine it as well.

Is there some way that is possible?


I haven’t done this yet, but I’m planning on doing something similar. I ordered a z-wave tilt sensor for my garage door and plan on making a ESP8266-based relay to toggle my garage door via MQTT.

This is what you are looking for:

I have that working already.

Problem is the HomeKit activation wording is different (Turn On vs Open and Close vs Turn Off).

A switch in Home Assistant gets exposed as a switch in HomeKit meaning my wife has to remember to say “turn on the garage door” instead of “open the garage door”. Not a massive deal, if you can remember. The problem becomes more apparent when you want to ask “is the garage door open?”

Hi, I have the exact same setup and the same problem with the wife. Have you found a solution to this problem?

No - nothing yet.

I’ve successfully done this to integrate WEMO MAKER, Magnetic Reed and GOOGLE HOME. This solution works well if your garage door using a ‘momentary’ switch configuration. I’m running Home Assistant using HASSBIAN on a Raspberry PI.

First, you need to expose the attributes of the Magnetic Reed that is attached to the Wemo Maker to be it’s own sensor. This way you can use this new sensor to track the state of the Garage Door. Having this sensor available makes it useful to trigger automations as well!

  - platform: template
        value_template: '{{ states.switch.garage_door.attributes.sensor_state }}'
        friendly_name: 'Garage Door Magnetic Reed'
        entity_id: switch.garage_door    ###this is the entity id of your wemo maker switch

The next step to to create a template switch that will allow you to turn the Garage Door ON or OFF (i.e. on = Open Garage, off = Close Garage). Use code below:

Note: I have put in conditions that rely on the magnetic reed sensor created above. These conditions aren’t strictly necessary, but they make things work much better when you are using the Google Home. For instance say you’re inside the house and you can’t see your garage door. You tell the Google Home “OK Google, turn off the garage door” to close your garage door. Without the conditions from the Magnetic Reed Sensor if your garage door were already closed this command would open the garage door (not what you want, so use the conditions)

  - platform: template
        value_template: '{{ states.switch.Garage_Door.attributes.sensor_state == "off" }}'
          - condition: state
            entity_id: sensor.garage_door_reed
            state: 'on'
          - service: switch.turn_on
            entity_id: switch.garage_door
          - condition: state
            entity_id: sensor.garage_door_reed
            state: 'off'
          - service: switch.turn_on
            entity_id: switch.garage_door
        friendly_name: 'Garage Door'

Next expose your switches to the Google Home by using the emulated Hue component. If you have an Amazon Echo then use that version instead.

Note: Google Home does not work on different ports. Refer to site below to open port 80 on Raspberry Pi

  type: google_home
  host_ip:   ###use your own Raspberry Pi IP address here
  listen_port: 80
  expose_by_default: true

With all of this done you should have the following:

  1. Sensor that tracks magnetic reed on your garage door
  2. A new Garage Door template switch that also knows whether or not the garage is open or not
  3. Ability to tell Google Home to turn ON (open) or OFF (close) the garage door

Finally you may want to hide your original Wemo switch in HA and also not expose it to the Google Home by adding the following into your “homeassistant:” customize section.

  name: Home
    switch.garage_door:   ###use your wemo switch's original entity id
      hidden: true
      emulated_hue: false

I want this so badly. A “template cover” component like “template switch”. For those of us using Homebridge for iOS integration, I think this will also get us a notification when the garage door opens.

I had this working when I was using Wink, but now that I took Wink out of the loop, my zwave magnetic contact can’t show up as a cover in Homebridge. I can’t make it a cover in Homeassistant.

1 Like

+1 for this!

I’ve had a Zwave magnetic reed sensor rigged to my garage door for the last couple of years. It’s paired to my Vera and for the last six months I’ve been running Home Assistant to alert via Sonos and SMS when it’s left open. I also have it triggering an automation to turn on the back porch lights when the garage is opened at night.

Works great and is super useful as our garage is detached and faces the alley and you can’t see if it’s open from inside the house.

Would be great to expose this via HomeBridge also.

Cover template is a thing now for those that are looking into this.

Hi there, this is my configuration:
1 Sonoff as relay
2 Xiaomi Sensors for know if cover is open/closed with frontend icon support
3 Apple HomeKit Working perfectly / with clickable notifications for closing garage thx to @DrZzs

  - platform: template
        friendly_name: "Saracinesca"
        value_template: >-
          {% if is_state('binary_sensor.door_window_sensor_158d0001fd6296', 'on') %}
          {% else %}
          {% endif %}
          - service: script.attivagarage
          - condition: state
            entity_id: binary_sensor.door_window_sensor_158d0001fd6296
            state: 'on'
          - service: script.attivagarage
          service: script.attivagarage
        icon_template: >-
          {% if is_state('binary_sensor.door_window_sensor_158d0001fd6296', 'on') %}
          {% else %}
          {% endif %}

    alias: "Apri-Chiudi"
      - service: switch.turn_on
          entity_id: switch.sonoff_garage_4
      - delay:
          seconds: 1
      - service: switch.turn_off
          entity_id: switch.sonoff_garage_4 

  - platform: mqtt
    name: "Sonoff Garage 4"
    state_topic: "stat/garage/POWER4"
    command_topic: "cmnd/garage/power4"
    availability_topic: "tele/garage/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: true

for clickable notification pls see:

One more thing: as you can see in my script there is a timeout of 1 second and than another service for turn off the switch. My garage cover work with inching mode, so first I tryed to use hardware for do this becouse the sonoff pro 4ch support this mode ad well…but is Not true at all! If HA doesn’t send an off payload to sonoff, it continues to store the On payoff; there is no Communication between hardware inching mode and home Assistant mqtt server. This will cause to open cover randomly because there is an ON retained on the sonoff, for Example when it loose connection or reboot. The solutions is to setup a script that emulate inching so Tasmota and HA mqtt can be in sync again. I hope that this will help ppl!

Was trying to figure out to to combine multi components in one control, this works!

It works.