Why is fields data not working in state condition? What do i miss?

Hello everyone

This is my first post. I’m new to HA but I already have a little experience. I have started experimenting with fields in scripts.

I have a script with following field:

station:
  name: Station
  required: true
  selector:
    text: null

Everything is working but the while condition, so it iterates forewer:

repeat:
  sequence:
    - service: media_player.select_source
      data:
        source: "{{station}}"
      target:
        device_id: 65fb746534c743de4577c0c80205976c
    - delay:
        hours: 0
        minutes: 0
        seconds: 1
        milliseconds: 0
  while:
    - condition: not
      conditions:
        - condition: state
          entity_id: media_player.kuche
          attribute: media_channel
          state: "{{station}}"
enabled: true

While this example is working:

repeat:
  sequence:
    - service: media_player.select_source
      data:
        source: "{{station}}"
      target:
        device_id: 65fb746534c743de4577c0c80205976c
    - delay:
        hours: 0
        minutes: 0
        seconds: 1
        milliseconds: 0
  while:
    - condition: not
      conditions:
        - condition: template
          value_template: "{{ state_attr(\"media_player.kuche\",\"media_channel\") == station }}"
          alias: media_channel == station
enabled: false

I could not find out, how to use sation field in state condition. Is someone here who can explain this or link me to the correct doc?

Many thanks in advance and best regards

So the error points to the while condition.
Take that code plug it into something simpler and make sure it works. Replace the variable with a real value and test different scenarios. Maybe plug it into the visual editor and see what it does with it. Does the attribute need to be there? think about what you need and eliminate everything else. Also, I have not always been successful, however I thing a condition that looks for something is a bit easier to manage than a condition that looks for a not.

General comments I know, but it’s how I would attack it.