Automation to switch on an entity for set amount of time

Hello,

I have an automation configured with Node-Red wich activates a fan for a set amount of time when a button is pressed.

I would like to migrate this automation to the native HA-automations but don’t find the solution on how to configure this timer.

So what I want to achieve:

Press Button → Fan turns on for time x → Fan turns off again

Any help would be great!

The most bulletproof way to implement this is to add a timer helper. This will ensure that if HA restarts while your automation is running, then your fan will stop once HA come back online.

The way to do it is to create a timer helper named fan. Then, create an automation with 2 triggers, one for the button press and the other for the timer state turning to "idle". Make sure you assign a TriggerID for each of these triggers (eg. button press & fan timer idle).

Skip the conditions section, then use a choose in your actions section & create 2 options:

  • When triggerId is button press, turn on fan and start timer.
  • When triggerId is fan timer idle, turn off fan.
2 Likes

Thanks for your advise! Eventually I found the “Blocks” tab which I did not recognise before and which has a build-in wait action which I assumed must be in there somewhere! I am fine with that as it is not super crucial to stop the fan at any time.