question

tleroy avatar image
tleroy asked

Smart Home Skill Discovery No Device Found

I am currently developing a Smart Home Skill for Amazon Voice Solution enabled device.

My lambda functions are setup as follow:

- US-east1 myAVSLambda

arn:aws:lambda:us-east-1:793444176480:function:myAVSDemoLambda

Triggered by my Alexa Smart Home, invoke another lambda located in us-east2 that will process the request.

from boto3 import client as boto3_client
from datetime import datetime
import json

#Initiate a lambda client for secondary function located in us-east-2 (IAS server)
lambda_client = boto3_client('lambda',region_name='us-east-2')

#Main handler
def lambda_handler(event, context):
    
    #Format in JSON request
    event_json = json.dumps(event, indent=4, sort_keys=True)
    
    #Invoke secondary lambda function
    invoke_response = lambda_client.invoke( FunctionName="arn:aws:lambda:us-east-2:793444176480:function:turnLightOn",
                                            InvocationType='RequestResponse',
                                            LogType='Tail',
                                            Payload=event_json)
    #Loads invokation respond payload
    ret = json.loads(invoke_response['Payload'].read().decode('ascii'))
    
    return ret

- US-east2 turnLightOn

arn:aws:lambda:us-east-2:793444176480:function:turnLightOn

This is the main lambda hanlder will return the discovery json structure to the other lambda.

{
  "event": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover.Response",
      "payloadVersion": "3",
      "messageId": "e7325871-61ba-43e4-a8cc-446bb1d7f0a6"
    },
    "payload": {
      "endpoints": [
        {
          "endpointId": "endpoint-001",
          "manufacturerName": "Sample Manufacturer",
          "friendlyName": "Switch",
          "description": "001 Switch that can only be turned on/off",
          "displayCategories": [
            "SWITCH"
          ],
          "cookie": {
            "detail1": "For simplicity, this is the only appliance",
            "detail2": "that has some values in the additionalApplianceDetails"
          },
          "capabilities": [
            {
              "type": "AlexaInterface",
              "interface": "Alexa.PowerController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "powerState"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa.EndpointHealth",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "connectivity"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa",
              "version": "3"
            }
          ]
       }
    }
  }
}

Testing this setup using the virtual event, all works great. But when trying to discover device from Alexa GUI, no device is found.


My Alexa Skill id : amzn1.ask.skill.40736a26-c91f-43b9-9e6c-b65e522612fe

It is configure to trigger my first lambda that is :

arn:aws:lambda:us-east-1:793444176480:function:myAVSDemoLambda



Thank you in advance for help,



skillsmart homedevice discovery
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tleroy avatar image
tleroy answered

Ok I found a workaround:

Locate my first lambda in the chain in the same region (EU, Irlande) as the language set in the Smart Home Skill (French).


This region configuration between Alexa Account, device language/time-zone and lambda server location is not easy to get. Can expand on that a little more?


Thanks

4 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello and thanks for sharing the solution that worked for you.

In this page you have more information regarding the region of your AWS Lambda code and the device's location.

Regards,
Barry

0 Likes 0 ·
Phil McGee avatar image Phil McGee Amazon_Bernardo Bezerra ♦♦ ·

It mentions latency issues as the reason for selecting the location. It does not explicitly say it will simply not work if you don't select the matched-option. That is misleading. When you create the lambda function for your skill, it also says 'choose the server closest to your customers' - it omits to tell you you HAVE to choose Virginia for a us_EN skill even if you live next door to the server in Ireland or Frankfurt with zero latency.

0 Likes 0 ·

Thanks for your feedback @philchillbill.

I will pass along to the team responsible for documentation to have that particular page updated.

Regards,
Barry

0 Likes 0 ·
Show more comments
tleroy avatar image
tleroy answered

When I check the CloudWatch statistic of my first lambda function after clicking discovery, I see that it doesn't even get triggered by the Alexa Smart Home Skill. The configuration of the link between Alexa & AWS lambda is correct, checked many times.


My device is located in EU, connected to IAS server in Us-east2.



10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.