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,