I think this statement is equivalent to the two previous statement I posted, or at least, I think they should be. Correct me if I’m wrong.
There seems to be a hidden character somewhere. This state is the output of the LCD of my alarm. I suspect the comparison may be done with a non-printable character. Is there a way to convert:
{{ is_state_attr('sensor.home_alarm_keypad','alpha','DISARMED CHIME\tReady to Arm') }}
Still yields false, but
{{ 'Ready to arm' in state_attr('sensor.home_alarm_keypad','alpha') }}
yield true, so there is a non-printable character after Ready to arm, but it’s not a tab. I don’t care atm about finding out, as I only need either the part before OR after that non-printable character. Therefore, ‘Ready to arm’ in state_attr() works for what I’m looking to do.
If you are curious to know what’s in the whitespace, you can use the urlencode filter. For example, this reveals the whitespace to be a tab character (%09).
There’s no tab. There was one space before the whole string, and two spaces after the whole string, including the three space inbetween. HA doesn’t display spaces before/after:
Now that you know the problem is due to leading and trailing spaces, you can get rid of them using the trim filter.
This screenshot demonstrates how the trim filter eliminates the leading/trailing spaces from the supplied string. urlencode is used only to show that the spaces have been removed.