I found this simple solution to dim the screen with AppleScript macbook pro - Dim screen brightness of MBP, using AppleScript (and while using a secondary monitor)? - Ask Different
I want to go all the way down and then up one step so I modified the suggested script to
tell application "System Events"
repeat 16 times
key code 109 -- darker
--delay 1 --doesn't really help
end repeat
--delay 5 --doesn't really help
key code 113 -- brighter
end tell
but the solution is not stable. Looping 16 times usually just goes approximately halfway and key code 113 regularly doesn’t seem to register at all. I have added delays, even long delays (5 seconds) but it still is unreliable, especially if you run it using Screen Sharing (in Script Editor).