It seems the Android API for accessing screen brightness has been broken in the past few Android version, where input and output values aren't within documented/specification ranges resulting in unexpected brightness.
Sadly, the unexpected values seems to differ with device making a workaround difficult.
However, an alternative is to use the
System setting set block with category System, name Screen brightness and a value between 0 and 255, but as said, those may differ on your device, e.g. on my Pixel device it's between 0 and 147.