I have this automation which set options for my input_select
- alias: input_select_workaround
trigger:
- platform: state
entity_id:
- sensor.octoprint_file_1_template
- sensor.octoprint_file_2_template
- sensor.octoprint_file_3_template
- sensor.octoprint_file_4_template
- sensor.octoprint_file_5_template
- sensor.octoprint_file_6_template
- sensor.octoprint_file_7_template
- sensor.octoprint_file_8_template
- sensor.octoprint_file_9_template
- sensor.octoprint_file_10_template
action:
- service: input_select.set_options
data_template:
entity_id: input_select.file_to_print
options:
- Select
- '{{ states("sensor.octoprint_file_1_template") }}'
- '{{ states("sensor.octoprint_file_2_template") }}'
- '{{ states("sensor.octoprint_file_3_template") }}'
- '{{ states("sensor.octoprint_file_4_template") }}'
- '{{ states("sensor.octoprint_file_5_template") }}'
- '{{ states("sensor.octoprint_file_6_template") }}'
- '{{ states("sensor.octoprint_file_7_template") }}'
- '{{ states("sensor.octoprint_file_8_template") }}'
- '{{ states("sensor.octoprint_file_9_template") }}'
- '{{ states("sensor.octoprint_file_10_template") }}'
When a sensor is empty, an empty box appears as an option in my input select. Is it possible to hide this empty box so it will just show the sensors which are not empty?
The template looks like this:
octoprint_file_1_template:
friendly_name: "Octoprint file 1"
value_template: >-
{% if is_state("sensor.octoprint_file_1", "unknown") %}
{% else %}
{{ states('sensor.octoprint_file_1') }}
{% endif %}