Dynamically Create input_select on Startup

I have a custom python script to create an input select, that script I am running on startup using an automation:

  - alias: HA Startup
    trigger:
      platform: event
      event_type: homeassistant_start
    action:
      - service: shell_command.startup  
      - service: script.turn_on
          entity_id: script.reloadconfig
      - service: notify.notifyall
        data:
          message: HASS Started.

What I am finding is that the input_select is loaded before the script can run so if there are changes to the input_select they are not shown until the next reboot.

I tried adding an HA script to run on a 3 minute delay after startup but I found that the reload_core_config service does not reload the input_select.

Does anyone have a good way to do this? Am I missing something obvious here?

If I understand correctly, the shell_command,startup creates the select and the script.reloadconfig populates it. Try adding a delay between the shell_command.startup and the script.turn_on.

  - alias: HA Startup
    trigger:
      platform: event
      event_type: homeassistant_start
    action:
      - service: shell_command.startup
      - delay:
          seconds: 10 
      - service: script.turn_on
          entity_id: script.reloadconfig
      - service: notify.notifyall
        data:
          message: HASS Started.

@kylerw Did you found a solution to this?

I haven’t found a good way to do it. It looks like we may be getting natively support for favorites/playlists by the looks of the PRs so I’m holding off for now.

It is possible to set from next release: https://github.com/home-assistant/home-assistant/pull/5630

2 Likes

@Danielhiversen this is really cool I have been looking for this but haven’t found anything in the documentation. Would this work with any list? For example a JSON-imported one? Are there any examples of this running with dynamic data?

I am using it here: https://github.com/Danielhiversen/home-assistant_config/blob/master/custom_components/switch/gmusic.py#L140

Ok, so it’s for custom components, not Yaml-configurations? That’s why the syntax was so different :slight_smile:

I tried to do this automation aswell, but it doesn’t work because the variable reads as a string, not a list.

  action:
    service: input_select.set_options
    data_template:
      options: "{{states.www_files.dirs.attributes.content}}"
      entity_id: "input_select.playlist"