Arming Apartment with Audible Countdown and Light Customizations


#1

I am trying to create a Piston that will be triggered via a Routine called Arm. This Routine is set up to either be executed from the iPhone Widget area or when my presence leaves my home. The Piston has two conditions: Is it inside of my acceptable time range for lights to be on, or is it outside of my acceptable range for lights to be on (If…Else Statement).

When the Routine is triggered (which does show as triggered in the Log for the Piston) the Piston should evaluate the time of date and determine whether it falls within the IF block or the ELSE block. For the sake of testing, I’m currently in the ELSE block (it is morning for me and the IF won’t evaluate to TRUE). The difference, for right now until I get it working and flesh it out, is whether lights are on or not. The common block between the two is a FOR loop that starts with an index of 0, repeats to a value of 20, and steps 1 value per iteration. Each iteration of the FOR Loop should have my Kitch Speaker device say “The apartment will arm in {$index} seconds.” with the exception of the last iteration having a different sentence spoken through the same device (using an IF statement that evaluates the value of $index).

So when I test this by hitting Arm I see in the log the Piston is executed. It takes about 5 seconds for the Piston to have Log activity (but it may be faster than that depending on the refresh rate of the dashboard). Once it registers the trigger all goes quiet. Then, about a minute later, the Kitchen Speaker says “The alarm will arm in 20 seconds.” Now, I know that this is in reverse order of what is expected, but I’m going for simplest functionality first and then I’ll create a variable with expression in the FOR block to have a true “countdown.” Just stick with me here because the expected behavior is that for each iteration of $index it should say a sentence (I need expected behavior to work before I can start setting it up for desired behavior).

Here is my code so far:


#2

First of all, why are you using the Adjust level command? If you want the lights on at 50%, you should issue the Set Level command.

I also have no idea what you expect out of the for $index…are you expecting a countdown of the number of seconds until the system is armed? It is already armed…the armed routine already ran. You do realize that it will take whatever is speaking the announcement more than a second to say that sentence. So, even if you got it to work, it won’t work like you want.

I would check out smart home monitor delay in the community apps. I think that is going to give you the countdown functionality you want.