Using templating variables within extensions like is_state?

Is it possible to use templating variables within the extensions, like so?

{% if is_state({{ trigger.to_state.state }}, ‘on’) %}

I can’t seem to make it work that way.

1 Like

Did you try

{% if is_state(trigger.to_state.state, ‘on’) %}

Cheers

Hi, yes I did.

I think I ran into a similar problem but was not able to find a fix for it. Couldn’t you use it without the is_state? just

{% if trigger.to_state.state == 'on' %}

Cheers

When using is_state, both the entity and the value should be in quotes, single or double:

{% if is_state(‘trigger.to_state’, ‘on’) %}

You can’t include .state when using if_state, because if_state is already looking at the state value of the entity referenced! so you just use the entity_id, you only use the .state when using the method @PhyberApex mentioned:

{% if trigger.to_state.state == ‘on’ %}

1 Like

Thank you, that worked perfectly!

1 Like