I solved this by downloading an app called night screen. Make sure the do not change system brightness option is unticked.
open