Automation code review help

Hello everyone. Seeking feedback I am getting started in automations and have written an automation that seeks to accomplish the following:

At 11pm every night, if the garage door is open, then close the garage door.

I would appreciate any feedback on this or ideas on a more graceful way to accomplish. Thanks

- id: '1622382545400'
  alias: Night Security Close Corvette Garage
  description: Closes Corvette garage at 11pm every night
  trigger:
  - platform: time
    at: '23:00:00'
  - platform: device
    device_id: 78c6f54c16e5790a129d27fb5725ebea
    domain: cover
    entity_id: cover.abington_corvette_garage
    type: opened
  condition: []
  action:
  - device_id: 78c6f54c16e5790a129d27fb5725ebea
    domain: cover
    entity_id: cover.abington_corvette_garage
    type: close
  mode: single

cover.abington_corvette_garage should not be trigger, it should be condition.
Otherwise as soon as the garage opens it will close again.

- id: '1622382545400'
  alias: Night Security Close Corvette Garage
  description: Closes Corvette garage at 11pm every night
  trigger:
  - platform: time
    at: '23:00:00'
  condition:
  - platform: device
    device_id: 78c6f54c16e5790a129d27fb5725ebea
    domain: cover
    entity_id: cover.abington_corvette_garage
    type: opened
  action:
  - device_id: 78c6f54c16e5790a129d27fb5725ebea
    domain: cover
    entity_id: cover.abington_corvette_garage
    type: close
  mode: single

Thank you! I understand/agree and have made the change. Looking forward to a live test tonight.

- id: '1622382545400'
  alias: Night Security Close Corvette Garage
  description: Closes Corvette garage at 11pm every night
  trigger:
  - platform: time
    at: '23:00:00'
  condition:
  - condition: device
    device_id: 78c6f54c16e5790a129d27fb5725ebea
    domain: cover
    entity_id: cover.abington_corvette_garage
    type: is_open
  action:
  - device_id: 78c6f54c16e5790a129d27fb5725ebea
    domain: cover
    entity_id: cover.abington_corvette_garage
    type: close
  mode: single

Well if you change the trigger time then it can happen now.

1 Like

good point :slight_smile: