keatontaylor / alexa-actions

A README and associated code to get actionable notifications setup for Alexa devices.
GNU General Public License v3.0
408 stars 187 forks source link

ResponseNone not working properly in Echo Plus #171

Closed brunofaim closed 7 months ago

brunofaim commented 1 year ago

I'm having an issue with "ResponseNone" with my Echo Plus.

I tested on Echo Plus and Echo Dot. The "ResponseNone" works just as expected in an Echo Dot device. While in the Echo Plus whenever there is no response, looks like it stores it somewhere, but doesn't go to "ResponseNone", then once you activate it again it goes straightaway to "ResponseNone" without waiting for the response, so it is sort of always one "ResponseNone" behind.

Same issue as described here:

(https://community.home-assistant.io/t/alexa-actionable-notifications-responsenone-event-not-firing/551490)

I did some comparinson on the logs and looks like everytime I run trough any Echo Dot, I get 12 lines of log. Image bellow: image image

But when I trough my Echo Plus I get only 7 lines of log. Image bellow: image image

I did some comparinson between them and I can see that once it gets the first [INFO] it's already skipping to "Session Ended Request Handler triggered".

Can someone please help me out?

SamB-GB commented 1 year ago

Interestingly I see the same issue with Alexa on my Sonos One Gen 2

brunofaim commented 1 year ago

@SamB-GB Did you ever found a solution or a work around for that? This is honestly driving me crazy, since it can actually trigger automations before I have the chance to answer the question.

SamB-GB commented 1 year ago

@brunofaim no I am afraid not, sorry. I am having the same issue.

DEADSEC-SECURITY commented 1 year ago

Can you activate debug mode and send the logs of you trying to recreate the bug?

SamB-GB commented 1 year ago

@DEADSEC-SECURITY I get two log entries one after the other with the same timestamps.

As you can see session end is triggered early on and then not triggered again on the second logs.

Snag_1a87260e

Snag_1a86d493

DEADSEC-SECURITY commented 1 year ago

One thing that catches my eye @SamB-GB is the speak_out key, I don't remember that being an option in the code. Is that code modded by you or a different fork? Could you try remaking the skill but with the master branch? Its a bit experimental but lets see how it goes with you.

SamB-GB commented 1 year ago

@DEADSEC-SECURITY yeh you can ignore that it was a mistake I made in configuring the script to suppress the OKAY confirmation. I did recompile the entire thing and start from scratch but I still see the same issue.

DEADSEC-SECURITY commented 1 year ago

Actually @SamB-GB just read your other post where you didnt know if it was speak_out or supress_confirmation so ignore my question.

DEADSEC-SECURITY commented 1 year ago

Ok @SamB-GB so basically just to resume. The skill works on normal Echo devices but in the Plus version it doesn't right? And the problem is that it skips waiting for a response and just triggers a ResponseNone event.

DEADSEC-SECURITY commented 1 year ago

@SamB-GB @brunofaim could you guys try this update to the lambda requirements file? https://github.com/keatontaylor/alexa-actions/blob/master/lambda/requirements.txt

SamB-GB commented 1 year ago

@DEADSEC-SECURITY I tried setting the requirements to which didn't help

isodate==0.6.0
pydantic==1.10.4
boto3
ask-sdk-core

This seems to apply to the Echo Plus but I am testing this on a Sonos One Gen 2 with Alexa.

What seems to happen is Alexa Actionable prompts for a response and I give no response but ResponseNone is not sent at all. Then when the Alexa Actionable is called again it immediately sends a ResponseNone and I can continue to follow the flow saying Yes or No or No Response (like it should) and it will carry out the action. But of course since there is an automation tied to ResponseNone it also carries out that action since it immediately sent ResponseNone when the Alexa Actionable was called the second time.

DEADSEC-SECURITY commented 1 year ago

Might need to check later when i get home. I dont have that device so might be a bit difficult to debug but ill try to figure this out. Alexa has this annoying thing that every device family is different a bit in the way it interacts with the skill code so I need to do more research.

If you find anything let me know

SamB-GB commented 1 year ago

Okay great, thanks.

I can confirm this works correctly on my 4th Gen Echo.

brunofaim commented 1 year ago

Sorry for the delay @DEADSEC-SECURITY, and thanks for trying to help. Im trying it on an Echo Plus device. My other echo dots work just as fine with same automations.

Just update the requirements as showed bellow. But still seems to be doing the same thing. image

SamB-GB commented 1 year ago

@brunofaim out of interest when your Echo Plus device doesn't hear a response do you get an additional sound? On my Echo 4th Gen I have a ding that closes the session and then a second sound that plays and at that point thats when the ResponseNone is sent.

On the Sonos One Gen 2 I get the sound that opens the session but not the additional dings afterwards.

brunofaim commented 1 year ago

@SamB-GB I noticed this! On my echo plus I don't get the ding for the ResponseNone. Basically on Echo Dot 3rd gen, I get an "Ok" (Translated to my language) if I answer Yes or No, if I don't answer anything, I hear a ding. While in Echoplus I get an "Ok" (Translated to my language) if I answer Yes or No, but don't get any ding for ResponseNone...

If I call service again on Echo Plus after not getting the ding from a "No response" on the previous call service, it fires "ResponseNone" even before asking the question, and the cycles repeats.

If I call service again on Echo Plus after getting an "Ok" from the previous call service, it does not fire the "ResponseNone" before asking the question, but if I dont answer this upcoming question then I get the issue adressed on paragraph above

SamB-GB commented 1 year ago

@DEADSEC-SECURITY could this be related albeit these devices don't have a screen #17

SamB-GB commented 1 year ago

@brunofaim what language do you have set for this Skill? When I created it I cloned it to the UK language and set my region for the Skill to EU.

brunofaim commented 1 year ago

@SamB-GB Mine is an Echo Plus, not Echo Show, so not sure if that's the same issue. I'm running the skill and the devices in Portugues. I use the US region on my alexa account. Although I live in Australia, quite confusing haha. But it shouldn't be a problem, because as I said its working on my other Echo devices.

Where do you change the Region for the skill? Im not using account linking for actionable notifications (I use the token), I know how to change region on the whole account, but not the developer skill per say

SamB-GB commented 1 year ago

Also see this issue on my Sonos Era 100 and 300s.

Krispkiwi commented 1 year ago

I'm also getting this on the fire cube and echo dot gen 3

DEADSEC-SECURITY commented 1 year ago

Can you guys share logs and activate debug mode?

DEADSEC-SECURITY commented 1 year ago

@Krispkiwi and all the others having issues, please activate debug mode and send me the logs as I don't have those devices and I can't debug at home.

Krispkiwi commented 1 year ago

@Krispkiwi and all the others having issues, please activate debug mode and send me the logs as I don't have those devices and I can't debug at home.

I'm just rebuilding my home assistant instance over the next few days, I'll do my best to get it to you by the end of the week.

Krispkiwi commented 1 year ago

Hey I just want to double check I understand you correctly so I'm getting you the right data, do you mean turning on this? logger: default: debug

Or are you referring to a debug mode inside of the skill console that I'm not aware of?

DEADSEC-SECURITY commented 1 year ago

In the code there is DEBUG = False, switch it to True and then attempt to recreate the bug and send me the logs for that call

Krispkiwi commented 1 year ago

I've gone into cloudwatch to try to get them there and I'm getting access denied exceptions. Is there anywhere else to obtain the log you're looking for?

I did a quick video too to show it in person using the fire cube https://youtu.be/7Qa1hFCcRwk

DEADSEC-SECURITY commented 1 year ago

Are you running multiple talk commands in sequence? @Krispkiwi

Krispkiwi commented 1 year ago

Are you running multiple talk commands in sequence? @Krispkiwi

In that clip, just two. That was a TTS question followed by a TTS confirmation after the ResponseNone event fired. The problem is the first attempt didnt trigger the confirmation as it got stuck so when I triggered it again then it suddenly recognized the earlier attempt and answered it twice.

DEADSEC-SECURITY commented 1 year ago

Its probably somethign finicky with the device or code @Krispkiwi. Can you share logs in debug mode please?

Krispkiwi commented 1 year ago

Its probably somethign finicky with the device or code @Krispkiwi. Can you share logs in debug mode please?

Is there somewhere other than cloudwatch in the alexa console i can locate that?

DEADSEC-SECURITY commented 1 year ago

cloudwatch is the only place to get logs

DEADSEC-SECURITY commented 1 year ago

@brunofaim can you let me know what are you receiving on the HA side instead of ResponseNone? Thats could be a clue of what is happening

PaulBiod commented 1 year ago

Hi, I'm using echo show 5 and 8 and I have the same exact issue. Let me know if I can provide some logs.

DEADSEC-SECURITY commented 1 year ago

Please do @PaulBiod

gosoares commented 1 year ago

The same is happening here in a Echo Show 5. A did a little bit of digging in this repository, and found out that this was previously "fixed", but reintroduced later.

The was first reported in issue https://github.com/keatontaylor/alexa-actions/issues/17. The cause was later clarified in https://github.com/keatontaylor/alexa-actions/issues/17#issuecomment-642335504 and https://github.com/keatontaylor/alexa-actions/issues/46.

Basically in the screen echos (and maybe also in the echo plus), when the user does not provide a answer the skill remain open, so the session is not ended and the ResponseNone is not triggered. I tested and i found out that i can still provide a answer in that time by calling for alexa and saying it. When we send another notification, the previous session is ended, triggering a ResponseNone, and then a new one is created.

PR https://github.com/keatontaylor/alexa-actions/pull/43 "fixed" it prevented sending the ResponseNone when the reason for the session ending was USER_INITIATED (that happens when a session is ended when the other is initiated), but PR https://github.com/keatontaylor/alexa-actions/pull/130 reallowed it.

My first thought was to use the event_id to disambiguate the response from the first request (which nothing was said) from the second, but after testing i saw that the ResponseNone from the first request is sent with the event_id from the second. This is probably another bug.

DEADSEC-SECURITY commented 1 year ago

We could revert #130 but I'm not sure if it will #127 bug back.

I need to think about this, because I'm not 100% sure how to fix this bug yet. If you would like to participate I'll create a new branch and feel free to continue posting any discovery.

Thank your for the input @gosoares.

DEADSEC-SECURITY commented 1 year ago

From docs we have 3 types of reasons for a None response. https://alexa-skills-kit-python-sdk.readthedocs.io/en/latest/models/ask_sdk_model.html#module-ask_sdk_SessionEndedReason

What we could do that might fix the issue is send the reason with the response to Home Assistant and allow the user in HA to do whatever with such information

What do you think @gosoares

gosoares commented 1 year ago

I think this is a good solution, doing that and documenting it would be enough for that issue in my opinion.

But i think that the event_id should also be fixed somehow, to return the one from the initial request. I might open another issue explaining something that i was trying.

DEADSEC-SECURITY commented 1 year ago

Ill implement this fix so all of you can test it out, if it goes well we can merge it.

Krispkiwi commented 1 year ago

Do we have a timeline on when this will be available to test? I just find myself checking here for an update every day

DEADSEC-SECURITY commented 1 year ago

@Krispkiwi @gosoares feel free to test it. Modification in the branch.

The type is still ResponseNone but now it should send in the body under event_response_type the reason for session to end.

The reasons possible are ERROR, EXCEEDED_MAX_REPROMPTS or USER_INITIATED

DEADSEC-SECURITY commented 1 year ago

Let me know if it works for you guys and what you might want me to change. @Krispkiwi @gosoares

DEADSEC-SECURITY commented 1 year ago

Has anyone been able to test out my branch? @gosoares @Krispkiwi @brunofaim @SamB-GB? I don't have an alexa with me since I'm currently not at Home and I cannot test it properly so if you guys could give me some feedback I would appreciate.

Krispkiwi commented 1 year ago

Has anyone been able to test out my branch? @gosoares @Krispkiwi @brunofaim @SamB-GB? I don't have an alexa with me since I'm currently not at Home and I cannot test it properly so if you guys could give me some feedback I would appreciate.

Sorry mate not yet, have had some personal matters pop up.

misterx8 commented 1 year ago

hi guys, even with my echo shows 5 and 8 the no response event is triggered immediately and does not wait for the end of the conversation. some idea?

DEADSEC-SECURITY commented 1 year ago

with this branch code @misterx8 ?

misterx8 commented 1 year ago

Master @DEADSEC-SECURITY

DEADSEC-SECURITY commented 1 year ago

Master @DEADSEC-SECURITY

Send me the logs

misterx8 commented 1 year ago

What logs do you want? those of HA? or others? @DEADSEC-SECURITY