Automation not trigerring for Cover (Garage)

I have just included a reed switch on my sonoff and created a cover.yaml file with this config:

    name: "GarageDoor"
    state_topic: "cmnd/2/POWER2"
    command_topic: "cmnd/SonoffGarages/POWER"
    payload_open: "ON"
    payload_close: "ON"
    payload_stop: "ON"
    state_open: "ON"
    state_closed: "OFF"
    optomistic: false
    retain: false

I also have this as a group:

    name: GarageDoor
    icon: mdi:garage
    #control: hidden
    view: no
    entities:
      - cover.GarageDoor

so this first bits work as I have this on my default view:

image

My automation to check if the garage door is open every 10 minutes and close it if it is open does not however work, the config is as follows:

- alias: GarageDoorChecker
  initial_state: true
  trigger:
    platform: time
    minutes: /10    
    seconds: 1
  condition:
    condition: state
    entity_id: cover.garagedoor
    state: open
  action:
  - service: cover.open
    entity_id: cover.garagedoor

Isn’t it case sensitive? in your automation, change cover.garagedoor to cover.GarageDoor.

Also, entity_id’s are generally always lower case. I would change whatever is necessary to make the entity_id lowercase: cover.garagedoor or cover.garage_door. You can see what it is on the States page. And you can try calling the service from the Services page. Lastly, you seem to want the automation to close the door, but you’re calling the cover.open service. That doesn’t seem right. I just checked, and the service I think you want is cover.close_cover.

It might also be indentation and formatting;g. Try this

- alias: GarageDoorChecker
  initial_state: true
  trigger:
    - platform: time
      minutes: /10    
      seconds: 1
  condition:
    - condition: state
      entity_id: cover.garagedoor
      state: open
  action:
    - service: cover.open
      entity_id: cover.garagedoor

Thanks, it was the command cover.open, I changed it to cover.close_cover, it works now, no more concerns about the garage being left open at night or when away. :space_invader::space_invader::space_invader::space_invader:

Yes, that works, the reason I used open is because the relay is indifferent between open and close, but I agree that things should be named accordingly, cover. close_cover works fine, thanks…

Glad to hear it! :slight_smile:

FWIW, you can probably make this automation better. Assuming you want the door to never stay open for more than 10 minutes (which is what your current automation will do), you could do this instead:

- alias: GarageDoorChecker
  initial_state: true
  trigger:
    platform: state
    entity_id: cover.garagedoor
    to: 'open'
    for:
      minutes: 10
  action:
    service: cover.close_cover
    entity_id: cover.garagedoor

This will not only use less system resources (because it only runs when it needs to instead of every 10 minutes), it will let the garage door stay open for exactly 10 minutes (if it’s not closed manually before that.) The way your current automation works, if the door is opened right before the next multiple of 10 minutes, it will close almost immediately. (E.g., say it is opened at 10:09:55 AM. At 10:10:01AM, only 6 seconds later, it would get closed. Probably not what you want.)

Excellent solution, working like a charm.

1 Like