Templating issue (with spaces?)

Working on a template for detecting what is on my roku device. I have a larger template but boiled down my issue to the following.

The two lines below should who the source and then use is_state_attr to check the source.

{{ state_attr("media_player.bedroom","source") }}   
{{ is_state_attr("media_player.bedroom","source",'Roku') }}

The output when the source is Roku, as expected is:

Roku
True

However, I turn on the Roku and my cable box and it fails:

{{ state_attr("media_player.bedroom","source") }}   
{{ is_state_attr("media_player.bedroom","source",'Cable box') }}

returns

Cable box   
False

For some reason the comparison to the word Cable box seems to fail.

when you do this, paste the following in Developer tools → Template and post the output here

{{ state_attr("media_player.bedroom","source") is string }}
{{ state_attr("media_player.bedroom","source") is string }}
{{ state_attr("media_player.bedroom","source") }}   
{{ is_state_attr("media_player.bedroom","source",'Cable box') }}

OUTPUT:

True
Cable box   
False

It seems to have to do with the space, if i rename Cable box to just cable it works. But I dont want to do that on all the tvs.

this code returns True on HA 0.107.7

{{ is_state_attr('automation.debug_change_default_log_level', 'friendly_name', 'debug: change default log_level') }}

what’s your setup?

Running on Hassio, 0.107.7.

I think the problem in not in is_state_attr, cannot reproduce it

{{ is_state_attr("binary_sensor.1st_floor_bathroom_extractor_fan_node_status", "friendly_name", 'Cable box')}}

prints True

Try cutting and pasting this into the template editor:

{{ is_state_attr('media_player.bedroom', 'source', 'Cable box') }}

Tom, I played with different quotes here and still was unable to reproduce the issue.
Can’t see anything else in the code that might be wrong :frowning:

The only thing I noticed was the mixed use of single and double quotes. While that should work in the template editor it will play havoc with a single line template.

I know, but apparently TS uses it in a bug chunk of code

so it’s very unlikely a single line template but I may be wrong here :wink: