Light Template Variables

I’m reading the docs for setting up a light template and I’m having a hard time with the Brightness variable.

        set_level:
          service: script.theater_lights_level
          data:
            brightness: "{{ brightness }}"

Is there an example of script.theater_lights_level that can be referenced so I can see the syntax of the script the template is calling? The template is passing the user input as a variable “brightness”, I assume?

In my script.brightness I have it like this:

 - type: turn_on
    device_id: X
    entity_id: light.theatre_sconces
    domain: light
    brightness_pct: "{{ brightness }}"

Getting error:
Script Unavailable, Actions: expected float for dictionary value @ data[‘brightness_pct’]

I was going to setup a value template on the script, but it just seems like my syntax is simply wrong.

Device actions do not accept templates, use a Call service action in your script.brightness.

  - service: light.turn_on
    entity_id: light.theatre_sconces
    brightness: "{{ brightness }}"
1 Like

Thank you Didgeridrew, that was it. I needed to do some math on the value, but it’s working. Here’s the yaml in case others are searching:

  - service: light.turn_on
    data:
      brightness_pct: "{{ (brightness / 255 * 100)|int }}"
    target:  
      device_id: X