Trigger for 60 minutes

hi,

I looking for trigger a switch for 60 minutes after a specific time.

The following automation is working but it’s 2 differents automation :

- alias: 'Cafetière'
  trigger:
    platform: time
    at: '20:19:00'
  action:
    - service: switch.turn_on
      entity_id: switch.cafetiere

- alias: 'eteindre cafetiere'
  trigger:
    platform: state
    entity_id: switch.cafetiere
    to: 'on'
    for:
      minutes: 60
  action:
    service: switch.turn_off
    entity_id: switch.cafetiere

There is any way to make just one automation like (it's not working) : 
- alias: 'Cafetière'
  trigger:
    platform: time
    at: '20:19:00'
  action:
    - service: switch.turn_on
      entity_id: switch.cafetiere
      for:
        minutes: 60

thank you

Have a look at scripts for that sort of thing. I don’t do much with them so can’t give you an example.

I use delay for these types of opportunities, as in the example below. 15 minutes after the light is turned on it shuts off, which is what I think you are looking for. Note that I’m using an input_number for those times I want the delay to be longer, but you can replace that with delay: ‘00:60:00’. Hope this helps.

  • id: Master_bedroom_off_after_15min
    alias: Turn the master bedroom light off after 15 minutes
    trigger:
    platform: state
    entity_id: light.master_bedroom_level
    to: ‘on’
    action:
    • delay: ‘00:{{ states.input_number.mbr_light_slider.state | int }}:00’
    • service: homeassistant.turn_off
      entity_id: light.master_bedroom_level

I must be getting tired :stuck_out_tongue: Dunno why I didn’t think of that :stuck_out_tongue:

So…

- alias: 'Cafetière'
  trigger:
    platform: time
    at: '20:19:00'
  action:
    - service: switch.turn_on
      entity_id: switch.cafetiere
    - delay: '00:60:00'
    - service: switch.turn_off
      entity_id: switch.cafetiere
1 Like

What happens if there is a reboot during the delay? Is HA smart enough and will still continue the script, or the coffee machine will stay powered on indefinitely?

As far as I know, it’s a crash and burn situation :rofl: in other words, until someone pushes the off button it won’t shut off unless you have a power outage… :thinking: