How can I set something turn on and off, based on time, in the same automation?

I have an automation to turn my coffee machine on in the morning, which works fine, but I would like the same automation to turn it off after 30 minutes. Can this be done in the same automation, or do I need a separate one?

- id: '1583445867789'
  alias: aromaboy Coffee Machine
  description: ''
  trigger:
  - at: 06:30
    platform: time
  condition:
  - after: 06:29
    before: 07:00
    condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
  action:
  - data: {}
    entity_id: ' switch.bf296b4f3518e857f8nmac'
    service: switch.turn_on

Yes you can, with a delay. Take a look at the second example in the automation docs

1 Like