Using Time of Day to select a Pattern

How can I have PixelBlaze select a pattern based on the time of day?

Sorry if there is an answer already out there but my searches have found nothing so far.

Maybe there is a library function already built into the device, or perhaps it can be achieved via Firestorm. Either way has anyone any code or pointers?

Hello!
The time of day functions were added recently. Right now, you can get to them in the code, but there isn’t a feature in the interface to switch patterns based on it. It is possible by combining multiple effects in the same pattern, then using logic in the pattern itself to switch.

It would also be possible to script with Firestorm.

How many patterns do you want to switch between?

Ok, thanks. Your suggestion to switch effects within one pattern was really what I was expecting and would be fine. If you could point me at the functions needed that would be really helpful.

In terms of the number of patterns the answer is I don’t know yet. First though would be a null effect (nothing happening) then turning on another active effect (pixels alight) mid afternoon until say midnight. If I could get something simple like that running it would be useful for coffee bar interiors and windows.

You can delegate out in the render function. Add a check there for the time within some range, and call one function or else another. Something like:

if (clockHour() > 21 || clockHour() < 5)
  doAfterHoursRender()
else
  doDayTimeRender()

And you can chain them in else-if to get sections of the day, like this:

if (clockHour() > 23 || clockHour() < 5)
  doNightRender()
else if (clockHour() < 12)
  doMorningRender()
else if (clockHour() < 18)
  doAfternoonRender()
else
  doEveningRender()

How does the PB know what time it is? Does it check with a time server online? If so, what would clockhour return if it was offline?

Pixelblaze gets the time in reply to the discover service given the timezone configured in settings. If Pixelblaze can’t sync the time after a restart, it will be midnight jan 1, 1970. Checking the year would let you know if it has synced clocks yet.

1 Like