Some fun with Alexa on a Friday afternoon

Hmm. I recently saw this on a thread over here:

same issue, the list would only randomize once. At the time I responded to that thread, I was on .35 and not having the issue (at least I don’t think I was!) But now, on .37, it looks like the random filter is broken.

Opened an issue:

1 Like

Confirmed on my system as well and I’ll report over at the issue.

Have you tried using ngork to set up custom skills?

Hi,

I’m trying this on my current setup but somehow its not working. I see the following error
WARNING:homeassistant.components.alexa:Received unknown intent ActivateSceneIntent

my alexa.yaml has the following config:
ActivateSceneIntent:
action:
service: scene.turn_on
data_template:
entity_id: scene.{{ Scene | replace(" ", “_”) }}
speech:
type: plaintext
text: OK

my scenes.yaml

name: TV
entities:
switch.living_room_tv:
state: on

on amazon side I have the following:

Intent schema

{
  "intent": "ActivateSceneIntent",
  "slots": [
    {
      "name": "Scene",
      "type": "Scenes"
    }
  ]
}

Sample Utterances
ActivateSceneIntent activate {Scene}

Any idea what is missing?

Have you checked home-assistant.log for errors? If this is your first Alexa intent, it could be that you haven’t set it up correctly - in that case, it wouldn’t be available to HA.

Try posting using preformatted text to see if we can spot an issue.

And be sure that you’ve included that alexa.yaml in your main config (I know - basic - but it happens)

alexa:
  intents: !include alexa.yaml

Hi,
I’m loosing somewhere and I don’t know where.
alexa: intents: ActivateSceneIntent: action: service: scene.turn_on data_template: entity_id: scene.{{ Scene | replace(" ", "_") }} speech: type: plaintext text: OK

When I ask Alexa she say hello but HASS error:
17-04-11 14:54:18 ERROR (MainThread) [homeassistant.core] Invalid service data for scene.turn_on: Entity ID scene. is an invalid entity id for dictionary value @ data[‘entity_id’]. Got ‘scene.’

Looks like a problem with the template but I don’t know where.

same here, i dont get an error though. i just get: 17-04-12 22:59:00 INFO (MainThread) [homeassistant.components.http] Serving /api/alexa to xx.xx.xx.xx (auth: True) in the log.

anything changed recently? i also dont get confirmation from alexa and it looks like this from the amazon developer console:
{
“version”: “1.0”,
“response”: {
“shouldEndSession”: true
},
“sessionAttributes”: {}
}

normally you should see the speech return here

Restore randomness to Alexa confirmations:

1 Like

Giving this a try - thanks @ih8gates! How did you figure this out?

I really missed my random playlists. I have random music start my day as an alarm and I wanted the randomness back, so I thought I’d do some spelunking.

@7h30n3 did some helpful experiments that he noted on the issue:
https://github.com/home-assistant/home-assistant/issues/5678#issuecomment-283031918

Since range still produced random numbers, I experimented with using that. Then I hit the Jinja docs to figure out the syntax for getting the length of a list…

1 Like

can confirm this works, good catch!

Same here - I liked the post but forgot to respond; so nice to have my random replies back. Thanks again, @ih8gates!

hi, I was trying custom command to use with Alexa. It works when I try to test in Service Simulator you can find screenshot below. even it responds success command when I when I speak to Alexa “ask home assistant to turn on ac” but it does not trigger script. someone, please help me

this my Intent Schema

{
  "intents": [
    {
      "slots": [
        {
          "name": "User",
          "type": "AMAZON.US_FIRST_NAME"
        }
      ],
      "intent": "LocateIntent"
    },
    {
      "intent": "WhereAreWeIntent"
    },
    {
      "slots": [
        {
          "name": "Script",
          "type": "Scripts"
        }
      ],
      "intent": "RunScriptIntent"
    }
  ]
}

Custom Slot Types & Sample Utterances

config in HA

alexa:
  intents:
    WhereAreWeIntent:
      speech:
        type: plaintext
        text: >
          {%- if is_state('device_tracker.ashu_ashu', 'home') and
                 is_state('device_tracker.afu_afu', 'home') -%}
            You are both home, you silly
          {%- else -%}
            Afu is at {{ states("device_tracker.afu_afu") }}
            and Ashu is at {{ states("device_tracker.ashu_ashu") }}
          {% endif %}

    LocateIntent:
      action:
        service: notify.notify
        data_template:
          message: The location of {{ User }} has been queried via Alexa.
      speech:
        type: plaintext
        text: >
          {%- for state in states.device_tracker -%}
            {%- if state.name.lower() == User.lower() -%}
              {{ state.name }} is at {{ state.state }}
            {%- elif loop.last -%}
              I am sorry, I do not know where {{ User }} is.
            {%- endif -%}
          {%- else -%}
            Sorry, I don't have any trackers registered.
          {%- endfor -%}
      card:
        type: simple
        title: Sample title
        content: Some more content
        
    RunScriptIntent:
      action:
        service: script.turn_on
        data_template:
          entity_id: script.{{ Script | replace(" ", "_") }}
      speech:
        type: plaintext
        text: !include alexa_confirm.yaml

Service Simulator

I think that sample utterance might be your issue. I’m not sure that Alexa can extract {Script}ekn and just return the “Script” part of the phrase. I bet you’re not getting a value for Script that you expect. Perhaps do something where you can see the actual text value of Script, like create a notification.

In your home-assistant.log, you’ve likely got errors telling you that the script that it attempted to run does not exist.

1 Like

yes.i think “ekn” was creating issue removed that and it works fine now.

I can’t be sure off the top of my head but I think you need to change “plaintext” to “plain”.

You don;t have to submit the skill, just keep it in dev mode (i.e. don;t submit) and it will work just for you.

I remember I used to have that problem way back in the beginning. I cant remember exactly what I did to fix it but it was in my intent/script that I had something off.

you just need to verify your syntax & indentations are all good.

at least you’ve passed a major hurdle! the alexa dev works!

The https://developer.amazon.com/alexa was changed this year, its all new and i cant figure a way out to create a correct integration with my HA. Can someone update the section https://www.home-assistant.io/cloud/alexa/ to the new layout?
And, can i use this random speech with Alexa Cloud on HA?

@aimc
Are you still using this within the new auth setup? This Alexa skill is my last thing that needs to be moved over and I haven’t figured out how to do it.
Thanks