I have 2 input_select
helpers defined in YAML (“bedroom” and “patio”) to track the last called preset for each area. The “bedroom” helper has hardcoded options. For the “patio” helper I have an automation that runs at HA startup that assigns this input_select
values from an external source using input_select.set_options
(have also tried running it in the script right before the helper value is set). An input_select
is not allowed to be defined without options so I have one dummy option defined called “n/a”. The issue I am having is that any time the input_selects.yaml config file is reloaded the “patio” helper loses it state and becomes “Unknown”, even though the “bedroom” helper and other helpers with hardcoded options all save their states. I am not sure why this is happening. Is there a way to continue using input_select.set_options
to dynamically pull the options for the helper and still have the state save after a config refresh? I realize since all the ‘chosen_preset’ values are all known, I could hard code the helper, but I want to understand how to use input_select.set_options
in this context if possible.
input-select.yaml
bedroom_last_scene:
name: Bedroom Last Scene
options:
- n/a
- neutral
- warm
- warm_dim
patio_door_last_preset:
name: Patio Door Last Preset
options:
- n/a
Startup automation:
- id: '1678681584776'
alias: HA - HA Startup Tasks
description: Actions to execute when HA boots
trigger:
- platform: homeassistant
event: start
condition: []
action:
- alias: "Set preset options for Patio Door Light from WLED"
service: input_select.set_options
target:
entity_id: input_select.patio_door_last_preset
data:
options: "{{state_attr('select.patio_door_lights_preset','options')}}"
mode: single
Script:
patio_door_lights_on:
alias: Turn on patio door led strip
description: Turn on patio door WLED strip to calculated preset
variables:
#The null values are because I haven't created the presets yet but none of those cases are true right now anyway
chosen_preset:
'{% if states(''sensor.season'') == "spring" %} null
{% elif states(''sensor.season'') == "summer" %} null
{% elif states(''sensor.season'') == "autumn" %} null
{% elif states(''sensor.season'') == "winter" %} Icy Twinkle
{% else %} null
{% endif %}'
sequence:
#Save the chosen preset name to the helper
- service: input_select.select_option
target:
entity_id: input_select.patio_door_last_preset
data:
option: "{{chosen_preset}}"
#Apply the chosen preset to WLED
- service: select.select_option
target:
entity_id: select.patio_door_lights_preset
data:
option: "{{chosen_preset}}"
mode: single