Is there a way to create a bi-weekly schedule?


1) Give a description of the problem
I have my son every other week from Wednesday to Tuesday, I would like his light to behave like a night light (dimmer set to 5%) but only on the days that he is here and from 8pm to 6:15am and begin to increase in brightness at 6:15am when his alarm goes off. (but only brighten mon-fri)

2) What is the expected behavior?
To be able to create a piston with a start date IE Wednesday Jan 10 selecting Wednesday Thursday Friday Saturday Sunday Monday and repeat every other week on those days.

3) What is happening/not happening?
I don’t know how to select every other week vs 1st week 3rd week of the month which will get out of sync.


What you could do is create a variable.
Increase that variable by one every week.
Then use the variable in an IF statement.
IF variable is even do something.

Here is a piston that doesn’t do anything for me but I’ve kept as an example in case I need it.
Should give you an idea of how to set up a variable to increase by 1 every week and you can then use week = odd or even in your own piston for it to run or not.


Cool, that should work.

So that piston is both counting up the variable and executing the action?


The THEN IF (if the variable is even), turns switch 13 on and increases the variable by 1. If ODD nothing happens here.
The ELSE IF (if the variable is odd), turns switch 13 off and increases the variable by 1. If EVEN nothing happens here.
In this case the piston triggers at 18:00 on Mondays.
This is just an example piston that I have kept for myself so that I remember how to do it.
I don’t actually use this piston to do anything.
Just incorporate this principle into your piston.


So I took your core concept and made what I believe will work.
I broke out the Increment week and used a global variable since I need this piston to run almost every day, and I may use the increment week in other pistons.

I’m still getting the hang of webcore, so this is just an example of what I did, and it’s likely not the best way to do something like this, IE in the increment week I couldn’t delete the turn on/off commands or the whole group disappears, if this piston actually works I’ll clean it up.

Thanks again!!


For anyone who is looking at doing this I built on the above solution but used a global variable which simply goes from true/false at midnight on Monday. Same result, different way of doing it…


Sorry for the delayed post. I somehow missed this conversation the first time around.

Here is another method that works very well, and is quite reliable. Even if the hub/internet is down at the time of execution, it will re-sync properly the next time it runs. Basically, it checks to see what “week in the year” it currently is, and then depending on whether that number is even or odd, it sets {activeWeek} to either true or false.


(I realize I could reduce this to a single line of code, but it helps to see it written out fully)


For those curious… Here is one way to do it all in a single line of code.


  • If the “weekOfYear” is even, it returns “true”
  • If the “weekOfYear” is odd, it returns “false”

For those who like a mathematical puzzle…
Do you see how I was able to determine if it is an even or odd number?