Using a Input Number Helper in an Automation

I’m struggling to use my input number helper in an automation.
My code, without the helper:

type: turn_on
device_id: 043be102073357fea2a6f8c365b7dde5
entity_id: be965d45d28e76fd5258a1eae3f1d6fd
domain: light
brightness_pct: 15

I want the brightness percent to be a value from a input number helper.
I think it should be like:

type: turn_on
device_id: 043be102073357fea2a6f8c365b7dde5
entity_id: be965d45d28e76fd5258a1eae3f1d6fd
domain: light
brightness_pct: "{{states('input_number.step_led_bright_brightness') | float}}"

But that won’t let me save it

Message malformed: expected float for dictionary value @ data[‘brightness_pct’]

What have I got wrong?

Thanks

Device actions do not support templating, you will need to use the light.turn_on action.

action: light.turn_on
target:
  entity_id: light.YOUR_LIGHTS_ID_HERE
data:
  brightness_pct: "{{states('input_number.step_led_bright_brightness') | float}}"
1 Like

Instead of:

{{states(‘input_number.step_led_bright_brightness’) | float}}

maybe try:

{{(states(‘input_number.step_led_bright_brightness’) | float)}}

Also be sure to take advantage of Developer Tools → Template. You should put code snippes there to see if they work when you run into these kinds of issues

Almost right, except for a common mistake I frequently make myself: brightness and brightness_pct are ot the same thing. The attribute is range 0-255:

action: light.turn_on
target:
  entity_id: light.YOUR_LIGHTS_ID_HERE
data:
  brightness: "{{states('input_number.step_led_bright_brightness') | float}}"
2 Likes

I see I was the one making the mistake. I thought the brightness was derived from another light, but the input helper was originally meant as a percentage. In that case @Didgeridrew was right in the fist place, with the input number range to 100.