Define a global variable based on Day of Week


#1

Hello all 1 day into WebCore and I clearly need some help.

I’d like to set a Global device variable (@Nightlight) to certain lights based on the day of the week. This would allow me to run a number of routines and not if to have write multiple ifs.

So on either Sunday or Thursday @Nightlight should be device A, on Monday and Friday @Nightlight should be device B, etc.

Then at @sunset, turn on @Nightlight.

@Nightlight a Device and the default value set as “nothing selected”.


#2

You can create a piston with a timer for every day and depending on the day, you can then have a task that looks something like:

Every day at XX time
  If $datOfWeek = Sunday or Thursday
    Set variable @Nightlight = [YourDeviceName]   (enter this as an Expression)

You’ll need another statement for the Turn On


#3

Like this?


#4

Looks like it’s gonna work at first glance :slight_smile: All you need is the turn on/set level statement for the time you want… and the turn off