Input_select.set_options not remembered after restart

Hi all,

I’m using the input_select.set_options to store some data but after a restart, all values are gone.

I’ve added the input_select.diepvries (the EntityId) to the recorder in the hope that it would be retained. Any idea what I’m doing wrong?

Thx!

It’s temporary only and doesn’t survive a restart. But you can add another trigger to your automation:


  trigger:
    - platform: homeassistant
      event: start

I’m preferring a custom event zu ensure that HA has been completely started before automations will be executed:


automation:

- id: homeassistant_start_delay
  alias: homeassistant_start_delay

  trigger:
    platform: homeassistant
    event: start

  action:
  - delay: 
      seconds: |
          {{ states('input_number.homeassistant_start_delay') }}

  - event: homeassistant_start_delay

and in the automation that sets the input select options:


  trigger:
    - platform: event
      event_type: homeassistant_start_delay

  action:
    - service: input_select.set_options
      data:
        options: |-
          {% set phrase =  ['…', 'Aus'] %}
          {% set x = state_attr('light.lounge', 'hue_scenes') %}
          {{ phrase + (x if x is not none else ['N/A']) |list |sort }}
      target:
        entity_id: input_select.szenen_lounge

1 Like

Hmmm, I’m in need of something that is not temporary and thus survives a restart. I also don’t know the values on homeassistant start as they are updated along the way via the dashboard.

I’ll look into the custom component var then.

Please post your code that sets the options.

It’s a custom card that I’ve created: see Custom card: Freezer Management.

I set the options as follows:

    saveContentsToHass() {
		const contentsToHass = this.parsedContents
			.map(x => `${x.potContents} || ${x.potNumber} || ${x.potCompartment} || ${x.potDate} || ${x.potIsoDate}`)
			.filter(x => !x.includes('|| / || / || /'));
		if(contentsToHass.length > 0) {
			this._hass.callService("input_select", "set_options", { entity_id: this.input_select_helper, options: contentsToHass });
		} else {
			this._hass.callService("input_select", "set_options", { entity_id: this.input_select_helper, options: [`${this._label('freezer-empty')} || / || / || / || /`] });
		}
	}

Well, I’m out :wink:

If you instead store it into an array property on HA, then you can use a list-card installed through HACS to display tabular content.

I do something similar by publishing the container contents as an array to an MQTT sensor. So mine looks like this:
image

I also integrate with Google Home, which is why I ended up “removing” containers 1, 2 and 4 because Google confused them with words (won, too, for). And I don’t have enough “1” stickers to spurge on an “11”.

In Dev Tools it looks like this:
image

The list-card config for this is:

type: custom:list-card
entity: sensor.containers
title: ''
feed_attribute: containers
columns:
  - title: ''
    field: id
  - title: ''
    field: size
  - title: ''
    field: value
  - title: ''
    field: date_short

I blanked out all the titles because I know what the columns are and wanted to minimize scrolling on my phone.