Need help in Blueprint script giving errors

hi
i am trying to make blueprint from script (which is working) but blueprint throwing error can anyone help?

blueprint:
  name: switch light patch
  description: toggle on or off switch of down light
  domain: script

  input:
    switch_trigger_id:
      name: Switch for light
      description: Switch which is connected to Down light
      selector:
        entity:
          domain: switch

    light_trigger_id:
      name: down light
      description:  Down light
      selector:
        entity:
          domain: light

alias: ground_floor_en1
sequence:
  - if:
      - condition: state
        entity_id: !input switch_trigger_id
        state: "off"
    then:
      - type: turn_on
        entity_id: !input switch_trigger_id
        domain: switch
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - type: turn_on

        entity_id: !input light_trigger_id
        domain: light
    else:
      - type: turn_off
        entity_id: !input light_trigger_id
        domain: light
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - type: turn_off
        entity_id: !input switch_trigger_id
        domain: switch
mode: single

Error:
image

Script(working)

alias: ground_floor_en1
sequence:
  - if:
      - condition: state
        entity_id: switch.ff_gbr_sb1_sw3_en1
        state: "off"
    then:
      - type: turn_on
        device_id: d68ed40835cd49d4e198b9ce13fd360e
        entity_id: 2b1a4c796e8a39d5d73e9962697890fd
        domain: switch
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - type: turn_on
        device_id: f7db20a725fcda8b64420972fc364339
        entity_id: 6a0b3bd5f1af8651268718a21288e403
        domain: light
    else:
      - type: turn_off
        device_id: f7db20a725fcda8b64420972fc364339
        entity_id: 6a0b3bd5f1af8651268718a21288e403
        domain: light
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - type: turn_off
        device_id: d68ed40835cd49d4e198b9ce13fd360e
        entity_id: 2b1a4c796e8a39d5d73e9962697890fd
        domain: switch
mode: single

The working script uses devices with device syntax.
The blueprint has all entities which have a completely different syntax, but you tried to copy the syntax over.
Doesn’t work like that.
Different syntax.

Thank you so much for reply

After changing syntax also i am not able to succeed. can anyone help?

blueprint:
  name: switch light patch
  description: toggle on or off switch of down ligh
  domain: script

  input:
    switch_trigger_id:
      name: Switch for light
      description: Switch which is connected to Down light
      selector:
        entity:
          domain: switch

    light_trigger_id:
      name: down light
      description:  Down light
      selector:
        entity:
          domain: light

alias: "ground_floor_en1"

action:
  - variables:
      sw_id: !input switch_trigger_id
  - choose:
      condition: template
      value_template: "{{is_state(sw_id, 'off') }}"
      sequence:
        - service: light.turn_on
          target:
            entity_id: !input switch_trigger_id

image

Is this what you are trying to do?
In yours:

  • That alias isn’t connected to anything
  • You didn’t have a sequence after the inputs
  • You had your switch listed as the light.turn_on
  • Other syntax issues

Also your logic was if the switch goes off, the light turns on and there was a single condition.
Because of the single condition, or because there was a choose statement at all, an automation Blieprint was better suited.
It’s not an absolute rule, but scripts shine when you give them 1 thing to do and make most of the decisions elsewhere. Not a hard rule, but a good one.

blueprint:
  name: switch light patch
  description: Turn on a light when switch is turned off.
  domain: automation
  author: amitja
  input:
    switch_trigger_id:
      name: Switch for light
      description: Switch which is connected to Down light
      selector:
        entity:
          filter:
            domain: switch
    light_trigger_id:
      name: down light
      description:  Down light
      selector:
        target:
          entity:
            - domain: light

mode: restart
max_exceeded: silent

trigger:
  platform: state
  entity_id: !input switch_trigger_id
  from: "on"
  to: "off"

action:
  - alias: "Turn on the light"
    service: light.turn_on
    target: !input light_trigger_id

Thanks for your time and reply, I am trying to call this script from light card as a call service.
Present layout- Zigbee RGB Light bulbs connected to zigbee wall switch.
Logic require:-
When user want to switch ON light bulb from HA - script need to check if wall switch (which is connected to that light bulb) is OFF or ON, if OFF need to switch ON wall switch first than Switch on light bulb or if wall Switch is already ON than just Switch on light Bulb.
if user want to switch OFF light bulb from HA - Script need to Switch off light bulb first than wall Switch.
image

That’s a different question from the script you started with.

You first step needs to be to create a script that does what you want to do. There isn’t enough logic in that which you presented to get there. Once you have a working script you may not need a script blueprint, but if you feel you still do, convert the script to a blueprint.

Creating an automation blueprint - Home Assistant

That is an example for an automation blueprint, but the principal is the same.

Thanks again for reply, working script already made and working fine, i want to make a blueprint because more than 66 bulbs are connected like this.

alias: ground_floor_en1
sequence:
  - if:
      - condition: state
        entity_id: switch.ff_gbr_sb1_sw3_en1
        state: "off"
    then:
      - type: turn_on
        device_id: d68ed40835cd49d4e198b9ce13fd360e
        entity_id: 2b1a4c796e8a39d5d73e9962697890fd
        domain: switch
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - type: turn_on
        device_id: f7db20a725fcda8b64420972fc364339
        entity_id: 6a0b3bd5f1af8651268718a21288e403
        domain: light
    else:
      - type: turn_off
        device_id: f7db20a725fcda8b64420972fc364339
        entity_id: 6a0b3bd5f1af8651268718a21288e403
        domain: light
      - delay:
          hours: 0
          minutes: 0
          seconds: 1
          milliseconds: 0
      - type: turn_off
        device_id: d68ed40835cd49d4e198b9ce13fd360e
        entity_id: 2b1a4c796e8a39d5d73e9962697890fd
        domain: switch
mode: single

I suggest using entities with states and state triggers, but that could work if you are into remembering 32 character hex numbers. I personally find that unusable.
However the script blueprint sequence should look almost exactly like that if it is working. The inputs should be device selectors and the bottom be the value of the inputs.

I’m not used to the goofy device selector syntax, but that is the idea.

Why and how to avoid device_ids in automations and scripts.