Afvalwijzer, search specific word in sensor output

Hi, I use for a example this code for the Next pickup item

      afvalwijzer_next_item_formatted:
        value_template: >-
          {% if is_state('sensor.afvalwijzer_next_type', 'keukenafval,') %}keukenafval
          {% elif is_state('sensor.afvalwijzer_next_type', 'papier,') %}Papier
          {% elif is_state('sensor.afvalwijzer_next_type', 'pmd,') %}PMD
          {% elif is_state('sensor.afvalwijzer_next_type', 'restafval,') %}Restafval
          {% elif is_state('sensor.afvalwijzer_next_type', 'metaal,') %}Metaal
          {% else %}Geen
          {% endif %}
        friendly_name: "Next pickup item"

I tried it on the home assistante help pages → sjabloon and it’s works almost.
Today would there “keukenafval, restafval, pmd” stay.
But the code doesn’t search for individual words. Wenn I changed ‘keukenafval’ to ‘keukenafval, restafval, pmd’ then the sensor output from “Next pickup item”. is “keukenafval”.

So it’s works almost but he doesn’t search for a specific wordt in the part of te output from the sensor.afvalwijzer_next_type

If you want to know if a word appears in a sensor state use this test:

 {% if 'keukenafval' in states('sensor.afvalwijzer_next_type') %}

Thank u Tom.
It’s worked. That live can bee so easy.

Do you now also the answer about this.
3 from the 5 words are in sensor.afvalwijzer_next_type
keukenafval is the first so I see by the afvalwijzer_next_item_formatted the value “keukenafval”.
But PMD and restafval are also in sensor.afvalwizjer_next_type. Can I change the code that de value from afvalwijzer_next_item_formatted is "Keukenafval, PMD, Restafval.

Hi Tom,

I used this to change the words:

sensor afvalvandaag:
  - platform: template
    sensors:
      afvalvandaag:
        friendly_name: "Afval Vandaag"
        value_template: >
         {{ states('sensor.vandaag') | replace("pmd", "Plastic Metalen en Drankkartons") | replace("gft", "Groente Fruit en Tuinafval") | replace("restafval", "Restafval") | replace("papier", "Papier") | replace("textiel", "Textiel")}}

sensor afvalmorgen:
  - platform: template
    sensors:
      afvalmorgen:
        friendly_name: "Afval Morgen"
        value_template: >
         {{ states('sensor.morgen') | replace("pmd", "Plastic Metalen en Drankkartons") | replace("gft", "Groente Fruit en Tuinafval") | replace("restafval", "Restafval") | replace("papier", "Papier") | replace("textiel", "Textiel")}}