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

[Bug]: Event not firing #210

Closed XcOM987 closed 11 months ago

XcOM987 commented 1 year ago

Did you check our FAQ and Issue/PR for similar issues?

Contact Details

francis@sutherland-mail.co.uk

What happened?

I have followed the wiki and the youtube video, and I've gotten quite far, I've managed to configure the skill, and said skill has access to my Home Assistant instance and it can read the helper text entry without issue, I can change this manually and it will registerer in the skills test page, but I can't activate it from anywhere.

Steps undertaken so far:

Symptoms/Diag:

I suspect this may be an issue with either Alexa not allowing the skill to be called outside the website dev environment, or something in the code not playing nice.

I've attached the logs but I don't think there of any use as there isn't anything in there indicating that any intent requests have been kicked off. log-events-viewer-result (1).csv

Version

Latest

What Alexa device are you using?

Echo

What other Alexa device are you using?

No response

Relevant log output

No response

DEADSEC-SECURITY commented 1 year ago

Did you respond to the alexa prompt?

DEADSEC-SECURITY commented 1 year ago

Also if not already, activate debug mode and send me new logs.

DEADSEC-SECURITY commented 1 year ago

With "I can't activate it from nowhere" do you mean sending a request to run the skill from HA?

Did you install the required plugin for connecting HA to the alexa cloud? If yes, what plugin did you install?

Send me the code/service_call in HA you're using to trigger the skill.

XcOM987 commented 1 year ago

Hiya,

Sorry, when I say "I can't activate it from nowhere", I meant to say I can't activate the new skill from anywhere other than the dev website.

If I try to access via my mobile app: image

If I access via the Dev console on the website: image

I've enabled debug mode, made some calls from my mobile app and from the console, only the console requests appear to be in the logs.

Many thanks logs1.txt

DEADSEC-SECURITY commented 1 year ago

Did you attempt to trigger the skill via HA? What steps did you do to do so via HA?

XcOM987 commented 1 year ago

Hi,

If trigger it from HA following the steps on the wiki I call the service, the service seems to work, I don't see any errors, and it's waiting for a response, but I hear nothing from any of my Alexa devices: image

The only error logs I get in HA when triggering the script is: `Logger: homeassistant.helpers.template Source: helpers/template.py:232 First occurred: 2:29:18 PM (1 occurrences) Last logged: 2:29:18 PM

Template variable warning: 'suppress_confirmation' is undefined when rendering '{"text": "{{ text }}", "event": "{{ event_id }}", "suppress_confirmation": "{{ suppress_confirmation }}"}`

XcOM987 commented 1 year ago

If I add a suppress confirmation in to the data of true or false I don' get the error in the logs but it makes no difference.

I am leaning towards this being an issue with Alexa as I can't trigger the skill from any alexa directly or from my phone even though I can see the skill in the dev section of my app.

DEADSEC-SECURITY commented 1 year ago

Are your alexa skill and alexa devices under the same account?

XcOM987 commented 1 year ago

Hi,

It looks to be, I can see the skill in my app: image

Along with the second one I made just to make sure I followed the steps correctly: image

I believe I only have one account for Alexa, I checked my password manager and can only find one account, I can also invoke my smart home devices from the dev environment which is linked to my Alexa account.

XcOM987 commented 1 year ago

The only thing I can think of is I have to use US when creating the skill for the locale but I use Ireland/EU for where the skill runs from, which I believe is where my devices are located.

DEADSEC-SECURITY commented 1 year ago

That wouldn't affect it. Just affects latency.

Are you sure that echo entity id is correct and refers to an alexa device? Also have you double checked that the id for the skill is correct?

Did you configure alexa in home assistant using the library refered in docs?

XcOM987 commented 1 year ago

Prerequisites:

The skill seems to be communicting with my HA instance when being run from the dev environment: image JSON output: { "body": { "version": "1.0", "response": { "outputSpeech": { "type": "SSML", "ssml": "<speak>This is the helper entity, is this working correctly, yes or no??</speak>" }, "reprompt": { "outputSpeech": { "type": "SSML", "ssml": "<speak></speak>" } }, "shouldEndSession": false, "type": "_DEFAULT_RESPONSE" }, "sessionAttributes": {}, "userAgent": "ask-python/1.11.0 Python/3.7.17" } }

Happy to provide any info that might be needed

ziggycatuk commented 1 year ago

I have this exact same issue..

Is there a fix ?

IT-Fuzzi commented 1 year ago

I'm facing the same issue. Everything works so far, except if I try to execute the 'service' via the developer tools. I don't see any event and nothing else happens.

My device is a Sonos One speaker with Alexa installed.

DEADSEC-SECURITY commented 1 year ago

@IT-Fuzzi @ziggycatuk @XcOM987 if you guys use the following code: https://github.com/keatontaylor/alexa-actions/releases/tag/v0.8.2

Does it start working again?

DEADSEC-SECURITY commented 1 year ago

Can you try sending a message to you alexa device using the service notify. @XcOM987

ziggycatuk commented 1 year ago
service: notify.alexa_media
data:
  data:
    type: tts
  message: "text to speech working "
  target:
    - media_player.living_room

works absolutely fine.

XcOM987 commented 1 year ago

Can you try sending a message to you alexa device using the service notify. @XcOM987

Yes, can send notifications using TTS without issue

service: notify.alexa_media
data:
  data:
    type: tts
  message: "text to speech working "
  target:
    - media_player.living_room

works absolutely fine.

Yes, this works fine using the below service: notify.alexa_media data: message: test target: media_player.living_room_echo_2 data: type: tts

I can see the script is running because it's updating the helper entry: image

But the Alexa notification fails and doesn't respond service: script.activate_alexa_actionable_notification data: text: "yes or no 19th oct 2023?" event_id: "Alexa_question_Test" alexa_device: media_player.living_room_echo_2

Thanks everyone who's helped thus far, I'd really like to get this ironed out as it would be ground breaking for my needs

XcOM987 commented 1 year ago

service: script.activate_alexa_actionable_notification data: text: "yes or no 19th oct 2023?" event_id: "Alexa_question_Test" alexa_device: media_player.living_room_echo_2

Oddly I rebuilt the skill with this new code and now it won't communicate with my home assistant instance image

ziggycatuk commented 1 year ago

I too have rebuilt the skill, but nothing has changed.

I still receive the text reply from HA in the alexa dev console

alexa dev window

but running the script in HA I just get silence ha dev tools

DEADSEC-SECURITY commented 1 year ago

Have you tried triggering the skill with out using the script? Maybe is an issue with the script? @ziggycatuk

DEADSEC-SECURITY commented 1 year ago

service: script.activate_alexa_actionable_notification data: text: "yes or no 19th oct 2023?" event_id: "Alexa_question_Test" alexa_device: media_player.living_room_echo_2

Oddly I rebuilt the skill with this new code and now it won't communicate with my home assistant instance image

Check logs, activate debug mode

DEADSEC-SECURITY commented 1 year ago

Also if you are trying master @XcOM987 update the requirements file with the one in master. It was a bug its fixed now

ziggycatuk commented 1 year ago

Have you tried triggering the skill with out using the script? Maybe is an issue with the script?

if you mean like this, then still nothing.

dev tools1

XcOM987 commented 1 year ago

Actions taken this morning:

Rebuilt the skill, and it failed building the code, looks like it pulled an old version for some reason, so I manually went through and pulled release v0.10.1 (N/B this is still referenced as 0.9.1 in the lambda_functions.py file.

I followed the guide and I can get the skill to reach my home assistant instance without issue, but only from within the development environments website but not from an Alexa device or phone:

Website: image

Phone: image But the Skill is showing in my Alexa app on my phone.

I've double checked the script several times, I've checked that my home assistant can play media on all alexa devices, TTS is working on the devices, and I've verified that home assistant is trying to reach out to Alexa: image

No logs are appearing in Alexa Developer console unless I run a test from the developer console unless I am looking in the wrong location.

I've attached logs I get when I test from inside the dev website: alexa logs.txt

The reference I see in my home assistant logs is: 2023-10-20 12:35:14.578 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'suppress_confirmation' is undefined when rendering '{"text": "{{ text }}", "event": "{{ event_id }}", "suppress_confirmation": "{{ suppress_confirmation }}"}'

But that goes away if I do reference the suppress confirmation.

I've gone in to the script and attempted to trigger just the stage where it calls out and that fails to do anything, when I run the script and listen for the event I get nothing: image

I also tried the same as ziggycatuk and got the same, no results.

I know this is a pain, and thanks for helping.

DEADSEC-SECURITY commented 1 year ago

Can you double check the account of the skill is the same as the echo devices? Did you install the skill in the mobile app? @XcOM987

DEADSEC-SECURITY commented 1 year ago

@ziggycatuk can you double check the alexa skill too? Also do what I said in the last message to @XcOM987 too.

XcOM987 commented 1 year ago

Can you double check the account of the skill is the same as the echo devices? Did you install the skill in the mobile app? @XcOM987

I can see the skill in my Alexa app: image image

I only have 1 Alexa account, but I have verified though that they are all using the same email address.

DEADSEC-SECURITY commented 1 year ago

This is so weird. I'm honestly getting low on ideas.

ziggycatuk commented 1 year ago

Alexa dev console and alexa app both using the same account.

Screenshot_2023-10-19-22-03-24-128_com amazon dee app

XcOM987 commented 1 year ago

This is so weird. I'm honestly getting low on ideas.

Yea, it's really strange, it's almost as if it's leaving my home-assistant but never reaching the Alexa environment, I am starting to lean to this being something outside of this project and something in the Aether

DEADSEC-SECURITY commented 1 year ago

So lets recap @XcOM987 just to make sure I'm not lost.

Given this behavior I would say no permission to execute skills? When you setup the alexa plugin for HA did you configure with the root account of you alexa? Can you try reinstalling the plugin and trying again? If you could activate logs of the plugin too in HA and send me the logs after attempting to call the skill I would appreciate.

For reference I'm using

I'm also using Nabu Casa for connection and using direct connection instead of token

DEADSEC-SECURITY commented 1 year ago

This is so weird. I'm honestly getting low on ideas.

Yea, it's really strange, it's almost as if it's leaving my home-assistant but never reaching the Alexa environment, I am starting to lean to this being something outside of this project and something in the Aether

Whats that Aether?

XcOM987 commented 1 year ago

Aeather is basically the void lol

Also I am currently reinstalling Alexa Media Player now to test that, I know I had issues in the past with authentication with it but that was long long ago

ziggycatuk commented 1 year ago
  • You can trigger the alexa device to talk using HA service right? - YES
  • You cannot trigger the skill from the HA services. - CORRECT
  • If you go to dev tools in alexa developers your able to start the skill and confirm its making a connection with HA. - YES

For reference I'm using

  • Alexa Media Player 4.6.5 - Running 4.7.7
  • HA 2023.9.0 - HA 2023.10.3
  • Supervisor 2023.10.0 - N/A running Docker
  • Operating System 10.5 - N/A running Docker
  • Frontend 20230906.1 - latest - Frontend 20231005.0 - latest
  • HACS 1.32.1 - 1.33.0

I'm also using Nabu Casa for connection and using direct connection instead of token

Currently using duckdns.org with HA long lived token

ziggycatuk commented 1 year ago

Additionally , if I use the media_player.play_media service to call an alexa routine that works fine

created a dummy hello world routine in the app

service: media_player.play_media
data:
  media_content_id: hello world
  media_content_type: routine
target:
  entity_id: media_player.living_room

I successfully hear alexa say "hello world"

XcOM987 commented 1 year ago

So lets recap @XcOM987 just to make sure I'm not lost. ......

You can trigger the alexa device to talk using HA service right?

Correct, I can trigger Alexa via notify, play media, and is used in other automations.

You cannot trigger the skill from the HA services.

Correct, I am unable to trigger the skill from within Home Assistant services or manually triggering the final stage of the script.

If you go to dev tools in alexa developers your able to start the skill and confirm its making a connection with HA.

Correct, I can run the skill from the Alexa Developers page and it can read the input text helper.

As an aside, I can run custom triggers on Alexa devices, for example I have routines which will set alarms and timers on my alexa devices with routines (Via node red mind but still)

My setup:

I reinstalled Alexa Media player, made no difference, I didn't see any options anywhere when setting it up referencing permissions or anything, but I double checked my details and all settings/options.

DEADSEC-SECURITY commented 1 year ago

Have you guys tried not using the token login method?

ziggycatuk commented 1 year ago

I guess that's the only thing I've not tested

XcOM987 commented 1 year ago

The token login method for the Alexa Media Player?

DEADSEC-SECURITY commented 1 year ago

no, for skill and HA. I don't know why that would work but if does awesome. You can try the tokne for media player too if that is an option

DEADSEC-SECURITY commented 1 year ago

also send me the logs of alexa media player. Make sure you put it in debug mode or activate them first.

ziggycatuk commented 1 year ago

AMP log file; home-assistant_alexa_media_2023-10-20T13-29-03.943Z.log

XcOM987 commented 1 year ago

I will try without the token now, I did the first t

also send me the logs of alexa media player. Make sure you put it in debug mode or activate them first.

I've sanitised the logs for you

alexa logs.log

Have you guys tried not using the token login method?

I setup a new skill and used account linking, same response, can access HA, but not trigger the skill from HA, wouldn't have anything to do with Locale will it? with HA being in en-GB and the skill being en-US?

ziggycatuk commented 1 year ago

I setup a new skill and used account linking, same response, can access HA, but not trigger the skill from HA, wouldn't have anything to do with Locale will it? with HA being in en-GB and the skill being en-US?

I'm also UK based, so maybe it is a regional thing

IT-Fuzzi commented 1 year ago

@IT-Fuzzi @ziggycatuk @XcOM987 if you guys use the following code: https://github.com/keatontaylor/alexa-actions/releases/tag/v0.8.2

Does it start working again?

I can confirm that it's working fine for me on a Sonos Player :-)

For me, the event listener got deactivated every time I clicked on to "Services" tab to trigger the service. Therefore, I was not able to see the event at all. Once it did it in two separate Chrome Tabs it was just working fine. Already in love with the extension, great work!

ziggycatuk commented 1 year ago

@IT-Fuzzi @ziggycatuk @XcOM987 if you guys use the following code: https://github.com/keatontaylor/alexa-actions/releases/tag/v0.8.2

Does it start working again?

No, already tried that

DEADSEC-SECURITY commented 1 year ago

I will try without the token now, I did the first t

also send me the logs of alexa media player. Make sure you put it in debug mode or activate them first.

I've sanitised the logs for you

alexa logs.log

Have you guys tried not using the token login method?

I setup a new skill and used account linking, same response, can access HA, but not trigger the skill from HA, wouldn't have anything to do with Locale will it? with HA being in en-GB and the skill being en-US?

miss match of local could be the issue

DEADSEC-SECURITY commented 1 year ago

@IT-Fuzzi @ziggycatuk @XcOM987 if you guys use the following code: https://github.com/keatontaylor/alexa-actions/releases/tag/v0.8.2 Does it start working again?

I can confirm that it's working fine for me on a Sonos Player :-)

For me, the event listener got deactivated every time I clicked on to "Services" tab to trigger the service. Therefore, I was not able to see the event at all. Once it did it in two separate Chrome Tabs it was just working fine. Already in love with the extension, great work!

what about master branch or version 0.10.1?

XcOM987 commented 1 year ago

@IT-Fuzzi @ziggycatuk @XcOM987 if you guys use the following code: https://github.com/keatontaylor/alexa-actions/releases/tag/v0.8.2 Does it start working again? ........ what about master branch or version 0.10.1?

Will test later on today and let you know, 0.10.1 was the version I was trying the other day, still leaning towards it being something in the void between HA and Alexa getting in the way given there's nothing in the logs to indicate it's rejected a request