Ok, i want to be able to choose a light from a dynamically generated list of lights present, then have an automation use that entity I’d within itself. I think I can tackle the second part once I get there, but I’m trying to get the first half working.
I’m guessing I’ll need an input_select, and one automation to populate it, then one to use it, the first one might be as simple as using an automation triggers with a data_template that cycles through all of the available entities.
Input selects can currently not be filled dynamically. They get their values at startup. That’s probably a show stopper for w/e you planned to do right there.
I was under the impression that data_templates on one line needed to be enclosed in single or double quotes, per https://home-assistant.io/docs/automation/templating/ “You must surround single-line templates with double quotes (”) or single quotes (’)."
if i take out the quotes, I get the following error:
found character ‘%’ that cannot start any token
in “/config/packages/alarm_clock.yaml”, line 61, column 21
I don’t think they were meaning to get rid of the quotes, I think they were pointing out that the formatting was off and that you needed to consider checking where both the quotes and commas were placed inside of your template.
Try something on this order. (Note - this is completely untested, but it follows the docs on how to set up the input_select utilizing the set_options) "{% for state in states.light -%} "{{ state.entity_id }}", {% endfor %}"
I think this will get you closer to a working template to use in your automation.
all in one option (and in the template editor:
“light.dining_room_level”, “light.entryway_level”, “light.ge_plug_dimmer_level”, “light.hall_level”, “light.kitchen_level”, “light.lamp_bulb_1_level”, “light.master_bathroom_level”, “light.master_bedroom_level”, “light.master_closet_level”
But i can’t figure out how to put those on separate choices…
sadly that just puts it all in the same element in a different format:
- light.breakfast_nook_level - light.dining_room_level - light.entryway_level - light.ge_plug_dimmer_level - light.hall_level - light.kitchen_level - light.lamp_bulb_1_level - light.master_bathroom_level - light.master_bedroom_level - light.master_closet_level
if i past in th output of the template: [{% for state in states.light -%}"{{ state.entity_id }}"{% if loop.last -%} {% else %}, {% endif -%}{% endfor %}]
which is:
([“light.breakfast_nook_level”, “light.dining_room_level”, “light.entryway_level”, “light.ge_plug_dimmer_level”, “light.hall_level”, “light.kitchen_level”, “light.lamp_bulb_1_level”, “light.master_bathroom_level”, “light.master_bedroom_level”, “light.master_closet_level”])
and got the correct info showing up in the input_select, but i still can’t make it work as a data_template.