Need help for Ceiling Fan script

I got a Fanco Ceiling Fan comes with Lights kit and also replace the traditional switch to Broadlink TC2 switch. Whenever I switch on the main power, the light kit will bright up. This is the default factory setup by Fanco which no way I can reset it unless I switch off the light kit manually.

Fanco comes with 433Mhz Remote that can adjust the speed and lights which works with my Broadlink RM2 Pro as well.

I have written a script for this ceiling fan to
turn on Broadlink TC2, then turn on ceiling Fan speed 2. I can even voice command it via google assistant.

Can anyone advice how can I improve my script to whenever I turn on my fan via script it will check my local time if before 7pm/sunset then turn off the light kit and if after 7pm/sunset the light kits will remain on?

Will appreciate if anyone can guide me to the right path.

Thanks