Automation for Ratgdo

I am trying to create an automation that if its after 9:30 pm and my garage door has been open for more than 30 min, hen close the garage door. This does not seem to work. When I run the automation manually it will close the door, so it likely has to do with how I test the cover state.

Appreciate the help.

alias: Garage Door Open - Mark’s
description: ""
trigger:
  - platform: state
    entity_id:
      - cover.ratgdo_mark_door
    to: open
    for:
      hours: 0
      minutes: 30
      seconds: 0
condition:
  - condition: time
    before: "23:59:00"
    after: "21:30:00"
action:
  - service: notify.pushover
    data:
      message: Mark's Garage Door is Open
      title: Mark’s Garage Door is Open
      target: iphoneX
  - service: cover.close_cover
    metadata: {}
    data: {}
    target:
      device_id: 9c711d42908828ea852e8cf5241a6286
mode: single

You get anywhere with this? I’m having same issue where I can’t get it to trigger but running the automation manually, it’ll close the door.

I noticed it worked fine when using MQTT vs ESPHome. I may swap back.

No i have never gotten it to work. I am using mqtt. If you get it to work please send me a message.

I do a simple trigger at 10pm. Getting the door state was kind of a pain. Here’s what I’m running now that works. current_position is 0 for closed and 100 for open, and anywhere between if you stop the door.

alias: Close Garage Door
description: ""
trigger:
  - platform: time
    at: "22:00:00"
condition:
  - condition: numeric_state
    entity_id: cover.garage_doorv25i_eed624_door
    attribute: current_position
    above: 1
action:
  - service: cover.close_cover
    data: {}
    target:
      entity_id: cover.garage_doorv25i_eed624_door

i think this is what you want:

alias: Garage Door Open - Mark’s
description: ""
trigger:
  - platform: state
    entity_id:
      - cover.ratgdo_mark_door
    to: open
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - platform: time
    at: "21:30:00"
condition:
  - condition: time
    before: "23:59:00"
    after: "21:30:00"
  - condition: state
    for:
      hours: 0
      minutes: 30
      seconds: 0
    entity_id: cover.ratgdo_mark_door
    state: open
action:
  - service: notify.pushover
    data:
      message: Mark's Garage Door is Open
      title: Mark’s Garage Door is Open
      target: iphoneX
  - service: cover.close_cover
    metadata: {}
    data: {}
    target:
      device_id: 9c711d42908828ea852e8cf5241a6286
mode: single

@markw 's approach works if you want to close the door if it’s open at 22:00. although using above 1 instead of state==open isn’t necessary. but what i think you’re asking for is to do it only if the door has been open for 30 minutes.

the problem with your original code is that you’ve written it with the mindset that you’re saying “if it is open for 30 minutes between 21:30 and 23:59” but that’s not how triggers work. triggers fire when your trigger changes from not-true to true. ie. if it BECOMES true during 21:30 to 23:59 that the door has been open for 30 minutes then trigger. so that does not work if, at 20:00 it is open… so at 20:30 it *becomes true that it’s open for 30 minutes"… that means at 21:30, it doesn’t become true… .it stays true… which does not trigger.

the code above triggers a check at 21:30… note that if the door was open at 21:15, it will not close until 21:45… because at 21:45, it becomes true that it has been open for 30 minutes…

I think you’re duplicating effort between your trigger and the condition. I think the trigger should just be to fire the automation at 21:30. Then the conditions in his case would be a state of door is open, and it’s been open for more than 30 minutes.

I’ve run my automation for years with a zwave relay/hacked liftmaster remote and just received a ratgdo today and was setting it up. I did try state of open and it didn’t work, but I may have done it wrong. In developer mode I found current_position was exposed and was anything from 0-100 with 100 being open and 0 being closed. Not sure where it flips from closed to open, that’s why I went with above 1.

alias: Garage Door Open - Mark’s
description: ""
trigger:
  - platform: time
    at: "21:30:00"
condition:
  - condition: state
    for:
      hours: 0
      minutes: 30
      seconds: 0
    entity_id: cover.ratgdo_mark_door
    state: open
action:
  - service: notify.pushover
    data:
      message: Mark's Garage Door is Open
      title: Mark’s Garage Door is Open
      target: iphoneX
  - service: cover.close_cover
    metadata: {}
    data: {}
    target:
      device_id: 9c711d42908828ea852e8cf5241a6286
mode: single

my triggers are not redundant. your automation won’t catch the case if it was opened at 21:15

open should work. i can’t comment on what went wrong in your scenario, but if you want to figure it out, i’m happy to help. i have a ratgdo and i trigger on open. best to start a new thread b/c it’s a different topic than this.

I think I figured it out, I had the previous cover in there, just went back and re-tried it with open and it works.

If the door is opened at 21:15, the 21:30 time trigger will be true, but the “for 30 minutes” will be false. Are the triggers an or, or an and? I need to refresh on this, it’s been awhile since I’ve written an automation.

triggers are “or” (any one trigger needs to become true)
conditions are “and”'ed together (all of the conditions must be true)

but your example has only 1 trigger and 1 condition, so that’s irrelevant right?
the state condition as written in your example is 1 condition (open for 30 minutes) not 2 conditions (open and 30 minutes)