Today is Monday, 6th February 2012

“How Do I…” create a snooze button

So it’s a rainy afternoon and you want to take a nap. After this write up all you need to figure out is how long you want to snooze and how do you want to be woken up.

I hope you’re ready because we are going to implement a lot of other “How Do I…” write up’s in this one write up. When we are done we will have created a wakeup agent, a popup on a touch screen, tap variable, and a press and hold. We need to create a number variable first. Pull up composer HE and select agents at the bottom left. At the top left select variables and below that hit new. I’m going to call it Snooze and make it a NUMBER variable.

While we are in the neighborhood also create a BOOLEAN variable which I will call SnoozeStop.

Now we need to create a timer. We do this by staying under agents at the bottom left, but at the top left select timer. Underneath that select new. I’m going to call it Snooze Timer and make the interval 10 minutes. The time here represents the increment that the snooze button will increase by. For example we will press a button and for me it will increase my snooze time by 10 minutes for each press. This will make more sense as we go on.

Alright, now that we have our agents created, we need to decide how we want to trigger this program. I’m going to use a button on a 6 button in my living room. There is a touch screen above this which isn’t required, but I’m going to show you how to make use of this touch screen.

Now on the bottom left side of composer go to programming, above that (device events) scroll down to the button you are going to use. Below that, since it’s a 6 button I need to select which button, in my case 6, then select “press”.

On the top right side (device actions) scroll down all the way to variables, then hit the + sign beside it to expose all your variables. Select the number variable we created “Snooze”. Below that select the 3rd radio button and put a + in the first field and 1 in the field next to it. Now drag this command to the middle pane (script).

Now at the top right select the boolean variable-SnoozeStop. Below that select “set to true”. Drag this to the middle pane (script) also.

When I go to sleep, I like it to be quiet so I also but in a line of code to turn the room off. At the top right (device actions) select the room name we are snoozing in and then below that select “turn the room off”. Drag this command to the middle pane (script).

Here is what the middle pane (script) should look like now.

Time to go back to the far left middle pane below “device events” and select “release”.

At the top right (device actions) scroll down to the boolean variable SnoozeStop and below that select “set to false”. Drag this to the middle pane (script) and this is what it should look like.

Under device events scroll down to “timer”. Below that select the timer we created in the drop down box “Snooze Timer”. Below that select “when expires”.

On the right top side (device actions) scroll down to our Snooze Variable. Below that select the 3rd radio button. Beside that change the field to a negative sign and beside that make the field a 1, then drag to the middle (script).

Now at the bottom right select the conditional tab, then select the first radio button. Make the first field equal and the second 0. Drag this to the middle pane.

This next step depends on what you want to wake you up. There are a few ways you could go about this. You could use the announcement agent and play a wav file with an annoying buzzing sound or message saying GET UP. You could select a source for the room you are in to turn on (lights/video/music). You can also create a wakeup agent which essentially selects the sources you would want to turn on. I created a wakeup agent called “Snooze Wakeup” which turns on my xm radio to a fairly loud volume and the lights to 100%. If you need a refresher on creating a wakeup agent CLICK HERE. So on the device actions side I select “wakeup”. Below that I select Snooze Wakeup, then below that select the room I’m snoozing in-Living. Drag this on top of the conditional in the middle pane so that it indents underneath it.

On the right side (device actions) go to programming control and select “Stop”. Drag this on top of the conditional also. This will cause the program to stop here since the variable has hit zero which means you want to wake up. If the variable still hasn’t hit zero we need to tell the timer to reset so at device actions select timer then select Snooze Timer. Tell it to reset and drag this to the middle pane. Here is what it should look like now.

Under device events scroll down to the Snooze variable. The only option below it is When snooze changes and the radio button is already checked for us. Under device actions go to programming control and select a delay of 2 seconds, then drag to the middle pane. This delay gives us time to press the 6 button a number of times to increment our snooze time however high we want it. Remeber we set it in increments of 10 minutes so each button press within the 2 seconds will add 10 minutes to the time before our snooze wakeup agent executes. Now under device actions go to the SnoozeStop variable. Select the conditional tab and select “is true” and drag this to the middle pane. Go to the the Snooze variable under device actions and below that choose set value to 0. Drag this on top of the conditional statement in the middle pane. Go to timer at the top right, below that select the snooze timer and tell it to “stop”. Drag this on top of the conditional statement too. Now go to programming control and select stop and drag it on to the conditional statement. This part of the program tells the snooze to cancel and stop doing anything below it if SnoozeStop is true. The way to make SnoozeStop true is to press the 6 button and hold it for 2 or more seconds based on the programming we have done so far. You can add another line before the stop command if you want an audio or visual cue. You can create an announcement to play something like snooze has been cancelled. You could have the led light change to a color of your choice and then have it reset on the release of the button. Or you can create a pop up message on a touch screen which is pretty sweet. To do that, on the top right side (device actions) I scrolled down to my touch screen. Below that scroll down and select the show popup radio button. Below that put in whatever text you want to see. I entered “Snoozing has been turned OFF”. I then selected the Clear after box and put 20 seconds. I also chose the show OK button so I could clear the message if I needed to before the 20 seconds expired.

Here is what the middle pane looks like so far

On the device actions pane select the snooze variable and select the conditional tab. Select is equal to 0 and drag that to the middle pane. Then indent the programming control command stop on top of this. Next we need to “reset” the snooze timer. Reset not only increases the timer back to it’s original amount, it also starts the timer. Now we can add several conditionals to account for the number of button presses and give a visual/audio message to allow us to confirm that we set the right snooze time. I’ll show you a screen shot of the final part of the programming though your’s might look different if you choose to to use a visual/audio cue at all.

hope you enjoyed
pharmdsmith

Share

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Leave a Reply


You must be logged in to post a comment.
Top