Using Home Assistant 0.92.2 (hassio on RPi3B+), using Developer Tools, Templates:
When my TCL Roku TV’s input source is YouTube, I see expected behavior,
but when the input source is HDMI 3 (ARC), I see unexpected behavior.
Do I have to escape the parentheses and/or spaces within the string, HDMI 3 (ARC) ?
In this case, delimiting HDMI 3 (ARC) with single or double quotes isn’t the issue.
It would appear that maybe, just maybe, there may be more here than meets the eye. It’s a long-shot, what if the source attribute contains a trailing space when it’s HDMI 3 (ARC).
Just to eliminate this silly possibility, change your template so it will help reveal any unseen white space.
Converting the string to its hex equivalent is a great idea … but I don’t know how to do that with Jinja2. Python string methods like hex() and decode() don’t appear to be supported.
This one has me stumped. I’ll bet it’s something simple, just non-obvious (to me).
I manually invoked a Roku REST API command to my TCL Roku TV to see that the
return value, HDMI 3 (ARC), doesn’t contain plain spaces, but rather HEX C2 A0 which is a non-breaking space.
On my Mac OS keyboard, I can produce that by pressing Option-Space.
I replaced each space in my is_state_attr() template with a non-breaking space and the comparison succeeded.