Turn coffee machine off after 3 hours

I have a Tasmota connected to my coffee machine but sometimes I forget it on. Is there a way to shut it down after being turned on for a period of time?

There’s a for: option with a state trigger.

This is my automation, exactly for this:

- id: rocket_stop
  alias: Rocket stoppen
  trigger:
  - entity_id: switch.sonoff_rocket_relay
    for: 03:00:00
    platform: state
    to: 'on'
  action:
  - data:
      entity_id: switch.sonoff_rocket_relay
    entity_id: switch.sonoff_rocket_relay
    service: switch.turn_off
2 Likes

Thank you both!

Before trying the script from @paddy0174 I opened up the automation UI and could set it up really quickly without any typing:

You know that you can do “both” with automations? Mine is set up via UI as well, and this is the code, that was generated in automations.yaml. I just go into automations.yaml afterwards and change the id from the numerical one to a “readable id”. In fact you can paste this simply into your automations.yaml save and reload automations, and then find it in the UI to make changes. :slight_smile:

Yes, but I thought I had to manually enter the script and copy/paste the entity id. Almost all my other automations cannot be properly edited from the UI (such as demultiplexers), but this one works a treat.