I wanted to create a piston for automating all of the lights in my house. But I wanted something that could be run at any time of day and it will set the lights to their proper settings. I also wanted something easy to modify and understand. Many of my smart bulbs are OSRAM Lightify bulbs, when they lose power, they default back on to 100% brightness and 2700k white temp. And at least a couple times a week…a light switch gets flipped and messes up those bulbs. So I wanted something that could not only automate the bulbs, but also restore them to where they should be based on time of day.
The “wait” functions are there to ensure that Webcore has plenty of time to set the value of the variables and doesn’t run into any race conditions. Some have pointed out to me that setting the same variable multiple times in quick succession could cause issues. Since I don’t care how long this piston takes to run, the wait times seemed like a good solution.
Here’s what I came up with.