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}}"
Background
When you start writing automations, a device trigger seems the obvious choice. Everybody knows what a device is and it comes at the top of the UI dropdown list.
[image]
It works… but it is certainly not a “great way to start” because it is storing up problems for the future. Far better to use an entity, with state or numeric_state.
This topic is part of the community-driven cookbook where you can find other topics you might be interested in or might like to contribute to.
Devi…
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
Edwin_D
(Edwin D.)
July 2, 2025, 3:27pm
4
Didgeridrew:
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}}"
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
Edwin_D
(Edwin D.)
July 2, 2025, 4:06pm
5
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.