Help with a (simple?) script blueprint

I’m tearing my hair out a bit over where my code issue is with the following blueprint:

blueprint:
  name: Update Status
  description: Change a light color subject to A) lockout, then B) sensor state
  domain: script
  input:
    the_lockout:
        name: Lockout
        description: The light will change only if this input is state OFF
        selector:
            target:
                entity:
                    - domain: input_boolean
    the_sensor:
        name: Input Sensor
        selector:
            target:
                entity:
                    - domain: sensor
    the_light:
        name: Status Light
        description: The light to be changed
        selector:
            target:
                entity:
                    - domain: light
    the_oncolor:
        name: On Color
        default:
        - 0
        - 255
        - 0
        selector:
            color_rgb: {}
    the_offcolor:
        name: Off Color
        default:
        - 255
        - 0
        - 0
        selector:
            color_rgb: {}

conditions:
  - condition: state
    entity_id: !input the_lockout
    state: "off"
if:
  - condition: state
    entity_id: !input the_sensor
    state: "on"
then:
  - action: light.turn_on
    metadata: {}
    data:
      !input the_oncolor
    target:
      entity_id: !input the_light
else:
  - action: light.turn_on
    metadata: {}
    data:
      !input the_offcolor
    target:
      entity_id: !input the_light

I am able to begin creating a script with it, but when I save I get the error “Message malformed: extra keys not allowed @ data[‘conditions’]”

The script is supposed to simply assign a color to a light based on a sensor state, but only if a lockout helper is set to off.

Help please!

I’ve also tried using an If/Then (directly copied from the yaml of a script) for this (top section unchanged):

if:
  - condition: state
    entity_id: !input the_lockout
    state: "off"
then:
  - if:
      - condition: state
        entity_id: !input the_sensor
        state: "on"
    then:
      - action: light.turn_on
        metadata: {}
        data:
          !input the_oncolor
        target:
          entity_id: !input the_light
    else:
      - action: light.turn_on
        metadata: {}
        data:
          !input the_offcolor
        target:
          entity_id: !input the_light

And the error changes to “Message malformed: extra keys not allowed @ data[‘if’]”

If/Then is an action… you need a sequence key to to start the action sequence and you need to use the correct selectors… target and entity are not directly interchangeable.

blueprint:
  name: Update Status
  description: Change a light color subject to A) lockout, then B) sensor state
  domain: script
  input:
    the_lockout:
        name: Lockout
        description: The light will change only if this input is state OFF
        selector:
          entity:
            filter:
              - domain: input_boolean
    the_sensor:
        name: Input Sensor
        selector:
          entity:
            filter:
              - domain: sensor
    the_light:
        name: Status Light
        description: The light to be changed
        selector:
          target:
            entity:
              - domain: light
    the_oncolor:
        name: On Color
        default:
          - 0
          - 255
          - 0
        selector:
            color_rgb: {}
    the_offcolor:
        name: Off Color
        default:
          - 255
          - 0
          - 0
        selector:
            color_rgb: {}

sequence:
  - condition: state
    entity_id: !input the_lockout
    state: "off"
  - if:
      - condition: state
        entity_id: !input the_sensor
        state: "on"
    then:
      - action: light.turn_on
        metadata: {}
        data: !input the_oncolor
        target: !input the_light
    else:
      - action: light.turn_on
        metadata: {}
        data: !input the_offcolor
        target: !input the_light

Thank you! Now I’m getting other errors, but might be able to figure them out…

You are selecting targets, and usung entities. Not the same thing…

Yes I fixed the target/entity issue after finding a post about it previously. Where I’m at now:

blueprint:
  name: update_status
  description: Change a light color subject to A) lockout, then B) sensor state
  domain: script
  input:
    the_lockout:
        name: Lockout
        description: The light will change only if this input is state OFF
        selector:
            entity:
                filter:
                    domain: input_boolean
    the_sensor:
        name: Input Sensor
        selector:
            entity:
                filter:
                    domain: sensor
    the_light:
        name: Status Light
        description: The light to be changed
        selector:
            target:
                entity:
                    domain: light
    the_oncolor:
        name: On Color
        default: [0,255,0]
        selector:
            color_rgb:
    the_offcolor:
        name: Off Color
        default: [255,0,0]
        selector:
            color_rgb:


sequence:
  - if:
      - condition: state
        entity_id: !input the_lockout
        state: "off"
    then:
      - if:
          - condition: state
            entity_id: !input the_sensor
            state: "on"
        then:
          - action: light.turn_on
            data:
              rgb_color: !input the_oncolor
            target:
              entity_id: !input the_light
        else:
          - action: light.turn_on
            data:
              rgb_color: !input the_offcolor
            target:
              entity_id: !input the_light

Throwing an error about the color data (I believe):

“Message malformed: not a valid value for dictionary value @ data[‘sequence’][0][‘then’][0][‘then’][0][‘target’][‘entity_id’]”

The color is possibly being stored as a string that looks like a list, not a list.
Cast it to a list.
I would add a variable to do that.

Thanks greatly for the help. I’m trying to cast as a list:

blueprint:
    name: update_status
    description: Change a light color subject to A) lockout, then B) sensor state
    domain: script
    input:
        the_lockout:
            name: Lockout
            description: The light will change only if this input is state OFF
            selector:
                entity:
                    filter:
                        domain: input_boolean
        the_sensor:
            name: Input Sensor
            selector:
                entity:
                    filter:
                        domain: sensor
        the_light:
            name: Status Light
            description: The light to be changed
            selector:
                target:
                    entity:
                        domain: light
        the_oncolor:
            name: On Color
            default: [0,255,0]
            selector:
                color_rgb:
        the_offcolor:
            name: Off Color
            default: [255,0,0]
            selector:
                color_rgb:
                
variables:
    oncolorgrab: !input the_oncolor
    offcolorgrab: !input the_offcolor

sequence:
  - if:
      - condition: state
        entity_id: !input the_lockout
        state: "off"
    then:
      - if:
          - condition: state
            entity_id: !input the_sensor
            state: "on"
        then:
          - action: light.turn_on
            data:
              rgb_color:
                - '{{ oncolorgrab.split(",")[0][1:] | int }}'
                - '{{ oncolorgrab.split(",")[1] | int }}'
                - '{{ oncolorgrab.split(",")[2][:-1] | int }}'
            target:
              entity_id: !input the_light
        else:
          - action: light.turn_on
            data:
              rgb_color:
                - '{{ offcolorgrab.split(",")[0][1:] | int }}'
                - '{{ offcolorgrab.split(",")[1] | int }}'
                - '{{ offcolorgrab.split(",")[2][:-1] | int }}'
            target:
              entity_id: !input the_light

And getting a similar error: “Message malformed: not a valid value for dictionary value @ data[‘sequence’][0][‘then’][0][‘then’][0][‘target’][‘entity_id’]”

I’ve tried remaking this as an automation, and using color names instead - I’m still running into an error I don’t undersand:

blueprint:
    name: update_status_automation
    description: Change a light color subject to A) lockout, then B) sensor state
    domain: automation
    input:
        the_lockout:
            name: Lockout
            description: The light will change only if this input is state OFF
            selector:
                entity:
                    filter:
                        domain: input_boolean
        the_sensor:
            name: Input Sensor
            selector:
                entity:
                    filter:
                        domain: sensor
        the_light:
            name: Status Light
            description: The light to be changed
            selector:
                target:
                    entity:
                        domain: light
        the_oncolor:
            name: On Color
            default: green
            selector:
               select:
                    options:
                        - yellow
                        - red
                        - green
                        - blue
                        - orange
                        - purple
        the_offcolor:
            name: Off Color
            default: yellow
            selector:
                select:
                    options:
                        - yellow
                        - red
                        - green
                        - blue
                        - orange
                        - purple

triggers:
  - trigger: state
    entity_id: !input the_sensor
      
conditions:
  - condition: state
    entity_id: !input the_lockout
    state: "off"
    
actions:
  - if:
      - condition: state
        entity_id: !input the_sensor
        state: "on"
    then:
      - action: light.turn_on
        metadata: {}
        data:
          color_name: !input the_oncolor
        target:
          entity_id: !input the_light
    else:
      - action: light.turn_on
        metadata: {}
        data:
          color_name: !input the_offcolor
        target:
          entity_id: !input the_light

Message malformed: not a valid value for dictionary value @ data[‘actions’][0][‘then’][0][‘target’][‘entity_id’]

Is it something in the way I’m selecting the target entity for the light?