Getting a wildcard value in a state/value in

I have a working Garbage Collection card, that is showing me this card when I need to put out the wheely bin. It has a different card, depending on the collection to be done this week. For instance:

cards:
type: vertical-stack
cards:
  - type: conditional
    conditions:
      - condition: numeric_state
        entity: sensor.afvalwijzer_next_in_days
        below: 2
        above: -1
      - condition: state
        entity: input_boolean.help_afvalwaarschuwing
        state: 'on'
    card:
      type: conditional
      conditions:
        - condition: state
          entity: sensor.afvalwijzer_next_type
          state: dmh
      card:
        ...

However, as the Christmas trees are this week collected on the same day, the state is “dmh, christmastree”. I therefor want to see if at least “dmh” is part of the current state. In essence: “dhm”.

I checked GPT and it gave me the solution below, but HA give an error in the conditions.

  - type: conditional
    conditions:
      - condition: numeric_state
        entity: sensor.afvalwijzer_next_in_days
        below: 2
        above: -1
      - condition: state
        entity: input_boolean.help_afvalwaarschuwing
        state: 'on'
    card:
      type: conditional
      conditions:
        - condition: value_template
          value_template: "{{ 'dhm' in states('sensor.afvalwijzer_next_type') }}"
      card:
        ...

On this forum I found another example using templates, and I would get from that:

      conditions:
        - condition: template
          value_template: "{{ 'dhm' in state_attr('sensor', 'afvalwijzer_next_type') }}"                         

This does not work either.

At this moment in time, I do not see an alternative option. Perhaps somebody here can steer me into the right direction?

That’s not a solution then. You can’t use templates in a conditional card.

You could create a template binary sensor (can be done via the UI now) with the same value_template, then add a condition to the card looking for that binary sensor to be on.

Thank you. Sad to see this was the solution. I am not too fond of unnecessary helpers, especially as they all need to be maintained. I now have to have 3 extra helpers (for dmh, rest and christmastree), and I need to have an automation running to set or unset these helpers, upon the change of the garbage collection status, so I can finally use it in the automation it was meant for. I hope that the template will one day be available in automation too…

Templates are available in automations.