Turn on for a specific time

Hi,
there is a feature I’m missing from my previous home automation system: I’d like to turn on a light only for a specific time, choosing it during the activation.

For example, when going to bring out the trash, I’d like to choose “turn on the porch light for 10 minutes” so I’m sure I will not forget to turn it off when I’m back home. The same feature would be useful in the climate component (I’m going to shower, set the temperature to 26°C for 30 minutes then back to the previous temperature).

I’m aware this can be done with delay in scripts, but that would mean to replace every light/switch with a script, and the interface to set the time with sliders is not really nice and tidy.

This is my ugly example of GUI, just to illustrate the concept

45

I use this automation, it’s not quite what you are asking but might get you there.

# frontdoor_timer:
- alias: Front Light Timer
  trigger:
    platform: state
    entity_id: light.front_door
    to: 'on'
    for:
      minutes: 5
  action:
    service: homeassistant.turn_off
    entity_id: light.front_door

Thanks for your answer, but if I read it correctly this will:

  • have the time fixed in code and not user selectable
  • always turn off the light after 5 minutes, no option to turn it on indefinitely.

I’m surprised the feature I’m asking for is not already in HA, as I had it even in a 15 years old home automation with a 2x16 green lcd screen controlled with a numeric keypad (Leviton Omni)

The automation is set for five minutes, that is correct. It was just an example, not a solution. You could set automations to turn it on for five minutes or ten or whatever. I never need it for more than five minutes and it is generally triggered by my phone connecting to wifi when I get home.

How you trigger it by considering under what circumstance you want different timings can be used to set which automation is fired. You could manage this by conditions depending on time and day of the week, or you could use input booleans.

I have a wifi button that can be used to toggle my front door light, this automation just turns it on if it is off, or off if it is on. With the timer in place it will never stay on for more than five minutes though.

You might have better luck with appdaemon depending on the specifics of what you want to achieve.

You can use an input slider to set the timeout duration from the frontend

I found the use of the input slider, but that would mean

  1. manually setting up an input slider and an automation for each entity -> lot of code
  2. clutter the interface with lot of seldom used components

Maybe there is a way to show the slider only in the detail card, when an entity is selected? (as in my photoshopped example)

For that, have a look here. Couple it with the input slider approach, and you’re sorted.

Alternatively, my approach is to have an automation that turns on the outside light when the door is opened, but it only turns the light off if the door is left open for more than 8 seconds (controlled by a slider). Otherwise, the lights are then turned off when the door is next opened and closed, or more than 10 minutes have passed (also controlled by a slider).

Neither slider is changed often, the defaults are set to be what works 99% of the time for us.

You’d need to create a custom UI element for that.

Came here hoping there was a solution :(. Deff a good feature request tho. Automations are great but when things are kinda last minute it would be great to have a timer or snooze button built into the cards

1 Like

So my initial thoughts are;

Create an automation that tracks the light.on, waits 15 and turns it off.
Then two buttons which both turn the light on but one enables the automation and the other disabled it, may need a group or script or could just be done through Lovelace possibly.

It’s an early work in progress for me but I’ve got the logic on paper, just need to put it into practice.

My thinking is just 2 buttons, off / on and on for 15 mins. Can’t see a way around 2 buttons for 2 tasks.

1 Like

Using a heat mat that melts snow, which is tied to a zwave switch…basically whenever the switch gets turned on, this triggers an automation that sets a two hour delay before it turns the switch off…works perfect!

automation:
alias: +heattrak
description: “”
trigger:

  • platform: device
    type: turned_on
    device_id: 5de8225c54dffd8916b9bd0e2b690042
    entity_id: 847a41e7de2ec07f6dcc2edf68c519ca
    domain: switch
    condition:
    action:
  • delay:
    hours: 2
    minutes: 0
    seconds: 0
    milliseconds: 0
  • type: turn_off
    device_id: 5de8225c54dffd8916b9bd0e2b690042
    entity_id: 847a41e7de2ec07f6dcc2edf68c519ca
    domain: switch
    mode: single
1 Like

This has very little to do with my feature request, it’s just a basic automation.

What I was describing was a mean to apply on the spot the same logic (turn on and then off again after x time) to any entity with any duration without having to build a specific automation for each one.

Kid is still playing in the garden? Turn the garden light on for 1 hour. Making up for a dinner outside? Turn the porch light on for 4 hours. Very hot day? Turn on irrigation for 20 minutes.

1 Like