Hello,
I’m trying to setup a template select without succes so far. The idea is to be able to customize icon depending on the select state. I have several template switch that work as expected (albeit syntaxt is slightly different), but I can’t even get this template select created (looking at Entities).
select.383 is an MQTT that is working fine.
Code is based on: Template/select, but obvioulsy I’m doing something wrong.
Running 2022.4.1
Thanks for any help on this matter
In configuration.yaml I’ve got
template: !include templates.yaml
And in templates.yaml, I’ve got
- select:
- name: "Sèche_serviette_gui"
unique_id: 383_1
state: "{{ states('select.383') }}"
options: "{{ state_attr('select.383', 'options') }}"
select_option:
service: select.select_option
target:
entity_id : select.383
data:
option
icon: >
{% if state == 'Off' %}
mdi:radiator-off
{% elif state == "On" %}
mdi:radiator
{% elif state == "Eco" %}
mdi:radiator-off
{% elif state == "HGt" %}
mdi:radiator-off
{% elif state == "HG" %}
mdi:radiator-off
{% elif state == "1H" %}
mdi:radiator-off
{% elif state == "2H" %}
mdi:radiator-off
{% endif %}