How to turn on switch at 6:00am the 2 days after turned off


#1

1) Give a description of the problem
I have a couple of ‘things’ in my basement I need to physically about every other day. Example: clean/change kitty litter. I created a virtual switch in ST, wrote a piston that triggers when the switch is turned off. I can get it to wait 48 hours.

2) What is the expected behavior?
What I would like is for the switch to turn on at 6:00 am the day after it’s turned off. Ex: Switch off at 4:15pm Saturday, turn on at 6:00 am Monday.

3) What is happening/not happening?

4) Post a Green Snapshot of the pistonimage


#2

I am not able to write code at the moment, but this is roughly what I would do:

If Switch changes to off
Then Set variable CatBox = 1
End if

Every day at 2am
Set variable CatBox = CatBox+1
End every

Every day at 6am
If CatBox is greater than or equal to 3
Then Turn on Switch 8
Set variable CatBox = 0
End If
End every

#3

try this:


#5

I like this, takes into account the Switch being turn on manually. But, if I don’t turn off the switch until the next day, i.e. skipped a day, then the 2am code would have set CatBox to 1, indicating the Switch was turned off, when it is still on. Could only increment CatBox if greater than 0.


Every Day at 2am
If CatBox is greater than 0
Then Set Catbox = CatBox + 1
End If
End every


#6

You are right. The variable would start counting up from 0 even if you missed the cat box…
My logic was, the switch was still turned on when you wanted, and stays on until you turn it off.
(at which time, the counter is reset)

In other words, there would have to be five days worth of :poop: for inaccuracies to show up…

But your tweak makes sense as well.


#7

I have both pistons running. I’ll try for a week or so to see if there are any unintended side affects.