Wrong Echo responding


#1

1) Give a description of the problem
I am trying to populate a Global Variable Device via a piston with the most recently spoken to Echo dot. I am using two pistons.

  1. “Set Last Alexa Spoken to” (see below) to capture the device name most recently used and then it populates a Global Variable Device called “@WhichEcho” with that device’s name.
  2. “Echo Response Test” is a test piston to make sure when I speak to a specific Echo it responds back.
    The result of my test is that after executing the “Echo Response Test” piston, the response is being played on the previous Echo used.

For testing

  1. I speak to a dissimilar Echo just to set the Global Variable Device different from the one I am testing on.
  2. I wait between one to two minutes before speaking to the test Echo.
  3. I speak to the Echo I want to respond.
    I have setup a few Log to Console comments to see what is happening, it I am reading them correctly it appears that the name of the device is not changing fast enough to capture the last one used.

Please Note:
I have looked at other older responses to issues somewhat similar to this in the WebCore Forums. I have tried adopting those pistons, but I get the same result, the response is being played on the previous Echo used not the one I just spoke to.

2) What is the expected behaviour?
The goal is to use this Global Variable Device in a number of different pistons.
When I ask Alexa to execute a piston (currently via IFTTT) a response will play back on the original Echo that was spoken to.

3) What is happening/not happening?
The response is being played on the previous Echo used not the most recent one spoken to.

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
3/11/2020, 4:22:20 PM +107ms
+132ms ╔Stopping piston…
+562ms ╚Piston successfully stopped (430ms)
3/11/2020, 4:22:12 PM +910ms
+1ms ╔Received event [Echo - Media Room Echo Dot].wasLastSpokenToDevice = true with a delay of 159ms
+81ms ║RunTime Analysis CS > 19ms > PS > 48ms > PE > 14ms > CE
+83ms ║Runtime (42303 bytes) successfully initialized in 48ms (v0.3.110.20191009) (81ms)
+84ms ║╔Execution stage started
+117ms ║║Comparison (string) false is (boolean) true = false (2ms)
+119ms ║║Comparison (string) false is (boolean) true = false (2ms)
+121ms ║║Comparison (string) false is (boolean) true = false (1ms)
+123ms ║║Comparison (string) true is (boolean) true = true (1ms)
+124ms ║║Comparison (string) false is (boolean) true = false (1ms)
+126ms ║║Comparison (string) false is (boolean) true = false (1ms)
+131ms ║║Cancelling condition #2’s schedules…
+131ms ║║Condition #2 evaluated true (43ms)
+132ms ║║Cancelling condition #1’s schedules…
+133ms ║║Condition group #1 evaluated true (state changed) (46ms)
+135ms ║║Cancelling statement #3’s schedules…
+141ms ║║Calculating (string) The Echo Used before + (string) Echo - Spare Room Echo Dot >> (string) The Echo Used before Echo - Spare Room Echo Dot
+144ms ║║The Echo Used before Echo - Spare Room Echo Dot
+145ms ║║Executed virtual command log (1ms)
+148ms ║║Executed virtual command setVariable (1ms)
+153ms ║║Calculating (string) The Echo Used After + (string) Echo - Media Room Echo Dot >> (string) The Echo Used AfterEcho - Media Room Echo Dot
+156ms ║║The Echo Used AfterEcho - Media Room Echo Dot
+157ms ║║Executed virtual command log (1ms)
+159ms ║╚Execution stage complete. (75ms)
+160ms ╚Event processed successfully (160ms)
3/11/2020, 4:22:10 PM +898ms
+1ms ╔Received event [Echo - Spare Room Echo Dot].wasLastSpokenToDevice = false with a delay of 72ms
+65ms ║RunTime Analysis CS > 17ms > PS > 37ms > PE > 11ms > CE
+67ms ║Runtime (42331 bytes) successfully initialized in 37ms (v0.3.110.20191009) (65ms)
+68ms ║╔Execution stage started
+100ms ║║Comparison (string) false is (boolean) true = false (1ms)
+103ms ║║Comparison (string) false is (boolean) true = false (1ms)
+105ms ║║Comparison (string) false is (boolean) true = false (2ms)
+107ms ║║Comparison (string) false is (boolean) true = false (2ms)
+109ms ║║Comparison (string) false is (boolean) true = false (1ms)
+111ms ║║Comparison (string) false is (boolean) true = false (1ms)
+115ms ║║Cancelling condition #2’s schedules…
+115ms ║║Condition #2 evaluated false (43ms)
+116ms ║║Cancelling condition #1’s schedules…
+117ms ║║Condition group #1 evaluated false (state changed) (45ms)
+119ms ║╚Execution stage complete. (51ms)
+120ms ╚Event processed successfully (120ms)
3/11/2020, 4:19:06 PM +880ms
+1ms ╔Received event [Echo - Spare Room Echo Dot].wasLastSpokenToDevice = true with a delay of 167ms
+85ms ║RunTime Analysis CS > 27ms > PS > 45ms > PE > 12ms > CE
+87ms ║Runtime (42303 bytes) successfully initialized in 45ms (v0.3.110.20191009) (85ms)
+88ms ║╔Execution stage started
+123ms ║║Comparison (string) false is (boolean) true = false (1ms)
+124ms ║║Comparison (string) false is (boolean) true = false (1ms)
+126ms ║║Comparison (string) false is (boolean) true = false (1ms)
+128ms ║║Comparison (string) false is (boolean) true = false (1ms)
+130ms ║║Comparison (string) false is (boolean) true = false (1ms)
+132ms ║║Comparison (string) true is (boolean) true = true (1ms)
+136ms ║║Cancelling condition #2’s schedules…
+137ms ║║Condition #2 evaluated true (46ms)
+138ms ║║Cancelling condition #1’s schedules…
+139ms ║║Condition group #1 evaluated true (state changed) (47ms)
+140ms ║║Cancelling statement #3’s schedules…
+146ms ║║Calculating (string) The Echo Used before + (string) Echo - Spare Room Echo Dot >> (string) The Echo Used before Echo - Spare Room Echo Dot
+149ms ║║The Echo Used before Echo - Spare Room Echo Dot
+150ms ║║Executed virtual command log (1ms)
+153ms ║║Executed virtual command setVariable (1ms)
+158ms ║║Calculating (string) The Echo Used After + (string) Echo - Spare Room Echo Dot >> (string) The Echo Used AfterEcho - Spare Room Echo Dot
+161ms ║║The Echo Used AfterEcho - Spare Room Echo Dot
+162ms ║║Executed virtual command log (1ms)
+164ms ║╚Execution stage complete. (77ms)
+165ms ╚Event processed successfully (165ms)
3/11/2020, 4:19:06 PM +104ms
+1ms ╔Received event [Echo - Kitchen Echo Dot].wasLastSpokenToDevice = false with a delay of 165ms
+104ms ║RunTime Analysis CS > 25ms > PS > 55ms > PE > 25ms > CE
+107ms ║Runtime (42327 bytes) successfully initialized in 55ms (v0.3.110.20191009) (105ms)
+108ms ║╔Execution stage started
+142ms ║║Comparison (string) false is (boolean) true = false (1ms)
+144ms ║║Comparison (string) false is (boolean) true = false (2ms)
+146ms ║║Comparison (string) false is (boolean) true = false (2ms)
+148ms ║║Comparison (string) false is (boolean) true = false (1ms)
+150ms ║║Comparison (string) false is (boolean) true = false (1ms)
+152ms ║║Comparison (string) false is (boolean) true = false (1ms)
+156ms ║║Cancelling condition #2’s schedules…
+157ms ║║Condition #2 evaluated false (45ms)
+158ms ║║Cancelling condition #1’s schedules…
+159ms ║║Condition group #1 evaluated false (state changed) (48ms)
+161ms ║╚Execution stage complete. (54ms)
+162ms ╚Event processed successfully (162ms)

3/11/2020, 4:22:14 PM +144ms
+87ms ╔Stopping piston…
+403ms ╚Piston successfully stopped (317ms)
3/11/2020, 4:21:29 PM +789ms
+0ms ╔Received event [My home].ifttt = its_quiet with a delay of 146ms
+77ms ║RunTime Analysis CS > 19ms > PS > 47ms > PE > 11ms > CE
+79ms ║Runtime (40898 bytes) successfully initialized in 47ms (v0.3.110.20191009) (78ms)
+80ms ║╔Execution stage started
+87ms ║║Comparison (string) its_quiet executes (string) its_quiet = true (2ms)
+88ms ║║Cancelling condition #2’s schedules…
+89ms ║║Condition #2 evaluated true (5ms)
+90ms ║║Cancelling condition #1’s schedules…
+90ms ║║Condition group #1 evaluated true (state changed) (6ms)
+92ms ║║Cancelling statement #5’s schedules…
+516ms ║║Calculating (string) The Echo used in the test + (string) Echo - Spare Room Echo Dot >> (string) The Echo used in the test Echo - Spare Room Echo Dot
+519ms ║║The Echo used in the test Echo - Spare Room Echo Dot
+520ms ║║Executed virtual command log (1ms)
+522ms ║║Cancelling statement #3’s schedules…
+527ms ║║Calculating (string) The last spoken to Echo was + (string) Echo - Spare Room Echo Dot >> (string) The last spoken to Echo was Echo - Spare Room Echo Dot
+1062ms ║║Executed physical command [Echo - Spare Room Echo Dot].playText([The last spoken to Echo was Echo - Spare Room Echo Dot]) (529ms)
+1062ms ║║Executed [Echo - Spare Room Echo Dot].playText (530ms)
+1065ms ║║Cancelling statement #7’s schedules…
+1070ms ║║Calculating (string) Echo in use after the test + (string) Echo - Spare Room Echo Dot >> (string) Echo in use after the test Echo - Spare Room Echo Dot
+1073ms ║║Echo in use after the test Echo - Spare Room Echo Dot
+1074ms ║║Executed virtual command log (1ms)
+1076ms ║╚Execution stage complete. (996ms)
+1261ms ╚Event processed successfully (1261ms)

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


#2

These two highlighted logs will always be identical.

pic

The logic is, a piston does not read or write to a @global while the piston is executing.

  • It reads at the beginning (before executing any code)… and
  • it writes at the end (once the last line of code has executed).

If you need instant feedback for a variable, use a local variable for that. A local can be set on one line, and the change will be seen on the very next line.


For example, you could change your last line above to say:
Log info "The Echo Used After "{whoSpoke};


#3

As far as I can see, IFTTT is executing your Echo Response Test a full forty seconds before the Set Last Alexa Spoken To piston receives the wasLastSpokenToDevice event and updates the global variable, so it really isn’t even close.


#4

This is a conversation that I had with the developer of Echo Speaks just a couple of days ago…


#5

Thank you @WCmore , @orangebucket and @Pantheon … So is there an alternative approach you could please suggest?


#6

Actually, I was hoping (and already coding pistons) to do what you have started. But I am getting terrible response times with ES on my Fire HD pads. Now, with my Echo Dots, I am getting nearly immediate responses. So I will probably remove my pads from this equation.


#7

@Pantheon that sounds promising. Would you be willing to share your piston(s) with me so I can see if I can adapt them for my use?


#8

@DGBQ, yes, I am more than willing to share pistons. I have read @WCmore’s alternative to ES HERE and I may move in that direction. And I have been hesitant to use Echo Speaks, but thought I would give it a try. So I have just started writing pistons. You may want to look HERE for more information and pistons for ES.


#9

Well, for a proper two piston test (as in your first post), I would Log using local variables (since they are instant), and then before the piston completes, set @global to match the local.

IE: Piston f5shh above, change line 27 to:
Log info "The Echo Used After "{whoSpoke};


#10

Thank you @WCmore for your insight. I now understand that the method for capturing the change in a Global variable to a Log is incorrect.

However would I not be correct in thinking that by changing line 27 it still will not solve my key issue of “The response is being played on the previous Echo used not the most recent one spoken to.”


#11

Just to clarify, using a @global in a log works beautifully to capture the data at the beginning… but if the piston makes any changes to the @global, then yes, use locals to keep track of that new data instantly.


You are correct. Changing the log does absolutely nothing to the underlying code… but using locals during processing will definitely give you accurate results in your testing environment.


#12

The problem is, the wasLastSpokenToDevice data doesn’t update very quickly. By itself, it takes about 10+ seconds. I use the getDeviceActivity command to speed that up (@2-4 seconds).