Building Dynamic timer helpers

In Home Assistant can we create a template automation that can enumerate all lights or switches and based on the labels on them create a dynamic timer helper to turn off the light, switch or fan when the timer finishes, Any ideas?

This would allow a single automation to control duration values for any number of entities and the labels would be an easy way of making custom durations.

It would be helpful to get some more context about what you want to actually do. Something like, if a light with a given label is turned on, have it turn off some time later, where the time is dependent on the label? It’s not impossible, but that specific mechanism would probably require you to bend over backwards to implement.

Yes.

There’s no action to create a new timer entity (only actions to control an existing timer entity) so an automation or script cannot create one.

That’s exactly my point and wanted to know if anyone had found a way to use anything out there, like Spook or alike or custom code to create dynamic helpers.

Feel free to browse through HACS to find a custom integration that adds something like a “timer.create” action (I have not seen such a thing).


NOTE

I searched the forum and found nothing on the topic of dynamically adding timer entities (other than your post).

Thank you for your clarifications, I hope the HA developers add the ability to create dynamic helpers.

You could do this by having an automation trigger every minute, enumerate your lights, etc. and check how long they’ve been on for, before taking the appropriate action. No timers needed.

Yes we can run on an aggressive polling schedule and enumerate every device type in question, the key is to use the labels to determine the length of allowed time to progress in the automation action.

For example if label is 30 Minutes, 90 Minutes or other time value, then based on label take action to proceed changing ON state of enumerated device. (Aggregating in to a single global Automation)

I will model this automation and see if this will allow me to have a global approach to have a quick way to manage so many multiple lights/switches/fans and not have so many automations for each device. I already use AUTO ENTITIES in my dashboards to dynamically show me all devices for each type that are either ON (Lights, Switches) - RUNNING (Fans) - OPEN (Doors, Valves).

I am not a fan of having so many automations for simple on and off or multiple options, always look to choice logic for single automation to handle any number of options and using trigger IDs and the like.

You can effectively annotate any entity with additional attributes via your customisation options (like customize.yaml). That way, you can set a preferred timeout for each entity (something that you’d need to do anyway).

New solution :slight_smile:

There is now an action in Spook

This card will help you see / visually manage the timers. Maybe I’ll expand it to allow you to create timers also.. hmmm…

I wonder if that would survive a restart.

If you check the box with that option… then yes

Thanks, I missed that with my first read.