Garage door script (z-wave outlet toggle) question

i control my garage door via z-wave appliance module that’s hooked up to a relay and then connected to the opener via bell wire (joined to the bell wire that comes from the wall opener). i have a script set up in HA that toggles the z-wave outlet on (which triggers the door), and then after some time, turns the outlet off. however long i set the delay is how long i’m effectively standing in the garage pressing the button on the wall opener. i have a tilt sensor on the door to tell me if it’s open or closed, and i also have a camera in the garage that i’m displaying right above the sensor/script in the UI so i can visually verify the door is open or closed.

i’ve struggled with the best way to set this up for a while now (just migrated to HA from openhab) to minimize the possibility of user error…initially, i set the delay at 2 or 3 seconds (since that’s really all it needs in order to be able to trigger the door). the problem with that, in my eyes, is that if i’m doing this remotely because i accidentally left the door open or need to open it for someone to check on our dogs i can inadvertently or otherwise run the script again before the door is fully open or closed, which may cause it to get stuck somewhere in the middle.

so, right now i have it set at a 15 second delay (which means i’m effectively standing there pressing the button for 15 seconds). this works well for the HA part, as it keeps the script “turned on” until the door is completely done opening or closing. there are two potential issues i see with this one…

first, if i have the delay set at 15 seconds and someone is still at home and wants to cancel the door opening or closing, they can’t - the z-wave outlet being turned on locks out the wall opener.

second, i’m not really sure how it works if i “cancel” the script by toggling it off while it’s in the middle of the delay…would that turn the outlet back off and return me to the initial state (where the outlet was off to begin with)? or would it just cancel in the middle and leave the outlet turned on? obviously if it’s the latter, that’s a very bad thing…as the button on the wall opener would remain locked as long as the z-wave outlet is turned on.

maybe i’m over thinking this, but i’d love to hear any ideas on the best way to handle this if anyone has any. i never got this set up completely the way i wanted it in openhab, and i’m already much closer than i ever got with that system…i’m just not quite there yet. thanks in advance for any help anyone can give me!

I have the same basic setup…

In my configuration.yaml:

  script:
    garage_door:
        alias: Garage Door
        sequence:
          - event: LOGBOOK_ENTRY
            event_data:
              name: EVENT
              message: "Garage door opener clicked."
          - service: switch.turn_on
            data:
              entity_id: switch.garageswitch_switch_2_0

In my automation.yaml:

- alias: Garage Door Reset
  hide_entity: True
  trigger:
    - platform: time
      seconds: '/4'
  condition:
    condition: state
    entity_id: switch.garageswitch_switch_2_0
    state: "on"
  action:
    service: switch.turn_off
    entity_id: switch.garageswitch_switch_2_0

This provides a script (works like a momentary switch) that I can activate via the HA page or through Alexa (Echo turn on garage door). I have a standard z-wave door sensor as well and a camera too. I also recently added an ‘alert’ to notify my if the door is sensed open too long.

alert.yaml

 garage_door:
   name: Garage Door is open
   entity_id: sensor.gdstatus
   state: 'Open'
   repeat:
     - 5
     - 30
     - 60
   can_acknowledge: True
   skip_first: True
   notifiers:
     - gmail

Your garage doesn’t go up and down with a single press of the button? Seems like it’d be easiest to have something trigger closing the same circuit that the button does instead of a “man in the middle” situation.

if i’m standing there pressing the button, of course it does. the z-wave outlet is connected to a relay that simulates a button push…

z-wave outlet on = pushing button down
z-wave outlet off = release button

that’s an interesting idea…so your automation just checks every 4 seconds to see if the outlet is on, and if so turns it off? doesn’t that overwhelm HA to be checking that often?

here’s my automation script (as it currently stands with the 15 second delay):

script:
  garage_door_toggle:
    alias: "Garage Door Toggle"
    sequence:
      - alias: "Garage Door Z-Wave ON"
        service: homeassistant.turn_on
        data:
          entity_id: switch.garage_door_opener_47
      - delay:
          seconds: 15
      - alias: "Garage Door Z-Wave OFF"
        service: homeassistant.turn_off
        data:
          entity_id: switch.garage_door_opener_47

also, i have mine set up to automatically close the door if left open longer than 10 minutes during the day or 5 minutes at night. i’m searching for a way to set up IFTTT to take care of this when the last person leaves the house (in case we ever were to leave it open accidentally), but i haven’t figured out how to do that yet without exposing HA to the internet, which i don’t want to do if i can avoid it…

- alias: "Close Garage Door Day"
  trigger:
    platform: state
    entity_id: sensor.garage_door_status
    state: 'opened'
    for:
      minutes: 10
  condition:
    condition: state
    entity_id: sensor.day_or_night
    state: 'Day'
  action:
    - service: script.garage_door_toggle

- alias: "Close Garage Door Night"
  trigger:
    platform: state
    entity_id: sensor.garage_door_status
    state: 'opened'
    for:
      minutes: 5
  condition:
    condition: state
    entity_id: sensor.day_or_night
    state: 'Night'
  action:
    - service: script.garage_door_toggle

What make/model of garage door is it? I’ve never seen one where you had to stand there and press the button. All of the ones I’ve been around either have limit switches or internal programming to where they know where up is and know where down is and a single press of the button moves the door to the opposite direction.

Basically, yes. 4 seconds is more than enough to simulate a button press for my SilentMax1000. I used a zwave contact switch with wires running to an extra key fob (soldered wires to the button on the circuit board).

It is such a simple action that i don’t believe HA or the PC even register it. I had this running back when I still used a Pi3 to run HA and did not have any issues.

I originally did have something like what you have (scripts) but then found this setup in searching through the forums here.

huh? what garage door opens without you having to press a button? there has to be some sort of interaction with it to open the door…

interesting…but how does that work if you cancel the script? or can you not cancel it because there’s no delay?

I tap the button and the door opens until it’s opened all the way and it stops and vice-versa; I don’t have to sit there and hold the button to make it move. What you’re describing is physically holding the button down while the garage door does its thing.

yeah, that’s the way mine works. you’re misunderstanding what i’m asking…

the problem i’m trying to solve here is that if i press the button again while the door is in motion is that it stops the door wherever it is at that point. that’s fine if i’m standing there and can visually verify what’s going on, but if i’m doing it remotely i don’t want it to do that…i want it to only go all the way up or all the way down. that’s why i have the delay at 15 seconds, to prevent sending the command again before the door finishes it’s movement…i’m effectively holding down the button, locking it out until the door is finished moving.

Could you set a variable once you trigger the “close” or “open” script and then have automations on garage door state change to reset the value? In the open or close script you could check the variable and do nothing if it’s set.

so in the script (pseudocode)
if (!isMoving) {
isMoving = !isMoving
make it move (close the circuit for a half a second or so)
}

automation:
when the garage door state changes from open/closed or closed/open
set isMoving = false

I tried doing it that way in openhab but I could never get anything to sync the way I wanted it…maybe I’ll give it another shot that way in HA.

Can’t cancel although I have never had a need to.

Mine works this way as well. This is why I have the door sensor and the camera, to be able to visually verify the closure of the door if I am remote.

i actually like your method better the more i think about it, because it makes sure the z-wave outlet is turned off no matter what every 4 seconds. there’s no need for that outlet to be on any longer than that, since all it’s doing is simulating a button push…

i’m going to tinker with this after work and see how it goes, but i think that’ll work. thanks!

edit: did some messing around with it, and what i’ve come with is actually a slight mod on your version…i’m using the outlet being turned on as a trigger, which then delays 3 seconds after it’s turned on and turns it back off. this way it’s not just sitting there checking every 3 seconds when it doesn’t need to be - the automation only triggers 3 seconds after the switch is turned on.

- alias: "Garage Door Toggle"
  trigger:
    platform: state
    entity_id: switch.garage_door_opener_47
    state: 'on'
    for:
      seconds: 3
  action:
    - service: switch.turn_off
      entity_id: switch.garage_door_opener_47

so far, it’s working pretty damn well. i’m still trying to figure out the best way to warn the user “hey, the door is probably in motion” if they activate the script again before 15 seconds elapse, though…may do some more tinkering with the variable idea @quadmasta mentioned earlier.

1 Like

I would just split the delay so as not to lock out your garage door opener. 2 seconds between turn on and turn off, then a 13 second wait. The wait only needs to be long enough for the sensor state to change.

You could also incorporate a safety check automation to check the switch for being on and turn it off. Have that run every minute or so. Just in case, like you feared, the script was stopped during the switch on window. 4 seconds does seem a bit much.

I just got mine setup the other day and ran across this thread today. Figured I’d share what I did in case anyone else needs another idea.

I had a tilt sensor already installed and had a spare Z wave appliance plug. I then purchased this relay from Amazon (LINK).

I added some check logic in the scripts to make sure the door went to the position it was expected in. As a side note, I can see my garage from my Ring doorbell so I do have a visual backup if necessary.

Here is the code:

Cover:

  - platform: template
    covers:
      garage_door:
        friendly_name: "Garage Door"
        value_template: "{{ is_state('binary_sensor.d2_garage_door_main_sensor', 'on') }}"
        open_cover:
          service: script.garage_door_open
        close_cover:
          service: script.garage_door_close
        icon_template: >-
          {% if is_state('binary_sensor.d2_garage_door_main_sensor', 'on') %}
            mdi:garage-open
          {% else %}
            mdi:garage
          {% endif %}

Scripts:

############################
#GARAGE DOOR
############################
garage_door_open:
  alias: 'Garage Door Open'
  sequence:
    - service: switch.turn_on
      entity_id: switch.d12_garage_door_switch
    - delay: 00:00:03
    - service: switch.turn_off
      entity_id: switch.d12_garage_door_switch
    - delay: 00:00:20
    - condition: state
      entity_id: binary_sensor.d2_garage_door_main_sensor
      state: 'off'
    - service: notify.gregg_pushover
      data:
        title: 'Garage Door Failure'
        message: 'The Garage Door did not open!'

garage_door_close:
  alias: 'Garage Door Close'
  sequence:
    - service: switch.turn_on
      entity_id: switch.d12_garage_door_switch
    - delay: 00:00:03
    - service: switch.turn_off
      entity_id: switch.d12_garage_door_switch
    - delay: 00:00:20
    - condition: state
      entity_id: binary_sensor.d2_garage_door_main_sensor
      state: 'on'
    - service: notify.gregg_pushover
      data:
        title: 'Garage Door Failure'
        message: 'The Garage Door did not shut!'
1 Like

@gregg098
Can you paste your switch configuration here also?
I am trying to get my Go Control garage doors working and think this is the missing piece for me.

There is no switch. Just a template cover and some scripts.