Use Template (or similar) in Web Server to Select a Specific Entity

I want to use something like the Text or Number Templates in the web server to provide a drop-down list of onboard entities so I can pick one entity out of the list?

An example or two helps clarify this.

I want to add a delay to a switch, so when the switch goes off, the delay is triggered. Another entity will stay on until the delay is finished. This way, if I turn a device on, another entity goes on and will stay on for a set time after the switch is turned off.

I have 8 entities on this device and would rather not do that many delays, so I want a way, on the web server, to list which switches or sensors will have a delay. To do that, I need to be able to have something like a drop-down list that I can use to pick out one device for use.

Is there a way to list all the entities on an ESPHome system in a dropdown on the web server so I can pick which one I want to use this for?

I don’t know how I missed Template Select when I was looking earlier, but that does provide a drop-down select widget. It looks like the values have to be set in the YAML file and I don’t see how they can be changed or how I can get a list of devices to use for the options.

I’m not aware of a way to populate the select list dynamically or modify the list at runtime.

Perhaps you could copy and modify the component to do what you want but that is beyond me.

https://esphome.io/api/template__select_8h_source

I think, as much as I hate crowding a webpage or device with a truckload of extra entities, and that I can’t do this easily by making an array, I think I’m going to have to go that way - add a template for modifying the value for each entity.

1 Like