Irregular system info brightness check


I was creating a button system for controlling the screen brightness by linking an automate flow that controls the brightness to a click event. I wanted the corresponding buttons to change color based on if the brightness level is the same that the buttons change it to.

So for example, I have a button that changes the brightness level to 50%. Once I press the button, the brightness of the screen changes, and therefore the formula for checking the brightness -

$if(si(system, screen_brightness)=129, gv(color-1), gv(color-2))$ *129 is the brightness value of 50%

- should update the value to the global variable color-1. The problem however is that it doesn't. When I press the button, it stays the variable it was before the brightness changed. I can tell that everything is working, as locking and unlocking the phone refreshes the wallpaper. The problem is that the value doesn't update until I do that.

Thanks in advance!