Condition if attribute contains string

Hello,

I am looking to set up a condition based on the entity below

I would like the condition to be true if the attribute “ID” contains the string “hamoed”. I have tried the following without any luck.

{{ 'hamoed' in state_attr('sensor.jewish_calendar_holiday_3, 'ID') }} 

which I based on this post

Thank you in advance!

1 Like

Hi

try this

{{ 'hamoed' in state_attr('sensor.jewish_calendar_holiday_3', 'ID') }} 
1 Like

In case you don’t see the difference in PickOne’s template, you missed a quote after ...holiday_3

2 Likes

Thank you! I get an error message: TypeError: argument of type ‘NoneType’ is not iterable

Any idea what caused this? I tried googling it and I am not sure.

@tom_l can you please help with this question?

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#onesix-should-i-tag-people-22

1 Like

Show the YAML code for the automation, template, whatever you’re using, that gives this error.

Also show a screenshot for your holiday sensor (if that is what it is) from Developer Tools / States.

Thank you, will keep in mind going forward

the Yaml is as follows:

{{ 'hamoed' in state_attr('sensor.jewish_calendar_holiday_3', 'ID') }}

Thank you for the help!

A problem is visible though — the attribute you want is 'id' not 'ID'.

1 Like

That was it! Thank you!

So even the pop-up card gives translated attribute keys. :roll_eyes:

Damn, that’s bad.

1 Like