Check if state matches a value from a list

I`m currently merging some automations. I currently have something like:

    - service: script.turn_on
      data_template:
        entity_id: >
          {%- if is_state('sensor.time_of_day_short', 'evening') or is_state('sensor.time_of_day_short', 'late evening') or is_state('sensor.time_of_day_short', 'night') -%}
                 script.xxxxxx

For me it would be logical to use something like this instead:

{%- if 'evening' or 'night' in states('sensor.woonkamer_motion') -%}
    script.xxxxxx
{%- endif %}

It’s working with a single value, but I can’t get it to work in combination with or.
Anyone know how to get this done? Thanks!

perhaps you could use this example I have to check for the state of a media_player

  - condition: template
    value_template: "{{ states('media_player.kitchen') in ['off', 'idle'] }}"
5 Likes

Exactly looking for such a solution! Cheers!
How stupid I didn’t thought of it to use it like that :smiley: