Timer option for light and switch entities?

Hello, i’m comming from FHEM to HA and have already migrated a lot of devices and automations but there is one function that I really miss.

in fhem i could optionally add a timer (on-for-timer) to each light or switch while switching.

sometimes i don’t want to switch on a device for so long and it’s practical if i can do this directly when switching.

I haven’t found anything about this anywhere

Well you can automate that.

1 Like

Ok, and how?

For example, the garden light. When it is switched on normally, it always stays on until I switch it off again. When I take out the garbage, I want it to stay on for 5 minutes, or 6 minutes, or maybe 10… And because I might have plans, I would like it to stay on for 34 minutes. I want to decide how long it should stay on when I switch it on. and that for every switch or light.

maybe theres a custom lovelace card out there? any suggestions?

for better understanding, in FHEM that options where default for every switch or light entity without creating automations or timer manually:

Screenshot 2024-05-25 063234
Screenshot 2024-05-25 063300
Screenshot 2024-05-25 063332

I’m missing this function on the lovelace cards

By leveraging what HA is built for: automations. I understand you want some convenience function, but this kind of thing becomes unmanageable over time, overloading the UI with too many builtin possibilities.

Is your use case really as simple as that? The problem always comes in with the exceptions, which then makes it different for every user. Next up someone wants the timer only if it’s under some condition, etc. And as you pointed out, you want different timings.

So, the simple answer here is: you make an automation that triggers on the state of the light and start a timer. A second automation will trigger on the timer’s finished event and turn it off.

but the name tells me that he wants to assist me :wink: anyway, we cloud leave that as a feature request and maybe some other user miss that feature and will vote for it.

How do you plan to turn this light on?
My assumption would be an automation … Simply add to that automation an action to ‘wait for a time’ (delay) then another action to turn the light off.

Also in your prior system, how did you tell the system it was a light you wanted to stay on for a while and then turn off?
My assumption would be pick some kind of mode that it needs to shut off and pick a time when that activates.

Same thing…

As Pieter said, you can also add an automation that triggers anytime that light comes on, starts the delay, then shuts the light off as well. Same but different trigger.

Things in HA are done with automations, scripts, and integrations as opposed to what you are used to.

Since this functionality is already there, there is very little chance that it will be changed in core.

1 Like

Automation is not a solution if you want the delay to be configurable at the moment of turning a switch or light on. What you want is a script with a field. Then when you run the script, it will all you to fill the field, which in this case should be time. In the script the field is used to specify the delay before turning off the light or switch. You can add the script entity to a card in the dashboard and that’s how you then run it.

1 Like

Just want to add that a timer’s duration can be templated with the start event. This isn’t clear from the official docs (I’ve come across this a number of times, I really must submit a PR for the docs). You can find more info and examples here: Data template in timer duration.

So:

  1. Script taking a parameter, passing the duration to the timer start event. You can add the script e.g. to an entity card. I’m not sure whether a modal will pop up asking for the parameters.
  2. An input datetime helper and a button your UI. A script can automatically use the helper’s value. This makes it configurable and gives you a default.
  3. An automation using a helper when turning on. Allows for a single, but configurable duration.
  4. An automation using for: with the trigger to turn off. (Can for be templated? I can never remember.)
  5. An automation/script with preconfigured durations and conditions to make the appropriate selection.
1 Like

Hi, that was a default functionallity of a switch or light entity. Like “on” or “off” or set a dimmer value, you can set it with on-for-timer as an integer input. no need to care for a timer automation.

i was thinking about a card like thermostat control were you can set time instead of temperature und home assistant automaticly handle this as a timer job…

i’ve seen that and i made this already as a workaround but as i said before,i don’t want to worry about timers or helpers if i want to switch on any socket or light for just a few minutes from time to time. My children often tell me to leave the light on for a while, then I set the light to 5 minutes and it goes off automatically

Then you picked the wrong platform, I guess.

1 Like

In that case a script attached to a button to turn on a light, delay, and turn off is probably your best bet.

In my case, I have a number of lights with timers, and I didn’t consider it a big deal to have timers for those, since it’s not a feature of all of my lights at home – only certain ones. Normal tap turns it on, and double tap turns it on with a timer – and I can visualise that a timer is running, which is actually important to me to know.

1 Like

I am also looking for a timer functionality, a simple on/off timer on a light. Set it to on at sunset and off at midnight for example.
When looking at Domoticz, you can set timers on just about anything: lights, switches, scenes, etc. I don’t think this overcrowds the UI. Putting the menu item for a timer in the “three dot” menu of a light doesn’t seem to be that problematic? It won’t overcrowd the basic UI. I am kind of surprised HA doesn’t have this feature.

It does, it’s called automations.

1 Like

You don’t need a timer for this. Just make an automation that triggers on sunrise and sunset. Depending on which triggered, you turn the light in or off — in a single automation. It’s just some clicks in the UI. With a bit of YAML you can do this in an even more digest way if you’re able to use templates.

Requests like these will tend towards UI bloat, because there’s a large number of “trivial” things like these that would be expected. The other problem is that people soon realise they want more, in which case the basic functionality isn’t enough. This means, basic functionality basically only helps new starters.