Input_select: service to add/remove an option

Hi all,

would it be possible to have a service that allows adding and removing an option to an input_select entity? Currently there’s only a service to set options which will overwrite the existing ones.

background:

  • I have set up a folder watcher
  • automation detects new files in that folder
  • automation shall add new filename to selection
  • template sensor creates an url which points to the new file
  • a custom-ui state card displays that link clickable
    So, in the frontend I can choose a file from dropdown and below appears the url to access the file

I tried to workaround, but this seems not to work: (any hint appreciated)

- service: input_select.set_options
  data_template:
    entity_id: input_select.datasheet
    options: >-
      {{ states.input_select.datasheet.attributes.options|replace("]", ", '" + trigger.event.data.file + "']") }}