I am trying to change the icon of my z-wave lock based on the attribute, but it doesn’t seem to recognize the attribute, any ideas?
Config:*
icon_template: >-
{% if is_state_attr('lock.kwikset_unknown_type0003_id0541_locked', 'lock_status', locked_by_rf) %}
mdi:z-wave
{% elif is_state_attr('lock.kwikset_unknown_type0003_id0541_locked', 'lock_status', unlocked_by_rf) %}
mdi:z-wave
{% else %}
mdi:gesture-double-tap
{% endif %}
Output:
Should be showing the zwave icon below:
Attributes:
Copy and paste your template in Dev Tools/Templates und you will see what you get.
If you’re testing for a string, you should put it in quotes.
Also case matters, write the string like it’s shown in the states.
That’s how I came up with the template, unfortunately, the dev tool shows the same output regardless of the case, and produces a error without the underscores.
What about this:
icon_template: >-
{% if is_state_attr('lock.kwikset_unknown_type0003_id0541_locked', 'lock_status', 'Locked by RF') %}
mdi:z-wave
{% elif is_state_attr('lock.kwikset_unknown_type0003_id0541_locked', 'lock_status', 'Unlocked by RF') %}
mdi:z-wave
{% else %}
mdi:gesture-double-tap
{% endif %}
BTW: It doesn’t matter if Locked or Unlocked, you template shows the same icon.
Disregard, that worked, thank you.