bergsm / SunLights

Program to adjust TP-Link smart bulbs with the ambient sunlight
GNU General Public License v3.0
0 stars 0 forks source link

Algorithm for sunrise and sunset #6

Closed bergsm closed 5 years ago

bergsm commented 5 years ago

The task here is to create the algorithm for modifying the bulb values with the sunrise and sunset. I expect to use cron scheduling is some way.

bergsm commented 5 years ago

Looking into cron scheduling, it looks like I could write a file to the /etc/cron.d directory using python that will be executed by cron at the specified times. I think this would be the simplist way to schedule the sunrise and sunset scripts

bergsm commented 5 years ago

Good news! I found I can set the transition period for the bulb changing very high! There doesn't appear to be a limit. This means, if the lights are on, I can send a command to transition the bulbs over an hour. The only caveat being I'm not sure what will happen if the lights are off, or are turned off during the transition. More experimenting is necessary!

bergsm commented 5 years ago

Setting the transistion period didn’t work thanks to an issue with turning the bulb off while transitoning. However I was able to succesfully implement an algorithm that changes the bulbs incrementally over a period of an hour, broken into 12 commands. This interval is long enough that I don’t have to send a lot of commands, but minor enough to not notice the transition of the bulbs.

See commit 356f59a90758f9be60804ac94698c157fa299264 for the code