Can’t get this to run correctly


#1

1) Give a description of the problem
Trying to have this say good morning, then play weather then play traffic but only once per day when motion is detected in the kitchen.

2) What is the expected behavior?
Would expect it to run trough them all in order

3) What is happening/not happening?
I figured by having them in order that it would play through them. Instead it only plays the weather, sometimes the traffic, but never in order.

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)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

How is the piston supposed to know when one recording ends to start the next?

With the current Alexa API, you may have to do something like this:

...
playWeather()
Wait 30 seconds
playTraffic()
...

#3

Great I’ll give that a try. I’m new to webcore so i did assume that they would just play in order. Sorry.


#4

Great. The wait time Worked thanks.
How do I get this to run only once per day in the morning?

Thanks.


#5

Well, you were right. WebCoRE does send commands in order. In your case, the problem is it only takes a split second for webCoRE to process a line of code, and move on to the next line.


Do you want it to run at a specific time no matter what?
Or do you want it to run when motion is seen during certain times of day?
(for example, when motion is seen between 7 and 8am)


#6

Yeah so between the hours of 6am to 9am but only once per day when kitchen motion sensor is activated.
Thank you.


#7

OK, I will whip something up for you in about ten hours.
I have a few things on my plate at the moment.


#8

Awesome. Thanks buddy.


#9

While you’re waiting for @WCmore,

You can fiddle around with this. Set a variable That compares it to the system variable “$day”

I do something very similar to what you were trying to do except I play Weather and News only between certain hours of the day once per day. This is the piston I use.


#10

Thanks for that. I’m trying to wrap head around all that. Whilst I can set up basic pistons etc, once I have to make it so it only runs once per day, I get confused. Still can’t understand it.


#11

@Eric182’s piston above (line 22-28) is just about the same direction I was going to take.

You should be able to insert your Echo commands in place of his “Music Player 3” block.

One small note:
The line “Set variable {lastDay} = {$day}” should be the very last command… (After all the Echo commands have been sent) This is because you are using a Wait, so you do not want to change that variable until all the commands have run successfully. (or you can set TCP to Never, as he did)


#12

Just for my learning purposes. Would you not want your motion sensor condition to be “changes to active” instead of “is active”?


#13

That was going to be my suggestion, but I did not want to critique @Eric182’s contribution.

If the trigger is “changes to active”, and you happen to be in the kitchen when the time becomes true, the commands will not be sent until you leave the kitchen, wait a few, and then return. Alternatively, if the trigger is “IS active”, then it should fire when the time enters the window, as long as someone is in the kitchen.

Personally, I would use “changes to active”, but I would make sure the time window started before I ever expect to be in the kitchen.


#14

Yes, trigger, not condition. I’m still struggling with those. :slight_smile:


#15

My question is same the OP : " How do I get this to run only once per day in the morning? ". Only once, or it will repeat every times the motion "changes to active " ? Thanks.


#16

The easiest way to remember the difference is:

  • a trigger is a precise instant in time (IE: changes to active)
  • a condition is a vague window of time (IE: IS active)

#17

For play news, what URL are you using?


#18

The Screenshot_2019-02-19%20webCoRE%20Community%20Forum should limit execution to only once a day.


#19

Here is a breakdown of this logic in it’s simplest form, showing both circumstances:

This logic can be applied in many different ways


#20

Thanks, I set up : motion change to active then Echo speak : Bla Bla Bla . I need the Echo only speak when : time is between X and Y, motion change to active , Echo speak, then 10 or 15 minutes later, if motion change to active , Echo speak , no more than 3 times per hour. How I use {lastRanOn} ? Thanks.