Circadian Lighting Piston in webCoRE


I really appreciate this piston. It does exactly what I need. I also encountered what KiloWatts was discussing with the lightTemperature giving a sawtooth pattern in the afternoon. I dumped the formulas into a spreadsheet and figured out that it was a simple error. The calculation within the “Time is before sunset” IF section for (@lightTemperature) should be

(({hourSunset} - {$hour24}) * {lightTemperatureIncrementAfternoon}) - (round($minute / 5) * {lightTemperatureMinuteIncrementAfternoon})+{@lightTemperatureMin}

The formula in the original code added the lightTemperature by minute increment instead of subtracting it. This caused the lightTemperature to go up slightly until it hit the hour where it dropped. Hope this helps everyone.


I have also imported this Piston today and set my lights. Keeping all else without changes.Error:

An error occurred while executing the event: java.lang.NullPointerException: Cannot get property ‘v’ on null object.

Please see Image.

Any assistance will for sure be appreciated! :slight_smile:


For some reason (probably because of Tuya complications), my lights didn’t work well with the Circadian Lighting smart app. So I cobbled together a simple one that basically triggers every time a color bulb goes on and sets the temp based on a curved sale from max (sunrise) to min (sunset). Seem to be working so far. Here are the variables:

Basically, if the time is after sunset up to an hour before sunrise, I just use min temp. Sunrise to sunset, it uses a curved scale from max down to min. Not really circadian, I realize, but works well so far for my needs.


(I used 2600 as the min and 5700 as the max)


thanks, that was exactly what i needed. I thought i was going crazy watching the lights change between 4-6 pm every day!


Hi thanks for the post. I’m probably missing something but the OP shows

{@lightTemperatureMin}, global integer variable - the minimum light temperature you want to use for sunset->sunrise. I use 2237. lowest reasonable amount would be 1900.

But this variable is not found in the variable section. I did find this variable further down used in line 49, but it’s undefined.

Is there a bug in the code? Please help newbie question. Thanks. :slight_smile:


Hey Bob, I’m looking for a simple way to change the color temp of my lights during the day. Your approach is a little more detailed and advanced even than what I had in mind - I’ve only just created my very first piston in webcore. But I would like to try creating it like yours. Would you be willing to share your piston’s import code with me/the forum?