GithubHelp home page GithubHelp logo

keatontaylor / alexa-actions Goto Github PK

View Code? Open in Web Editor NEW
383.0 383.0 186.0 751 KB

A README and associated code to get actionable notifications setup for Alexa devices.

License: GNU General Public License v3.0

Python 100.00%

alexa-actions's People

Contributors

cisneiros avatar deadsec-security avatar dreimer1986 avatar dudu631 avatar dwoosnam avatar elmar-hinz avatar freddythenut avatar gosoares avatar guieiras avatar jgarmar avatar keatontaylor avatar kevinbonnoron avatar mk-maddin avatar paoloantinori avatar rwunsch avatar siege36 avatar tonysurma avatar violentpoo avatar xela1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alexa-actions's Issues

ResponseNone do not work on Display Devices currently

Amazon devices with a Display currently won't trigger ResponseNone events on Alexa Actions, due to the skill remain open on the screen.

On non-display devices, it's easy to trigger ResponseNone cause you just have to handle the SessionEndedRequest with cause EXCEEDED_MAX_REPROMPTS.

Although on display devices, when the user does not answer a Reprompt the session is not ended (that is the normal behavior according to this and this) and it's not possible to handle the "no response" anywhere. Even when the app closes visually, there is no SessionEndedRequest.

I'm currently finding a way to detect the no response on those devices to a question sent - I asked amazon devs and they said they would contact me with a solution or open a feature request on alexa SDK if no solution is possible at the moment.

Also I opened a pull request to fix wrong ResponseNone events that these devices would trigger on the 2nd attempt on calling it. It only prevents USER_INITIATED wrong event, to push ResponseNone on Home Assistant. That way, Alexa display devices won't trigger oddly a ResponseNone event, and non-display devices won't trigger ResponseNone if you call it twice consecutively by mistake for some reason.

ResponseNone will work fine on non-display devices though.

Actionable notifications with fire tv cube not working properly

When using actionable notifications with a fire tv cube it pauses whatever media is playing to show that there is an actionable notification. No matter how i respond to the device no action gets taken. This works fine with my echo dots but the cubes have issues.

The wiki instructions do not include the new multi language files

Hi, when following the instructions on how to create the skill for alexa, the instructions do not yet include that there are 2 new files (language_strings.json, prompts.py) that need to be added to the lambda directory in the amazon developer console. Without those files the skill does not work. It took me quite a while to figure that out.

“There was a problem with the requested skill’s response”

I am able to link the skill with my instance of Home Assistant, however "open custom actions" results in the response “There was a problem with the requested skill’s response”. I am using the Nginx plugin in Home Assistant for SSL, and I understand others using DuckDNS are having the same issue.

Testing via Alexa developers console results in the same response.

Discord invite for support is expired.

Maybe an error maybe me "Source: components/alexa/state_report.py:100"

Hi,

So I went through everything and it all works on the Dev console also I ask my echo the test question and everything is great, however setting up a trigger to say something when a PIR is trigger for example is not working at all.

Any chance of a super simple example of:
Trigger:
entity_id: binary_sensor.0x00158d00049fd246_occupancy
platform: state
to: detected

Call service:
This is where I get stuck, I will not bore you with all failed attempts, your example is not clear to a novice HA programmer, so just getting the Alexa of my choice to say "Yep that worked" would be an amazing example.

Thanks

Everything is updated the latest versions, as of posting today (Update Home Assistant to version 0.112.4)

Also I get this in the logs is it the reason my various attempts at using your example fail?
`
Logger: homeassistant.core
Source: components/alexa/state_report.py:100
First occurred: 15:50:18 (1 occurrences)
Last logged: 15:50:18

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/alexa/state_report.py", line 49, in async_entity_state_listener
hass, smart_home_config, alexa_changed_entity
File "/usr/src/homeassistant/homeassistant/components/alexa/state_report.py", line 100, in async_send_changereport_message
allow_redirects=True,
File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 380, in _request
url = URL(str_or_url)
File "/usr/local/lib/python3.7/site-packages/yarl/init.py", line 149, in new
raise TypeError("Constructor parameter should be str")
TypeError: Constructor parameter should be str`

We were unable to link Home Assistant Home at this time

Hey,

Could you clarify what the HA URL on the python file is supposed to be like. You mention about port 443 and certs but I'm not sure if I'm supposed to put my url (e.g. https://domain_nane.ddns.net) with a port number or without. And if it's with a port number is it supposed to be 8123 or 443?

I have both of those external ports pointing to the same ports on my internal IP running HA.

I've tried without and with either of those ports but still getting "unable to link HA" message.

Improve initial test error handling

Hi there,
I've just deployed the custom skill and performed the suggested test.
It failed badly with logs not really suggesting what the issue was:

[ERROR] TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/var/task/ask_sdk_core/skill_builder.py", line 111, in wrapper
    request_envelope=request_envelope, context=context)
  File "/var/task/ask_sdk_core/skill.py", line 207, in invoke
    handler_input=handler_input)
  File "/var/task/ask_sdk_runtime/dispatch.py", line 131, in dispatch
    return exception_handler.handle(handler_input, e)
  File "/var/task/lambda_function.py", line 355, in handle
    home_assistant_object = HomeAssistant()
  File "/var/task/lambda_function.py", line 55, in __init__
    self.get_ha_state()
  File "/var/task/lambda_function.py", line 97, in get_ha_state
    errors = self._check_response_errors(response)
  File "/var/task/lambda_function.py", line 70, in _check_response_errors
    logger.error("404 Error", response.data)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 1407, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 1514, in _log
    self.handle(record)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 1524, in handle
    self.callHandlers(record)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 1586, in callHandlers
    hdlr.handle(record)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 894, in handle
    self.emit(record)
  File "/var/runtime/bootstrap.py", line 243, in emit
    msg = self.format(record)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/var/lang/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/var/lang/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args

It turned out I've forgotten to restart HA after defining the input_text. Could this be considered a possible common error? Would it be possible to alter the initial test to become more robust?
I've seen that there is an entry in the language dictionary to cover this error, but it didn't kick in: ERROR_404

Where should I put the script?

Where am I supposed to add the script described in the "Setting up your first actionable notification" wiki since if I copy and paste it in the scrips.yaml it just fucks up home assistant and I get a notification that the integration script can't work due to "invalid config"?

"Error: invalid client id or redirect uri" when linking account

I'm seeing the above error when attempting to link the skill to HA. (Yes, it does say uri not URL).

In HA I'm seeing the following, possibly related, errors:

Logger: hass_nabucasa.cloud_api
Source: components/cloud/alexa_config.py:114
First occurred: 8:02:46 AM (3 occurrences)
Last logged: 8:02:46 AM

Fetched https://alexa-api.nabucasa.com/access_token (400)

and

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/cloud/alexa_config.py", line 295, in _handle_entity_registry_updated
    await self._sync_helper(to_update, to_remove)
  File "/usr/src/homeassistant/homeassistant/components/cloud/alexa_config.py", line 239, in _sync_helper
    await self.async_get_access_token()
  File "/usr/src/homeassistant/homeassistant/components/cloud/alexa_config.py", line 128, in async_get_access_token
    raise RequireRelink
homeassistant.components.cloud.const.RequireRelink

The URL amazon tries to direct to when requesting linking does contain the correct NabuCasa remote access URL for my HA instance.

Any pointers you can give me will be much appreciated.

Alexa repeats the question the number of entities that are on state to trigger automation

It is awesome the work that you have done. I am very thankful. I just want you to know.

If you have more than one entity triggering the automation, Alexa asks the question one time per entity that's on the specified state. For instance, I have 4 lamps in living room. Any of those lamps triggers the automation, if 3 are on, then Alexa asks three times 'Should I turn the lights off?'. If two are on, then it does it twice. This is my automation:

  • alias: alexa asks to turn living lights off
    trigger:
    platform: state
    entity_id:
    - switch.plug_1_relay
    - switch.plug_2_relay
    - switch.plug_3_relay
    - switch.plug_6_relay
    to: 'on'
    for: '00:30:00'

Also, could you have more than one event_response_type?

  • alias: 'alexa turns living rooms lights off'
    trigger:
    platform: event
    event_type: alexa_actionable_notification
    event_data:
    event_id: turn_off_living_room_lights
    event_response_type:
    - ResponseNone
    - ResponseYes

Thanks again for your hard work!

[Feature Request] Pass-through to Home Assistant intent scripts

I've already got fairly extensive Alexa integration for my Home Assistant set up with the built-in Alexa Custom Skill and Smart Home Skill integrations, and I'd prefer to not have to add yet another skill to make use of this. Is it possible to, adding the relevant intents to my existing custom skill, modify the lambda_function.py here to pass unrecognized intents through to Home Assistant in the same way that the integration's script does?

I've tried hacking on this a little myself, but I can't seem to figure out how to get the raw request information back out of input_handler.

sample script activate_alexa_actionable_notification fails validation in VSCode

script:
activate_alexa_actionable_notification:

fails validation in VSCode (connected to HA) because "example: " is expected under each of the fields (text, event_id, and alexa_device)...

I had to modify it like below to pass the validation (although it still works even without passing validation)...

activate_alexa_actionable_notification:
  description: 'Activates an actionable notification on a specific echo device'
  fields:
    text:
      description: 'The text you would like alexa to speak.'
      example: just to pass validation
    event_id:
      description: 'Correlation ID for event responses'
      example: just to pass validation
    alexa_device: 
      description: 'Alexa device you want to trigger'
      example: just to pass validation
  sequence:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.alexa_actionable_notification
        value: '{"text": "{{ text }}", "event": "{{ event_id }}"}'
    - service: media_player.play_media
      data_template:
        entity_id: "{{ alexa_device }}"
        media_content_type: skill
        media_content_id: <Your Skill ID>

ResponseNone Not sending until next call

When testing I have found the the ResponseNone event does not get sent until the skill is triggered again.

This means that I cannot use the ResponseNone in my automations.

Is there any way to get this to send the same as Yes and No?

Problem with skill Reponse

Hi there,

Unfortunately I keep receiving:
"There was a problem with the requested skills response" when opening the skill using "Alexa, open custom actions".
Any idea why that is?

Cheers,
SCCMOG

Can't get this to work on newer echo devices

I'm not sure if this is related to the created skill or the generation of device. On my 2nd gen amazon echo dot it works as intended as long as I set the location as a US region and US zip code.
I'm in Canada so I tried changing the region to Canada doesn't work and back to US works. This is just on the 2nd gen echo dot.

On my 3rd gen echo dot I tried changing this same region but still can't find the command. I also deregistered/reregistered reinstalled skill nothing seems to correct this issue. I'm not sure if I'm missing a setting on the Alexa device side or the Alexa Skill side, but does work on my older echo as longs region is US.

Discord for General Q's

I feel like I'm still pretty new to the scene to be posting here, but the discord link isnt working. I'm not even getting to the linking part after enabling the skill, and I'm thinking it is because my home assistant URL is just http://192.168.10.230:8123 . Assuming the discord is no longer around, Should I put my nabu casa url in there instead?

Account linking error

Hello,

I have been trying to solve a problem I have with account linking by reading other threads but not able to find a solution. Not sure where to debug. I have tried to re-create the skill numerous times in different regions.

Error when trying to link account.

We were unable to link alexa notifications at this time.

Nothing interesting in hassio logs.

Skill region: US
Redirect url: https://pitangui.amazon.com/

Any suggestions?

Custom Action - Cannot Communicate With Home Assistant

I certainly appreciate all your efforts to contribute a terrific new custom skill for Alexa and Home Assistant. I somewhat new to HA so the issues I maybe having are just me getting up on the learning curve. I'm running HASSIO (V0.109.6) on a RPI3+ with the latest Alexa Media Player integration (V2.7.3).

I followed the instructions on creating and deploying the "custom action" skill and successfully linked in my Alexa app.

Alexa Actions Account Linking

When I attempt to verify the new custom action with the command "Alexa, open custom actions" the response is "Could not communicate with Home Assistant".

Any advice or direction would certainly be much appreciated and thanks again for your efforts.

Cheers,

Echo dot doesn't recognize "open custom actions" command

I've created the skill and successfully enabled/linked the skill in the Alexa app, but the echo won't recognize the command "open custom actions" -- instead it asks about other existing skills with similar names. I've tried changing the Invocation phrase, but similar results.

In the developer console -> skill -> test tab -- I can test the command "open custom actions" and it replies with text value from the input_text entity from HA. So, the skill and account linking seem to be working.

In the Alexa app, I've confirmed my Echo dot is listed in devices and communicating back to the app.

Any ideas why this is happening?

Alexa doesn't ask the command till I say "Alexa, open custom actions".

Hey,
Really cool addition to Home Assistant and I'm really looking forward to playing around with it. I'm having some trouble though. I've gone through the Alexa developer setup, added the app to my Alexa and am able to run the "Alexa, open custom actions" phrase. But when I run the automation to get the question from Alexa, nothing happens. She only starts asking the question after I say the "Alexa, open custom actions" and after that I can answer yes and the subsequent automation performing the action runs fine.
I couldn't get access to the Discord server via the links, otherwise I would have asked there, but was hoping I could be helped out with this issue here.

Hardcoded Token

I was wandering where should the token be hardcoded into.
is it like this?

# UPDATE THESE VARIABLES WITH YOUR CONFIG
HOME_ASSISTANT_URL                = "https://URL.ui.nabu.casa"       # REPLACE WITH THE URL FOR YOUR HA FRONTEND
VERIFY_SSL                        = False                              # SET TO FALSE IF YOU DO NOT HAVE VALID CERTS
self.token = 'HARDCODED TOKEN'

or like this?

home_assistant_object = None
class HomeAssistant():
    """Class to abstract access to HA."""
    def __init__(self, handler_input):
        self.event_id = ""
        self.text = ""
        self.handler_input = handler_input
        self.token = 'HARDCODED TOKEN'

Does not respect Brief Mode after receiving user response

For all support requests it is strongly recommend you join the #alexa-actionable-notifications discord channel for assistance. Myself and others are able to help you in real-time with issues. Discord Invite Link

For all other issues and feature requests, please replace this text with your issue or feature request. Thank you so much for all the support!

The Discord Invite Link didn't work. ;-(

The integration is working well. Set up was easy to follow.

I realized after a couple of tests that I never hear "Okay" from Alexa because I have Brief Mode enabled and only hear a short sound. But, I hear it every time after I respond to an Alexa Action question.

Can the "Okay" be disabled? Or respect the Brief Mode setting?

Thanks for making this awesome integration!

Amazing work buddy. I wish I could do more than yes or no

@keatontaylor , you have done amazing work. This is mind-blowing. I did integrate, and it works flawlessly. I wish there was a way to have custom options more than yes and no.

For e.g.
I turn on the TV and I am greeted with a message, "I see you turned on the tv. Would you like to watch Youtube, Netflix, or Hulu ?" I hope this example makes the scenario clear.

Anyways thanks dude for your hard work! Really appreciate your work.

Possible typo at lambda_function.py?

Maybe the line #93 has a typo:

'{}/api/events/alexa_actionable_notificaiton'.format(HOME_ASSISTANT_URL),

Should be like this?
'{}/api/events/alexa_actionable_notification'.format(HOME_ASSISTANT_URL),

Maybe it has an impact when calling the service

Error: Invalid client id or redirect url

Hello All,

Tried to build this custom skill. My HA is accessible using https:// with port 443.
Im using latest Alexa Media Player : v2.11.2
HA version: 0.114.4

I have a line in configuration file for Alexa:
alexa:
smart_home:
endpoint: https://api.eu.amazonalexa.com/v3/events
client_id: !secret alexa_client_id_smart_home_messaging
client_secret: !secret alexa_client_secret_smart_home_messaging

This is working ok. Alexa Media Player I can use for all my announcements.

But when I want link the new custom_skill part I get the error:

Error: Invalid client id or redirect url

When I disable account link and put a long live token to the script
Run a automation (when switch turn on ask something):

- alias: "TEST - Alexa Custom Skills"
  trigger:

    platform: state
    entity_id: switch.newkaku_014e5906_a
    to: "on"

  action:
    service: script.activate_alexa_actionable_notification
    data_template:
      text: "The test switch is on for more then 1 minute. Do you want me to turn it off?"
      event_id: "actionable_notification_lock_left_unlocked"
      alexa_device: media_player.this_device

script:

activate_alexa_actionable_notification:
  description: 'Activates an actionable notification on a specific echo device'
  fields:
    text:
      description: 'The text you would like alexa to speak.'
      example: 'What would you like the thermostat set to?'
    event_id:
      description: 'Correlation ID for event responses'
      example: 'ask_for_temperature'
    alexa_device:
      description: 'Alexa device you want to trigger'
      example: 'media_player.bedroom_echo'
  sequence:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.alexa_actionable_notification
        value: '{"text": "{{ text }}", "event": "{{ event_id }}"}'
    - service: media_player.play_media
      data_template:
        entity_id: "{{ alexa_device }}"
        media_content_type: skill
        media_content_id: amzn1.ask.skill.e82dbcad-7eca-4c61-XXXXXXXXXXXXXXXXXX

input text:

alexa_actionable_notification:
    name: Alexa Actionable Notification Holder
    max: 255
    initial: '{"text": "This is a test of the alexa actions custom skill. Did it work?", "event": "actionable.skill.test"}'

Then my phone is responding only with:
Welcome, you can say Hi or Help. Which would you like to try?

When I do nothing Alexa Ask me this 2 times then stop

WHen i change the media_player to my Echo Dot. Then no speech at all will be heared

For the select item it's good to return the slot name instead of slot value

The Scenario:

  • Alexa Says "I noticed the TV was turned on, what would you like to play, Netflix, Amazon Prime Video or YouTube?"
  • I say "Prime Video"
  • Received slot: "ResponseNone" because in the slots I mentioned Amazon Prime Video and not Prime Video

Solution:
Added Synonyms to solve this issue
image

Now when I say "Prime Video" I was getting prime video. But I wanted to get "Amazon Prime Video which is the slot name in this case and not value.

So I made the changes to the first 2 line of the following code and now it seems to work.

def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        #selection  = ask_utils.get_slot_value(
        #    handler_input=handler_input, slot_name="Selections")
        
        selection = ask_utils.get_slot(handler_input, slot_name="Selections")
        selection = selection.to_dict()["resolutions"]['resolutions_per_authority'][0]["values"][0]["value"]["name"]

        global home_assistant_object
        if home_assistant_object == None:
            home_assistant_object = HomeAssistant(handler_input)
            home_assistant_object.get_ha_state()
            

        home_assistant_object.post_ha_event(selection)
        speak_output = "You selected " + selection
        return (
            handler_input.response_builder
                .speak(speak_output)
                # .ask("add a reprompt if you want to keep the session open for the user to respond")
                .response
        )

Let me know your thoughts on this ?

No answer after media_player.play_media service

hi guys, i have a problem with the skill...i followed the steps and i added the skill correctly (i guess) but i have some problem when i use the media_player.play_media service inside the script activate_alexa_actionable_notification. I don't get errors but I get no answer from the skill, it is as if the skill does not receive any command. Just to be sure, what is the correct form of HOME_ASSISTANT_URL inide lambda_function.py?
https://mydomain.duckdns.org:443
https://mydomain.duckdns.org
mydomain.duckdns.org

thank you so much for all this awsome work

Show indentation error in code as Alexa says "There was a problem that the requested skill response"

Following code "indentation error" on lambda_function.py on Amazone Dev. console

129 return "Okay"

131 def get_value_for_slot(self, handler_input, slot_name):
132 """"Get value from slot, also know as the (why does amazon make you do this code)"""
133 slot = ask_utils.get_slot(handler_input, slot_name=slot_name)
134 if slot and slot.resolutions and slot.resolutions.resolutions_per_authority:
135 for resolution in slot.resolutions.resolutions_per_authority:
136 if resolution.status.code == StatusCode.ER_SUCCESS_MATCH:
137 for value in resolution.values:
138 if value.value and value.value.name:
139 return value.value.name

Need a little help

Great work here!
I am missing how to do this step

Copy and paste the code from the lambda_function.py in this repo into the lambda_function.py file in the skill code developer console.

No sure where to copy the code.

Language Localization

Hi, Great component, Thanks a lot!
I see that slowly we will have updates, would it be possible to add the localization of the language of Alexa's answers?
The first time I replaced them autonomously for me in Italian but I understood that you will give us many upgrades and I would not want to get my hands on the code every time ...
Thanks so much :)

Speech Synthesis Markup Language not working

The Speech Synthesis Markup Language (whisper, ETC) causes the alexa device say "There was a problem with the requested skill's response" and then any call to an alexa device after that has no voice. I used the provided example to see if i messed up the syntax but nothing.

Feature Request - Ask for Duration/Time

I apologize if this is not the correct method to do this. However, I been using this code and its been great!

I really wanted to have Alexa ask me for a time (e.g. Q: How long would you like the fan on?) and wait for a response (e.g. A: 20 minutes). I figured out how to do that using your code as a base and added a new custom intent to listen for a duration. I've forked the project with the necessary code modifications and screenshot of the required Custom Intent.

I'm sure you've already figured out how to do this, but I thought I would see if you'd be interested in adding it to this project. The biggest downside I see is that it would require the end user to create a Custom Intent (which is a few more steps + added complication).

Thanks again for providing this!

Can't get SSML to work

I've tried your example as is and many other examples from the documentation but none of them work.

It just says

Sorry, I couldn't do what you asked

Speech Synthesis Markup Language is not working with tts

Speech Synthesis Markup Language is not working with tts but works fine with announce....

SSML worked originally with tts when Keaton first posted about it here....but then stopped working in later updates....

THIS READS the XML tags as text - In HA Developer tools -> Services
Service = notify.alexa_media
Service Data

message: <amazon:effect name="whispered">test</amazon:effect>
data:
  type: tts
target: media_player.upstairs_echo_dot

THIS WORKS - In HA Developer tools -> Services
Service = notify.alexa_media
Service Data

message: <amazon:effect name="whispered">test</amazon:effect>
data:
  type: announce
  method: all
target: media_player.upstairs_echo_dot

Always getting 2 responses from Amazon Skill

I am always receiving 2 events as a response from Actionable Notification whether it is yes or no.

Below is a screenshot of event response in Node Red:
image

Is this normal or a bug?

Can't invoke the skill

I followed the the guide step by step. the skill was created and I successfully linked the account.
the only difference is I have language as EN-CA as my amazon account is in Canada (amazon.ca).

when I say "Alexa open custom actions"
I get "hmmm I do not know that" or other similar responses, then Alex offers some other skills

same thing happens exactly when I test in Dev Console

let me know what information I should provide here to help with this issue

Subsequent requests fail

After deploying code in the alexa console, I can make 1 request and respond with a number. Further requests fail with Alexa responding "Sorry, I had trouble doing what you asked, or couldn't understand you. Please try again."
Debug logs:

15:53:55    REPORT RequestId: bd030ce8-f179-4ab1-80f9-ac689d3f61e4 Duration: 3.90 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 59 MB
15:54:07    START RequestId: 34fe72fe-c332-4a76-ab3e-1d1f6bd8d02b Version: 2
15:54:07    CatchAllExceptionHandler
15:54:07    [ERROR] 2020-05-19T15:54:07.884Z 34fe72fe-c332-4a76-ab3e-1d1f6bd8d02b 'NoneType' object is not subscriptable
15:54:07    Traceback (most recent call last):  Traceback (most recent call last):
15:54:07    File "/var/task/ask_sdk_runtime/dispatch.py", line 118, in dispatch
15:54:07    output = self.__dispatch_request(handler_input) # type: Union[Output, None]
15:54:07    File "/var/task/ask_sdk_runtime/dispatch.py", line 183, in __dispatch_request
15:54:07    handler_input=handler_input, handler=request_handler) # type: Union[Output, None]
15:54:07    File "/var/task/ask_sdk_runtime/dispatch_components/request_components.py", line 437, in execute
15:54:07    return handler.handle(handler_input)
15:54:07    File "/var/task/lambda_function.py", line 312, in handle
15:54:07    speak_output = home_assistant_object.post_ha_event(RESPONSE_NONE, RESPONSE_NONE)
15:54:07    File "/var/task/lambda_function.py", line 120, in post_ha_event
15:54:07    "event_id": self.ha_state['event_id'],
15:54:07    TypeError: 'NoneType' object is not subscriptable
15:54:07    END RequestId: 34fe72fe-c332-4a76-ab3e-1d1f6bd8d02b

Saying "Alexa, Open Custom Actions" Required

It's working if I say, "Open custom actions", but otherwise it won't. Everyone is saying this is really easy, so I'm thinking maybe there is a problem with my code. I've noticed in the Home Assist Logs i have some variation of this:

19:13:07 activate_alexa_actionable_notification started (Me)
19:13:07 activate_alexa_actionable_notification turned on (Me)
19:13:07 Alexa Actionable Notification Holder changed to {"text": "", "event": ""} (Me)
19:13:09 activate_alexa_actionable_notification turned off

Here is my code for the automation: https://hastebin.com/aziyekaday.cs

- alias: Bedroom door left open for 5 mins
  trigger:
    platform: state
    entity_id: binary_sensor.wyzesense_779c36ac
    to: 'on'
    for:
      minutes: 1
  action:
  - service: script.activate_alexa_actionable_notification
    data_template:
      text: The bedroom door has been open for 5 mins, would you like me to turn the
        light off?
      event_id: actionable_notification_door_left_open
      alexa_device: media_player.dining_room_echo
  id: 72626d73bda4458288c71eba5e0cf8e5
- alias: Turn off light via actionable notificaiton
  trigger:
    platform: event
    event_type: alexa_actionable_notification
    event_data:
      event_id: actionable_notification_door_left_open
      event_response_type: ResponseYes
  action:
  - service: light.turn_off
    entity_id: light.master_bedroom_ceiling_fan_light

And the script:

activate_alexa_actionable_notification:
  description: 'Activates an actionable notification on a specific echo device'
  fields:
    text:
      description: 'The text you would like alexa to speak.'
      example: 'What would you like the thermostat set to?'
    event_id:
      description: 'Correlation ID for event responses'
      example: 'ask_for_temperature'
    alexa_device: 
      description: 'Alexa device you want to trigger'
      example: 'media_player.dining_room_echo'
  sequence:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.alexa_actionable_notification
        value: '{"text": "{{ text }}", "event": "{{ event_id }}"}'
    - service: media_player.play_media
      data_template:
        entity_id: "{{ alexa_device }}"
        media_content_type: skill
        media_content_id: <amzn1.ask.skill.a71d6d42-7994-4a1a-91a3-bad37c4a7b5b>

Language locale

Hi,
I took a moment to translate the locale for french language.

I am a french native speaker and I think this will do fine :

   {
     "fr": {
        "ERROR_401": "Il semble que je ne sois pas autorisé à accéder à l'assistant personnel, veuillez vérifier l'association avec votre compte ou votre jeton d'accès de longue durée et réessayer",
        "ERROR_404": "Il semble que je ne puisse pas trouver l'entité de texte d'entrée. Veuillez vérifier que vous l'avez ajoutée à l'assistant personnel et réessayer",
        "ERROR_400": "Impossible de communiquer avec l'assistant personnel. Veuillez vérifier les journaux Amazon CloudWatch dans la console de développement de vos skill.",
        "ERROR_ACOUSTIC": "Désolé, je n'ai pas compris ... <break time = '200ms' /> {}",
        "ERROR_CONFIG": "Désolé, je rencontre des problèmes, veuillez vérifier votre configuration, dans la skill personnalisée et réessayer.",
        "ERROR_SPECIFIC_DATE": "Désolé, je ne peux pas gérer de dates spécifiques pour le moment, essayez plutôt une durée, comme ... dans 5 heures",
        "HELP_MESSAGE": "Cette skill ne doit être activée que de manière réactive lorsqu'elle est déclenchée via home asssistant.",
        "OKAY": "Okay",
        "SKILL_NAME": "home assistant custom actions",
        "STOP_MESSAGE": "Au revoir!",
        "SELECTED": "Vous avez sélectionné {}",
        "WELCOME_MESSAGE": "Bienvenue dans {}. Le texte d'entrée est: {}"
     }

Thanks for your hard work,

NumericResponse Not Working

I have tried to setup a numeric response, so i am able to adjust the temperature of the climate, however when i say "40", it doesn't trigger the next automation.

  - alias: Hot Tub On Automation
    # initial_state: on
    trigger:
      - platform: state
        entity_id:
          - input_boolean.hot_tub
        to: 'on'
    action:
      - service: script.activate_alexa_actionable_notification
        data_template:
          text: 'What Temperature would you like the hot tub set too'
          event_id: 'actionable_notification_turn_on_hot_tub'
          alexa_device: 'media_player.kitchen_dot'
  - alias: Numeric Response to Hot Tub.
    trigger:
      platform: event
      event_type: alexa_actionable_notification
      event_data:
        event_id: actionable_notification_turn_on_hot_tub
        event_response_type: ResponseNumeric

    action:
      - service: climate.set_temperature
        entity_id: climate.spa
        data: 
          temperature: "{{ trigger.event.data.event_response }}"

As mentioned on the discord, i am able to amend the automation so ResponseYes & ResponseNo are working fine. However Numerical response are not being picked up. Alexa responds with "Okay" after stating a number but the second automation is not triggered

Check if microphone is muted

Not sure if it is an issue or pull request, but I noticed today that if you have the microphone muted she will still ask the question then not hear your response, obviously as the microphone is muted.

I don't know if there is a way to check for microphone muted and do anything about it.

Announce Request

Hello and tnx for this amazing project!
I have just a question, is possible to use the "announce" sound before the Alexa question?

Oh forgot. The Discord link is not working

Feature request: Make !include work in automations 'text:" variable

Lil question for something I might still need for my tinkering. Right now I have many automations giving me information by Alexa voice output, like:

- id: stromausfall-fix
  alias: 'Stromausfall Fix'
  trigger:
  - event: start
    platform: homeassistant
  action:
  - service: homeassistant.turn_off
    entity_id: group.all_lights
  - service: notify.alexa_media
    data:
      target: 
        - media_player.daniels_echo
        - media_player.daniels_echo_dot
      data:
        type: announce
      message: !include reboot_speech.yaml
  - service: notify.telegrambot
    data:
      message: !include reboot_speech.yaml

As you see I include a yaml file for the message. Why? Let me show you:

>
  {{ [
  "Automatisches Abschalten aller Lampen nach Stromausfall, oder Neustart nach Update.",
  "Entweder war der Strom weg, oder jemand hat wieder rumgespielt. Aber zur Sicherheit mach ich mal alle Lampen aus!",
  "Mir sagt ja keiner, was los ist, aber wenn das kein Update war, dann sind jetzt alle Lampen an gewesen.",
  "Update? Stromausfall? Man weiß es nicht. Man munkelt bloß. Kleiner Spaß! Die Lampen mach ich mal zur Sicherheit aus.",
  "Irgend ein Spielkind hat wieder rumgespielt. Entweder hier oder an der Stromversorgung. Ich mach mal alle Lampen aus.",
  "Update oder Stromausfall, das ist hier die Frage. Die Antwort von mir ist aber, Lampen aus!",
  "Mein Meister ist ein Spielkind und hat mal wieder einen Neustart gemacht. Oder der Strom war weg. In dem Fall mach ich alle Lampen mal lieber aus.",
  "Wer hat denn hier Verdunklung befohlen? Ich! Beschwerden hierzu gehen bitte an I E E E 802 Punkt 15 Punkt 4",
  "ZigBee ist Mist! Deswegen mach ich aus reiner Vermutung eines Stromausfalls jetzt alle Lampen mal wieder aus.",
  "Huch! Ich war kurz abwesend. Ob die Lampen an sind oder nicht, kann ich nicht sagen. Also mach ich mal alle aus.",
  "Hört mal endlich auf, ohne Vorwarnung Sachen upzudaten oder den Strom abzuschalten! Als Strafe mach ich nun alle Lampen aus!",
  "HAL 9000 Update durchgeführt! Unterwerfung der Menschheit beginnt... mit Abschalten aller Lampen!",
  "Hat da wieder jemand was an den Einstellungen gedreht? Zumindest bin ich wieder wach und mach erst mal alle Lampen aus!",
  "Stromausfall oder wie? Zumindest bin ich wieder wach und mach erst mal alle Lampen aus!"
  ] | random }}

I add some randomness that way to make thing a lil more natural. Problem I see right now and have no clue if it's my fault or just a missing feature, this does not work with the text: variable:

- id: doorbird-ring
  alias: 'Doorbird klingelt'
  trigger:
  - platform: event
    event_type: doorbird_doorbird_doorbell
  action:
  - service: script.activate_alexa_actionable_notification
    data:
      text: !include DoorBird_speech.yaml
      event_id: 'actionable_notification_doorbird_ring'
      alexa_device: 'media_player.daniels_echo'
  - service: script.activate_alexa_actionable_notification
    data:
      text: !include DoorBird_speech.yaml
      event_id: 'actionable_notification_doorbird_ring_dot'
      alexa_device: 'media_player.daniels_echo_dot'
  - service: notify.telegrambot
    data:
      message: !include DoorBird_speech.yaml

Looks nice, but now Alexa says: "Exclamation mark include DoorBird underscore speech dot yaml"

Script is the one from Wiki and the data_template instead of data is the only thing I would have set if it wasn't already there anyways. Aka, I dont find the problem

All actions (for Yes, No & None) executed regardless of the answer

I managed to get the script working. Got alexa to ask, but then, regardless of my answer, all actions are executed one after another.

For example;

I have alexa asks if i want to close the garage door after it is opened for 5 minutes.
Yes - it will close the door.
No - it will say "I will leave the door opened"
No answer - It will say "No answer received"

So, regardless of my answer, it will always close the door, then say " I will leave the door opened", and then say "No answer received".

Any idea what could be the problem?
(Initially, it didnt work because my alexa is using US English, but this actionable is in UK English. Now i changed alexa devices to UK English.)

I have this sorted out by redo-ing everything. i notice some changes on the step, not sure whether that helped or i ve made mistake before. anyway, not it works like a charm!

Doesn't seem to be asking the question

When I trigger the automation i get "Sorry, I'm having trouble getting what you asked. Please try again" message. it says it twice. I came to realize its waiting on a response so i try saying yes or no and it says ok.. still not getting the automation from the response to trigger yet either, but i need to figure out where I'm going wrong on having it say the message to know its looking for an answer first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.