How do you use a variable in a template checking states?

I’m trying to change the color of the icon when the input_boolean is changed using a variable. I know how to do it without using a variable, but trying to learn with variables. I’m sure it’s some simple syntax error.

{% set away = states('input_boolean.away') %}
{% if is_state('away',  'on' %}
 green
{% endif %}

Since you’ve already set away equal to the state of your boolean, you don’t need to use is_state and away should not be in quotes:

{% set away = states('input_boolean.away') %}
{% if away == 'on' %}
 green
{% endif %}
1 Like

@Didgeridrew I knew it was something simple! Thank you so much!