Automation calling a script with light.turn_on and no entity_ids turns on all lights

Edit: In case anyone else runs into this problem, this is what works:

  g_bright_mode:
    sequence: 
      - service: light.turn_on
        data_template:
          entity_id: '{{ input_light }}'
          brightness: 255
          color_temp: 226 
- alias: Lamp Bright
  trigger: 
      - platform: state
        entity_id: input_select.lamp_mode
        to: "Bright"
  action:
      - service: script.g_bright_mode
        data:
          input_light: 'light.lamp'

Hi,
I’m very new to home assistant and need help understanding why this isn’t working.

I have this script:

g_bright_mode:
  sequence: 
      - service: light.turn_on
        data:
          brightness: 255
          color_temp: 226

and this automation:

- alias: Lamp Bright
  trigger: 
      - platform: state
        entity_id: input_select.lamp_mode
        to: "Bright"
  action:
  - service: script.g_bright_mode
    entity_id: light.lamp

I was hoping to set up multiple automations to set lights to bright mode (or other modes) individually. But the script always calls all lights, not just the one specified in the automation. I also tried:

- alias: Lamp Bright
  trigger: 
      - platform: state
        entity_id: input_select.lamp_mode
        to: "Bright"
  action:
  - service: script.g_bright_mode
    data: 
      entity_id: light.lamp

Still didn’t work.
Is this a limitation of light.turn_on? Does the script have to have the entity_id of a specific light to make it work? Will I need to make a “Bright” script for each light instead?

You need to use a variable in the script,

g_bright_mode:
  sequence: 
      - service: light.turn_on
        entity_id: '{{ input_light }}'
        data:
          brightness: 255
          color_temp: 226

- alias: Lamp Bright
  trigger: 
      - platform: state
        entity_id: input_select.lamp_mode
        to: "Bright"
  action:
  - service: script.g_bright_mode
    data:
      input_light: light.lamp
1 Like

Thank You! I knew I had to be missing something

Ok. It’s not working. Doesn’t like input_light
How do I add input_light in as an option instead of entity_id?
Is it a component?

Think I missed the quotes,

    data:
      input_light: 'light.lamp'

I’m still getting this error for each script when I check the config:
Invalid config for [script]: not a valid value for dictionary value @ data[‘script’][‘g_bright_mode’][‘sequence’][0][‘entity_id’]. Got ‘{{ input_light }}’

Edit: Got it. Change it to data_template in scripts

  g_bright_mode:
    sequence: 
      - service: light.turn_on
        data_template:
          entity_id: '{{ input_light }}'
          brightness: 255
          color_temp: 226