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.
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.
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).