RVAtom
(Adam)
March 13, 2025, 1:44am
1
I would like to record the current brightness of a light to a helper, and then reduce that number by some amount, and then set the lights to that level.
I am trying to run an action " Input number ‘Set’"
The YAML I have is
action: input_number.set_value
metadata: {}
data: {}
value: {{state_attr('light.living_room_ceiling_fan_light', 'brightness')}}
target:
entity_id: input_number.living_room_light_brightness
I get the error “required key not provided @ data[‘value’]. Got None”
I feel like it worked once, and I don’t know what I changed but it didn’t work again after I tried to go to the next step I had in mind.
NathanCu
(Nathan Curtis)
March 13, 2025, 1:50am
2
Look after the colon after data
That {} structure means null…
Then you have value right after that as it’s sub key. It cant both be null and have a sub key
One or the other. And it picked null. This the error.
2 Likes
RVAtom
(Adam)
March 13, 2025, 2:12am
3
okay so I have deleted the {} and now have this:
action: input_number.set_value
metadata: {}
data:
value: {{state_attr('light.living_room_ceiling_fan_light', 'brightness')}}
target:
entity_id: input_number.living_room_light_brightness
Now I get a new error: expected float for dictionary value @ data[‘value’]. Got None
Based on the developer tools template editor this state_attr should give the result 130.
Your single-line template is not surrounded by quotes. That’s literally template rule #1:
1 Like
RVAtom
(Adam)
March 13, 2025, 2:17am
5
Thanks everyone.
There is something very humbling about doing this stuff.
3 Likes