Alexa Custom Skill do not start HA Script and i do not know why

Hi together,
i have installed and configured HA and Alexa custom skill. If i ask Alexa with the right utterance “Alexa, ask butler alfred ping zztestscript” the connection between HA and Amazon is ok. Alexa gives me the right answer, but do not execute the script.

The configuration is done via this manual: Amazon Alexa Custom Skill - Home Assistant

This is the outcome of the debug log in HA:

2023-01-17 14:31:41.413 DEBUG (MainThread) [homeassistant.components.alexa.intent] Received Alexa request: {'version': '1.0', 'session': {'new': True, 'sessionId': 'amzn1.echo-api.session.xxxxxxxxxxx', 'application': {'applicationId': 'amzn1.ask.skill.xxxxxxxxxxxxxxx'}, 'attributes': {}, 'user': {'userId': 'amzn1.ask.account.xxxxxxxxxxxxxxxxxxxxxx', 'accessToken': 'xxxxxxxxxxxxx'}}, 'context': {'Viewports': [{'type': 'APL', 'id': 'main', 'shape': 'RECTANGLE', 'dpi': 213, 'presentationType': 'STANDARD', 'canRotate': False, 'configuration': {'current': {'mode': 'HUB', 'video': {'codecs': ['H_264_42', 'H_264_41']}, 'size': {'type': 'DISCRETE', 'pixelWidth': 1280, 'pixelHeight': 800}}}}], 'Viewport': {'experiences': [{'arcMinuteWidth': 346, 'arcMinuteHeight': 216, 'canRotate': False, 'canResize': False}], 'mode': 'HUB', 'shape': 'RECTANGLE', 'pixelWidth': 1280, 'pixelHeight': 800, 'dpi': 213, 'currentPixelWidth': 1280, 'currentPixelHeight': 800, 'touch': ['SINGLE'], 'video': {'codecs': ['H_264_42', 'H_264_41']}}, 'Extensions': {'available': {'aplext:backstack:10': {}}}, 'System': {'application': {'applicationId': 'amzn1.ask.skill.xxxxxxxxxxx'}, 'user': {'userId': 'amzn1.ask.account.xxxxxxxxxxx', 'accessToken': 'xxxxxxxxxxx'}, 'device': {'deviceId': 'amzn1.ask.device.xxxxxxxxxxx', 'supportedInterfaces': {}}, 'apiEndpoint': 'https://api.eu.amazonalexa.com', 'apiAccessToken': 'xxxxxxxxxxx'}}, 'request': {'type': 'IntentRequest', 'requestId': 'amzn1.echo-api.request.xxxxxxxxxxx', 'locale': 'de-DE', 'timestamp': '2023-01-17T13:31:41Z', 'intent': {'name': 'Ping', 'confirmationStatus': 'NONE', 'slots': {'pings': {'name': 'pings', 'value': 'zztestscript', 'resolutions': {'resolutionsPerAuthority': [{'authority': 'amzn1.er-authority.echo-sdk.amzn1.ask.skill.xxxxxxxxxxx.Pings', 'status': {'code': 'ER_SUCCESS_MATCH'}, 'values': [{'value': {'name': 'zztestscript', 'id': 'xxxxxxxxxxx'}}]}]}, 'confirmationStatus': 'NONE', 'source': 'USER', 'slotValue': {'type': 'Simple', 'value': 'zztestscript', 'resolutions': {'resolutionsPerAuthority': [{'authority': 'amzn1.er-authority.echo-sdk.amzn1.ask.skill.xxxxxxxxxxx.Pings', 'status': {'code': 'ER_SUCCESS_MATCH'}, 'values': [{'value': {'name': 'zztestscript', 'id': 'xxxxxxxxxxx'}}]}]}}}}}}}

Intent config in HA:

  Ping:
    action:
    service: script.turn_on
    target:
      entity_id: script.{{ pings | replace(" ", "_") }}
    speech:
      type: plain
      text: Ping erfolgreich

HA sample script:

alias: zztestscript
sequence:
  - type: turn_on
    device_id: xxxxxxxx
    entity_id: switch.licht
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - type: turn_off
    device_id: xxxxxxxx
    entity_id: switch.licht
    domain: switch
mode: single

Alexa Skill config:

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "butler alfred",
            "intents": [
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.NavigateHomeIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.FallbackIntent",
                    "samples": []
                },
                {
                    "name": "Ping",
                    "slots": [
                        {
                            "name": "pings",
                            "type": "Pings"
                        }
                    ],
                    "samples": [
                        "Ping",
                        "ping {pings}"
                    ]
                }
            ],
            "types": [
                {
                    "name": "Pings",
                    "values": [
                        {
                            "name": {
                                "value": "zztestscript"
                            }
                        }
                    ]
                }
            ]
        }
    }
}

I do not know where i can find the issue, that the script is not startet. Any idea?

Thanks a lot!

I have seen, that there are some more log details that may help to solve the problem:

2023-01-17 15:31:46.284 DEBUG (MainThread) [homeassistant.components.alexa.intent] Received Alexa request: {'version': '1.0', 'session': {'new': True, 'sessionId': 'amzn1.echo-api.session.xxxxxxxxx', 'application': {'applicationId': 'amzn1.ask.skill.xxxxxxxxx'}, 'attributes': {}, 'user': {'userId': 'amzn1.ask.account.xxxxxxxxx', 'accessToken': 'xxxxxxxxx'}}, 'context': {'Viewports': [{'type': 'APL', 'id': 'main', 'shape': 'RECTANGLE', 'dpi': 213, 'presentationType': 'STANDARD', 'canRotate': False, 'configuration': {'current': {'mode': 'HUB', 'video': {'codecs': ['H_264_42', 'H_264_41']}, 'size': {'type': 'DISCRETE', 'pixelWidth': 1280, 'pixelHeight': 800}}}}], 'Viewport': {'experiences': [{'arcMinuteWidth': 346, 'arcMinuteHeight': 216, 'canRotate': False, 'canResize': False}], 'mode': 'HUB', 'shape': 'RECTANGLE', 'pixelWidth': 1280, 'pixelHeight': 800, 'dpi': 213, 'currentPixelWidth': 1280, 'currentPixelHeight': 800, 'touch': ['SINGLE'], 'video': {'codecs': ['H_264_42', 'H_264_41']}}, 'Extensions': {'available': {'aplext:backstack:10': {}}}, 'System': {'application': {'applicationId': 'amzn1.ask.skill.xxxxxxxxx'}, 'user': {'userId': 'amzn1.ask.account.xxxxxxxxx', 'accessToken': 'xxxxxxxxx'}, 'device': {'deviceId': 'amzn1.ask.device.xxxxxxxxx', 'supportedInterfaces': {}}, 'apiEndpoint': 'https://api.eu.amazonalexa.com', 'apiAccessToken': 'xxxxxxxxx'}}, 'request': {'type': 'IntentRequest', 'requestId': 'amzn1.echo-api.request.68fe9238-1e79-438d-a843-f20cc1e02528', 'locale': 'de-DE', 'timestamp': '2023-01-17T14:31:45Z', 'intent': {'name': 'Ping', 'confirmationStatus': 'NONE', 'slots': {'pings': {'name': 'pings', 'value': 'zztestscript', 'resolutions': {'resolutionsPerAuthority': [{'authority': 'amzn1.er-authority.echo-sdk.amzn1.ask.skill.xxxxxxxxx.pings', 'status': {'code': 'ER_SUCCESS_MATCH'}, 'values': [{'value': {'name': 'zztestscript', 'id': 'xxxxxxxxx'}}]}]}, 'confirmationStatus': 'NONE', 'source': 'USER', 'slotValue': {'type': 'Simple', 'value': 'zztestscript', 'resolutions': {'resolutionsPerAuthority': [{'authority': 'amzn1.er-authority.echo-sdk.amzn1.ask.skill.xxxxxxxxx.pings', 'status': {'code': 'ER_SUCCESS_MATCH'}, 'values': [{'value': {'name': 'zztestscript', 'id': 'xxxxxxxxx'}}]}]}}}}}}}
2023-01-17 15:31:46.285 INFO (MainThread) [homeassistant.helpers.intent] Triggering intent handler <ScriptIntentHandler - Ping>
2023-01-17 15:31:46.288 DEBUG (MainThread) [homeassistant.components.intent_script] Intent named Ping received with slots: {'pings': 'zztestscript'}
2023-01-17 15:31:46.288 INFO (MainThread) [homeassistant.helpers.script.intent_script_ping] Intent Script Ping: Running intent_script script

On first glance I see wrong indentation in the action part of your intent.

Maybe a stupid question, but why do you use intents to start scripts, which works natively with the smart home skill?

What did you mean exactly? Can you explain, please?

Scripts work with the smart home skill? Thats new for me. I’m going to have a look at the manual again.
The reason for working with scripts (and other things) for me is, that i would like to have all the intelligence and automation things within HA as centralized thing. Alexa should be only the voice assistant.

Service, target and enitty_id need to move to the right.

Scripts are treated as scenes by Alexa. As I suppose you speak German, you can activate them by saying “Aktiviere Skriptname”. Or you can create a routine with a custom command that activates a scene (which is in fact the script).

1 Like

That was the problem, many thanks :slight_smile:

For all who have the same problem, here is the right intent config:

  Ping:
    action:
      service: script.turn_on
      target:
        entity_id: script.{{ pings | replace(" ", "_") }}
    speech:
      type: plain
      text: Ping erfolgreich

But with the smart home integration you got all scripts/scenes as devices. Thats too much for me within Alexa. So it is better for me to work with intents.

Thanks a lot for fast help!