I felt like this should work, but I’m not seeing the icons in my sensors in the UI. Any tips
security_system_state:
value_template: '{{ states.input_select.security_system.state }}'
friendly_name: 'Security System'
icon_template: >
{% if is_state('states.input_select.security_system.state', 'Disarmed') %}
mdi:home-lock-open
{% elif is_state('states.input_select.security_system.state', 'Armed (Home)') %}
mdi:home-lock
{% elif is_state('states.input_select.security_system.state', 'Armed (Away)') %}
mdi:security-lock
{% else %}
mdi:help
{% endif %}
dionmaas
(Dion Maas)
May 24, 2018, 10:15pm
2
Looks fine to me. Are you sure that you’ve reloaded HASS, and maybe tried to clear the cache of your browser?
Or use the settings to check your config, maybe something pops up there?
The only icon that is appearing is the mdi:help, and even that only shows if I click on the sensor, I was hoping the sensor would show the icon in the circle
dionmaas
(Dion Maas)
May 25, 2018, 12:09am
4
Have a look at this:
Hi,
I’m trying to use a dynamic icon template for a template sensor. The config is the following:
- platform: template
sensors:
multisensor_chambre_batterie:
value_template: '{{ states.zwave.multisensor_chambre.attributes.battery_level }}'
friendly_name: Batterie
unit_of_measurement: '%'
icon_template: >
{% if states.zwave.multisensor_chambre.attributes.battery_level|int < 20 %}
'mdi:battery-alert'
{% else %}
…
Basically it comes down to this:
Try putting a dash (-) after/before the % in the statement. That cleans up the spaces in the jinja code. I find more consistent results with dashes:
icon_template: >
{%- if states.zwave.multisensor_chambre.attributes.battery_level|int < 20 -%}
mdi:battery-alert
{%- else -%}
mdi:battery
{%- endif -%}
You also have a quote at the endif which seems odd.
No difference. Hmm,
security_system_state:
value_template: '{{ states.input_select.security_system.state }}'
friendly_name: 'Security System'
icon_template: >
{%- if is_state("states.input_select.security_system.state", "Disarmed") -%}
mdi:home-lock-open
{%- elif is_state("states.input_select.security_system.state", "Armed (Home)") -%}
mdi:home-lock
{%- elif is_state("states.input_select.security_system.state", "Armed (Away)") -%}
mdi:security-lock
{%- else -%}
mdi:help
{%- endif -%}
I also tried double quotes as shown above. No change. Maybe does not work with input select?
dionmaas
(Dion Maas)
May 25, 2018, 12:42am
6
Is the state needed after "states.input_select.security_system.state"
? I’m not sure but I think I remember not adding that when I was wrestling around with the state of input_selects.
Good call, almost there
security_system_state:
value_template: '{{ states.input_select.security_system.state }}'
friendly_name: 'Security System'
icon_template: >
{%- if is_state("input_select.security_system", "Disarmed") -%}
mdi:home-lock-open
{%- elif is_state("input_select.security_system", "Armed (Home)") -%}
mdi:home-lock
{%- elif is_state("input_select.security_system", "Armed (Away)") -%}
mdi:security-lock
{%- else -%}
mdi:help
{%- endif -%}
Works but not as I expected, when I click on the item I see the mdi icon now, but still not here.
Probably something I’m misunderstanding.
Looks like I need to look into
entity_picture_template:
Not sure I want to take the time to grab local images for these. Thanks for the tip about removing state though.