Can pistons be scheduled when mode changes?


#1

1) Give a description of the problem
Trying to understand if its possible to make a piston run when a mode changes.

2) What is the expected behavior?
The intent is to have a light go on when I am “home” after sunset, even if I arrive home after sunset.

3) What is happening/not happening?
I beleive the piston will only run once and not run again when the mode changes from “Away” to “Home”

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)*
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)


#2

BTW, this is my first piston … you can ignore that it is currently set for Tuesday … I was just testing with that time … (I know how to test for Sunset) … also probably dont need the test for power = 0 (that a diff question)

James


#3

Do you set your hub to “Home” and some other mode when you’re not? Or do you use a presence sensor that should be incorporated into this piston to determine that? If the former, all you need is:

IF
[select Virtual Device from the drop down] Location Mode is Home
AND
[select Virtual Device from the drop down] Time is between Sunset and (when you want automation to stop)

THEN
With outlet/switch/device
Turn On

optional - if you want it to automatically turn the light off if you leave or if time progresses beyond the later limit
ELSE
Turn off

If you save this piston, you should see an orange lightning bolt for BOTH IF conditions (like you see in row 18 of the piston in your original post. This means the pistons is ‘subscribed’ to each condition and will execute when there are changes.

It will execute each time your location mode changes (home, away, night, etc.)

It will execute at Sunset (the light will turn on if you’re home, for example), and at the end of the time window you select. At the end of the time window, if you choose to have the piston turn the light off, it will switch off whether you’re home or not since the condition is being home AND time being between sunset and xxx.


#4

Hi michicago -

Thank you, very helpful. I think I’m beginning to understand the subscribing events etc. Yes, I have separate logic to set the mode (various states) … So with the changes shown below my assumption is that the light will go on if I’m home AND its between sunset+15 and 10pm … and light will go off at 10pm OR I am not home (or any other mode) … If that’s correct, does this mean that if I leave, they go off and when I come back, if its still between those hours (and days) then the lights will come back on? Seems yes since new events (mode changes) happened.

Thanks for your help!!


#5

Looks good! You can simplify the latter 2 IF statements though, since the code will only hit the ELSE portion if either of your first conditions are false, all you need is:

IF
Location mode is Home - Evening
And time is xxx
THEN
With Outlet 1
Turn on
ELSE
With Outlet 1
Turn off


#6

Thanks @michicago … but I think we still need the checks … so that during the week (not F, S, S) the lights will turn off after 10 … also … if we turn the lights on manually during the week … we would want them to turn off if we are no longer at home…

Did I get that right?


#7

If either of your conditions evaluate false, the ELSE code will run.

I think the checks are redundant but you can leave them there if you prefer.