My Second Piston: What would be a better way to write this?/Piston executing out of order/Alexa Speaks


#1

1) Give a description of the problem
Piston playing out of order/all lights not going out when motion detector no longer detects motion for 10 seconds. New at WebCoRE my second piston.:sweat_smile: What is the best way to write this simple Piston I created?

2) What is the expected behavior?
(Just practicing) When Motion Sensor defects motion at a specific time Alexa says, “I was told to give you a compliment when you come into the garage” DIRECTLY AFTER (Should say) randomCompliment(…) at the say time lights should blink and turn off. RGB Bulb 3 stays on until it no longer detects motion for 10 seconds (which is correct) Bulb 2, 4 and 5 sometimes still stay on.

3) What is happening/not happening?
Alexa does not always say both voice commands (The Speak Expression and Compliment Line)

Thanks so much for your help! Eager to learn how to write better.

5) Attach logs after turning logging level to Full
6/8/2020, 11:04:50 AM +848ms
+0ms ╔Received event [My home].test = 1591628690848 with a delay of 1ms
+48ms ║RunTime Analysis CS > 14ms > PS > 4ms > PE > 29ms > CE
+51ms ║Runtime (41398 bytes) successfully initialized in 4ms (v0.3.110.20191009) (49ms)
+52ms ║╔Execution stage started
+67ms ║║Comparison (time) 39890905 is_between (time) 27900000 … (time) 82800000 = true (9ms)
+68ms ║║Time restriction check passed
+70ms ║║Condition #2 evaluated true (14ms)
+77ms ║║Condition #3 evaluated false (6ms)
+78ms ║║Condition group #1 evaluated false (state did not change) (22ms)
+88ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+98ms ║║Adding a timed trigger schedule for condition 7
+102ms ║║Cancelling condition #7’s schedules…
+103ms ║║Condition #7 evaluated false (22ms)
+104ms ║║Cancelling condition #6’s schedules…
+105ms ║║Condition group #6 evaluated false (state changed) (24ms)
+117ms ║╚Execution stage complete. (66ms)
+124ms ║Setting up scheduled job for Mon, Jun 8 2020 @ 11:05:00 AM EDT (in 9.975s)
+131ms ╚Event processed successfully (131ms)


#2

I’d say break this into 2-3 pistons.
A lot is happening for a single piston.
And always, triggers first, conditions second.


#3

If you are using webCoRE to space out speak commands, I would increase that 8 seconds a bit…
(Alexa does not like getting spammed)


If it were me, I’d probably combine both commands (Speak and sayCompliment) into one line… Like this:

We can get away with shorter delays using executeSequenceCommand(..)


Here is that string Parameter value, if you want to copy/paste:
volume::50,, speak::I was told to give you a compliment when you come into the garage,, wait::2,, cannedtts_random::compliments,, volume::30

(the double commas and double colons are required)


#4

Thank you @WCmore, ike2018 all set!

Hopefully with practice I can grasp the best solutions moving forward easier.


#5

This a great community. You’ll find all your answers.