Wake-up routine trigger (using Execute Piston with arguments to get variable fade time)

conditions
variables

#1

This is how I kick off my morning wake-up routine, or anytime of the day wake-up routine for that matter. Some of the things I wanted to account for include the day of the week, whether or not it’s a holiday (so that I can sleep in) and me actually being there. Also, I really wanted the ability to sometimes start this routine earlier than the normal time, and then not run twice if that happens. Thus this is what I cam up with:

I use a virtual switch which is set in another piston that knows whether or not it is a Holiday, so that way this piston will let me sleep in. I can also control this Holiday virtual switch with the Echo if I’m just taking a day off to stay home. You could use a boolean global variable, but this just makes it easier for the Echo/ST app to also be used to set it.

I also ensure the the Wakeup virtual switch is not already on. That would mean that the full routine has already run…more on that later.

Lastly I check for my presence and if all of those are true then the piston sets the variable for the amount of time I want the lights to fade up and then it calls another piston which actually does all of the work of turning on and off the various lights.

Important note here, this piston has two triggers in it. It responds to Time of day and to a virtual switch changing to on. However, the piston I’m calling does not respond to any Triggers at all. In fact I specifically turn off all event processing in the called piston. That just makes it very simple and clean when executing.

Now let’s talk about the Wakeup switch. I use this switch for two purposes. First if the wake-up time comes around and the switch is already on, then the piston knows that I got up early and so it skips running the routine again, but instead it turns the switch back off so that it’s ready to be used the next time. Secondly I use this virtual switch to actually trigger the full routine but with a different fade time passed to the called piston.

The way I have this setup, I can have the Echo device turn on this virtual switch when I say the command which starts up an Alexa routine. Therefore, I can just say something like “Alexa, start my day” and the Echo device will tell me the weather and then turn on the virtual switch. Since I know I want to get up right away in that case I set the fade time variable on the lights to only 1 minute instead of 20 before calling the other piston.

All in all this works very well for me and it’s quite simple but also flexible. Passing arguments to another piston allows you to reuse the same code, but to also change up the behavior a bit.


Call Piston with Arguments - Need Syntax
How to call one piston from another
Multiple triggers combined with “or” not working
#2

Very nice! Could you share the piston that knows holidays?


#3

Are you using gcal?


#4

Sorry, I’m not doing anything that fancy. It’s really just a Timer piston which I manually setup with the values of the known holidays.

Every night at 12:05 AM
If current day is in the list of Holidays
Turn on Holiday
Else turn it off

That’s all… Easy enough…for now anyway. :slight_smile:


#5

Where do you list your holidays?


#6

Just in a simple string array.