Dynamic Facade and the Sun

Hello world, i work on a dynamic facade with electrochromic glasses.Can someone help me with how i can make the opacity of the glasses to change in relation to the sun so i can maintain a stable light inside the building. Thank you in advance