I was checking through the logs and I found an error was occurring after reloading all configuration:
Referenced entities select.hall_lighting are missing or not currently available
Its occurring because I have an automation that is trying to set (write to) a template select.
And the ordering is unclear between the initialization of the template select and the trigger conditions for the automation.
I did try updating configuration.yaml to move the automations include to the bottom of the file:
automation: !include automations.yaml
However that didn't seem to help, so I ended up changing my automation to wait for the select to become ready, i.e.:
actions:
- repeat:
for_each: "{{ active_setting }}"
sequence:
- wait_template: "{{ has_value(repeat.item.selector) }}"
timeout: "00:00:5"
continue_on_timeout: false
- action: select.select_option
metadata: {}
data:
option: "{{ repeat.item.value }}"
target:
entity_id: "{{ repeat.item.selector }}"
Where repeat.item.selector is the select.abc to be updated.
That approach works but it feels a but kludgey to simply halt the automation waiting for the control to be ready.
I considered some other options, I could:
- Change the automation to directly update the backing field, behind the select (which breaks the abstraction - of interacting with a select).
- Change the template select, to an input helper select (the dumb version), but that loses some functionality.
TL;DR - I have three ways of solving the problem, but I don't like any of them for various reasons.
Is there a official/standard way of ensuring that automations / controls load in specific order so that they are available before they are used?