I have code like that above but instead of hardcoded value of 100% and 50% I want yo use value stored in input_number.bedroom_lights_brigtness and half of that value.
So before the lights is dimmed I need to read brightness of that light, sotre into helper and dim it to half of that brightness.
When motion is detected I need to restore brightness to the value stored in that helper.
I haven’t used it myself as I have hardcodwd values but there is a service called: scene: create. It’s function is to create a temporary scene with the brightness/color of your light.
If you use this, just before the lights will dim, you can then re-apply it to restore the original brightness.
Please give it a try in the developer tools to understand how it works. Then you can apply it in your automation via a call service
Only thing left to figure out is how to store the initial brightness before the automation even starts, otherwise on motion it will restore light to brightness level stored in the helper on previous run.
One solution could be to run separate trigger every time brightness of those lights changes that will store actuall brightness into input helper. But this will also rewrite my stored value even when the brightness is changed within the original automation.