Baffled by a script error with a condition

I don’t understand why I’m getting this error:

Invalid config for [script]: [condition] is an invalid option for [script]. Check: script->script->bedtime_music->sequence->0->condition. (See /config/configuration.yaml, line 12). Please check the docs at https://home-assistant.io/components/script/

I’ve tried copying all types of examples to get the condition right, but they all generate the error. Here is the code.

  bedtime_music:
    alias: "Bedtime Music"
    sequence:
      - condition: state
        entity_id: "{{ bedtime_player }}"
        state: "playing"
      - service: media_player.select_source
        data_template:
          entity_id: "{{ bedtime_player }}"
          source: "{{ bedtime_source }}"
      - service: media_player.volume_set
        data_template:
          entity_id: "{{ bedtime_player }}"
          volume_level: "{{ bedtime_volume }}"
      - service: media_player.play_media
        data_template:
          entity_id: "{{ bedtime_player }}"
          media_content_id: "{{ bedtime_playlist }}"
          media_content_type: playlist

what happens if you change the condition to:

      - condition: template
        value_template: >
          {{bedtime_player == 'playing'}}

I use many of these scripts, so a condition using the template should be fine:

  radio_paused_for_message:
    alias: 'Radio paused for message'
    sequence:
      - condition: template
        value_template: >
          {{states('sensor.intercom') == states('sensor.media_player') }}
      - condition: template
        value_template: >
          {{states(states('sensor.media_player')) == 'playing'}}
      - service: input_boolean.turn_on
        entity_id: input_boolean.radio_paused

as you can see, the template in my full example refers to the entity_id, and not to the state of the entity_id.

This might be the case in your condition also. the state of the {{bedtime_player }} would probably be the entity_id of the selected player, and not the state of that particular entity_id.

getting to the state of that entity_id would then need to be something like {{ states(bedtime_player) == 'playing' }}

Strange. This script that flashes some of my lights if the doorbell is pressed works for me:

flash_lights_purple:
  sequence:
  - condition: state
    entity_id: alarm_control_panel.house
    state: disarmed
  - service: light.lifx_effect_pulse
    data:
      entity_id:
      - light.lifx_mstr_bed_1
      - light.lifx_lounge_middle_left
      - light.lifx_lounge_middle_right
      - light.lifx_kitchen_1
      - light.lifx_kitchen_4
      - light.lifx_bar_1
      - light.lifx_cinema_1
      - light.lifx_hallway
      - light.lifx_deck_front_1
      - light.lifx_deck_front_3
      - light.lifx_deck_front_5
      - light.lifx_deck_front_7
      - light.lifx_deck_side_1
      - light.lifx_deck_side_3
      - light.lifx_ensuite
      rgb_color: [255,0,255]
      period: 1
      cycles: 2
      mode: blink

Try it with a fixed entity id rather than passing a variable.

Thank you very much. The value template worked perfectly.