Add a task and make sure to name it.
Add an action to the task code -> run shell.
On the line for command put your terminal command;
echo on >> /sys/class/backlight/panel0-backlight/hbm_mode
Tick the box for use root.
on the line with the "if"
On the first line put the variable %BRIGHT
Tap the center button (probably displays a ~)
Select "Maths: greater than" (will now display a > )
On the second line, enter 230 (* see further down for an explanation)
Back out of the task to save it.
Now create a profile, with the context of event -> display -> display on
Link the task you created above
What this does is each time the display turns on, the associated task will run. But the code will execute only if the display brightness is above the level set. You will need to play with the number to your satisfaction.
On my Pixel 3XL, stock Pie, 237 is actually the highest I've seen brightness go. In theory, 255 is the highest. Other (non pixel devices) have reported an order of magnitude higher. You can view the value of the variable in an alert -> flash action.
If there is a specific app that you will be using, then adding that as a profile context will reduce the number of times the profile will run. Or any other way to narrow down the active condition, maybe a state -> light level context.