Template if, elif, not is_state

I have constructed a template to select a result based on the state of two variables. First, I created two variables that were Boolean, i.e. the value can be true or false. I did not find anything in the Var integration that would treat boolean variables in a specific way.
I could never get the template to work properly using the is_state(var, true) construct. I switched to two related numerical variables testing for non-zero values. That didn’t work either despite following the form suggested on various web resources.
The following template uses the numerical variables and additionally I have extracted the variable states as a test method. A screen capture shows the results.

{% if not is_state('var.rising_temp_active',0) %}
mdi:arrow-up
{% elif not is_state('var.falling_temp_active',0) %}
mdi:arrow-down
{% else %}
mdi:circle-medium
{% endif %}

{%set tup = states('var.rising_temp_active') %}
rising {{ tup }}
{%set tdn = states('var.falling_temp_active') %}
falling {{ tdn }}

The template editor interprets results. So a string that looks like a number (e.g. “0”) will be displayed as a number (0) when in fact it is not a number. This is dumb as hell and confuses a lot of people but the devs aren’t interested in changing it.

States are always strings. Only attributes can be other types.

In short your variable states are actually: "0" not 0, try testing for strings rather than numbers:

{% if not is_state('var.rising_temp_active','0') %}
  mdi:arrow-up
{% elif not is_state('var.falling_temp_active','0') %}
  mdi:arrow-down
{% else %}
  mdi:circle-medium
{% endif %}

Thanks for that. Actually, I think I tried that but then the variables were changing based on a time triggered automations, which I eventually disabled but perhaps not coincidentally with the variables being ‘0’.
The thing I tried initially was this:


{% if is_state('var.tempup_trig','true') %}
mdi:arrow-up
{% elif is_state('var.tempdn_trig','true') %}
mdi:arrow-down
{% else %}
mdi:circle-medium
{% endif %}

{%set tup = states('var.tempup_trig') %}
rising {{ tup }}
{%set tdn = states('var.tempdn_trig') %}
falling {{ tdn }}

I suspect testing a boolean in this manner is not allowed as it doesn’t work.

Update: I got this to work. Turns out capitalization matters.