Giter Club home page Giter Club logo

skill-sample-nodejs-smarthome-switch's Introduction

Skill Sample : Smarthome Switch (Node.js)

This is a basic Alexa Smart Home skill sample that implements a virtual switch. It shows the discovery and directive handling process for a virtual device implementing Alexa Smart Home switch capabilities.

Instructions

To use this sample, follow the Instructions.

License

This library is licensed under the Amazon Software License.

skill-sample-nodejs-smarthome-switch's People

Contributors

aszk avatar kunalhsatoz avatar mikemaas-amazon 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

Watchers

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

skill-sample-nodejs-smarthome-switch's Issues

Unexpected token function

I've been following the tutorial, so far so good..
Now to test the Lambda function... and I'm getting an error:

Syntax error in module 'index': SyntaxError
exports.handler = async function (event, context) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

Any ideas??

Import module aws/sdk error with Node 18

Hello,

I have the following error:

2023-08-15T18:18:53.309Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:997:17)",
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1029:21)",
" at async start (file:///var/runtime/index.mjs:1192:23)",
" at async file:///var/runtime/index.mjs:1198:1"
]
}

I am using Node v18

Discover Device by Alexa Skill

I followed each step in instructions and created a lambda function in Virginia region as per given.
I made a test execution on lambda function and it is successful, returning the dummy sample switch(confirmed in logs)
But from Alexa's skill, the account link showed successful as well, but no virtual switch is discovered and no logs in lambda function.

I have an Alexa account, I try to login to https://alexa.amazon.com/ it redirects me to https://alexa.amazon.in/. (I am from India)

What may be the issue? Why Alexa's skill is not triggering my lambda function?

DynamoDB update item not working

Hi, trying this example i see that the dynamodb updateItem (i've tryed also putItem) doesn't work.
The response to the request.send is this:

2020-03-13T23:48:43.174Z	27d6c4a5-4927-19ec-7050-361fd4053906	INFO	Response {
  request: Request {
    domain: null,
    service: Service {
      config: [Config],
      isGlobalEndpoint: false,
      endpoint: [Endpoint],
      _events: [Object],
      MONITOR_EVENTS_BUBBLE: [Function: EVENTS_BUBBLE],
      CALL_EVENTS_BUBBLE: [Function: CALL_EVENTS_BUBBLE],
      _clientId: 1
    },
    operation: 'updateItem',
    params: {
      TableName: 'SampleSmartHome',
      Key: [Object],
      AttributeUpdates: [Object],
      ReturnValues: 'UPDATED_NEW'
    },
    httpRequest: HttpRequest {
      method: 'POST',
      path: '/',
      headers: [Object],
      body: '{"TableName":"SampleSmartHome","Key":{"ItemId":{"S":"sample-switch-04"}},"AttributeUpdates":{"powerStateValue":{"Action":"PUT","Value":{"S":"ON"}}},"ReturnValues":"UPDATED_NEW"}',
      endpoint: [Endpoint],
      region: 'eu-west-1',
      _userAgent: 'aws-sdk-nodejs/2.585.0 linux/v12.15.0 exec-env/AWS_Lambda_nodejs12.x',
      stream: [ClientRequest]
    },
    startTime: 2020-03-13T23:48:43.097Z,
    response: [Circular],
    _asm: AcceptorStateMachine { currentState: 'send', states: [Object] },
    _haltHandlersOnError: false,
    _events: {
      validate: [Array],
      afterBuild: [Array],
      restart: [Array],
      sign: [Array],
      validateResponse: [Array],
      send: [Array],
      httpHeaders: [Array],
      httpData: [Array],
      httpDone: [Array],
      retry: [Array],
      afterRetry: [Array],
      build: [Array],
      extractData: [Array],
      extractError: [Array],
      httpError: [Array],
      success: [Array],
      complete: [Array]
    },
    emit: [Function: emit],
    API_CALL_ATTEMPT: [Function: API_CALL_ATTEMPT],
    API_CALL_ATTEMPT_RETRY: [Function: API_CALL_ATTEMPT_RETRY],
    API_CALL: [Function: API_CALL],
    signedAt: 2020-03-13T23:48:43.108Z
  },
  data: null,
  error: null,
  retryCount: 0,
  redirectCount: 0,
  httpResponse: HttpResponse {
    statusCode: undefined,
    headers: {},
    body: undefined,
    streaming: false,
    stream: null,
    _abortCallback: [Function: callNextListener]
  },
  maxRetries: 10,
  maxRedirects: 10
}

Alexa don't respone "OK" messages

As instruction, After send "alexa, turn on sample switch", Alexa should respond with "OK". But In my sample switch, It just return "". I can see respose JSON in the Skill Logs.

image

image

I can't choose Nodejs 8.10 on AWS Lambda - directiveDiscovery Test failed

I can't choose nodejs 8.10 version on AWS. So, I try to choose Nodejs 12.x.

When I run "directiveDiscovery" test it closed with error:

2020-08-23T13:42:15.459Z undefined ERROR Uncaught Exception
{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Unexpected token 'export'",
"stack": [
"Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token 'export'",
" at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object. (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1138:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)",
" at Module.load (internal/modules/cjs/loader.js:986:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:879:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)",
" at internal/main/run_main_module.js:17:47"
]
}

Failed at Set Allowed Return URLs

Following kind-of OK up to here. Can NOT get a selection "Web Settings" tab. Security Profile shows App list empty. Possibly I have failed at a previous step?

Will be back tomorrow to go back over all the steps.

IF this is a NEW example, and it needs updating, I already have several items to submit to help the document.... Will this document be updated? Or is this a very old example that does not match the tool menus and we shall just interpret where needed???

Discover Devices

Discover Devices not working.
testing not working error massage is

Response:
{
"errorMessage": "2020-05-16T17:50:44.171Z 47546ffe-6e58-44d2-a9d1-855163d70851 Task timed out after 3.00 seconds"
}

Request ID:
"47546ffe-6e58-44d2-a9d1-855163d70851"

Function Logs:
START RequestId: 47546ffe-6e58-44d2-a9d1-855163d70851 Version: $LATEST
END RequestId: 47546ffe-6e58-44d2-a9d1-855163d70851
REPORT RequestId: 47546ffe-6e58-44d2-a9d1-855163d70851 Duration: 3003.16 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 20 MB
2020-05-16T17:50:44.171Z 47546ffe-6e58-44d2-a9d1-855163d70851 Task timed out after 3.00 seconds

uuid is not a function

Good afternoon. I followed the whole tutorial, but there is no way to select NodeJS 8.x anymore, only 10.x and 12.x.

Selecting 10.x or 12.x, the same error occurs:
{ "errorType": "TypeError", "errorMessage": "uuid is not a function", "trace": [ "TypeError: uuid is not a function", " at new AlexaResponse (/var/task/alexa/skills/smarthome/AlexaResponse.js:58:62)", " at Runtime.exports.handler (/var/task/index.js:67:19)", " at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)" ] }

Logs:
START RequestId: d7a4d7c7-48aa-425f-a00d-d15023a55eb1 Version: $LATEST 2020-03-08T15:42:29.039Z d7a4d7c7-48aa-425f-a00d-d15023a55eb1 INFO index.handler request ----- 2020-03-08T15:42:29.054Z d7a4d7c7-48aa-425f-a00d-d15023a55eb1 INFO {"directive":{"header":{"namespace":"Alexa.Discovery","name":"Discover","payloadVersion":"3","messageId":"1bd5d003-31b9-476f-ad03-71d471922820"},"payload":{"scope":{"type":"BearerToken","token":"access-token-from-skill"}}}} 2020-03-08T15:42:29.074Z d7a4d7c7-48aa-425f-a00d-d15023a55eb1 INFO index.handler context ----- 2020-03-08T15:42:29.074Z d7a4d7c7-48aa-425f-a00d-d15023a55eb1 INFO {"callbackWaitsForEmptyEventLoop":true,"functionVersion":"$LATEST","functionName":"skill-sample-nodejs-smarthome-switch","memoryLimitInMB":"128","logGroupName":"/aws/lambda/skill-sample-nodejs-smarthome-switch","logStreamName":"2020/03/08/[$LATEST]42601907f8394b98b95965e6a815575f","invokedFunctionArn":"arn:aws:lambda:us-east-1:534427607265:function:skill-sample-nodejs-smarthome-switch","awsRequestId":"d7a4d7c7-48aa-425f-a00d-d15023a55eb1"} 2020-03-08T15:42:29.075Z d7a4d7c7-48aa-425f-a00d-d15023a55eb1 ERROR Invoke Error {"errorType":"TypeError","errorMessage":"uuid is not a function","stack":["TypeError: uuid is not a function"," at new AlexaResponse (/var/task/alexa/skills/smarthome/AlexaResponse.js:58:62)"," at Runtime.exports.handler (/var/task/index.js:67:19)"," at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"]} END RequestId: d7a4d7c7-48aa-425f-a00d-d15023a55eb1 REPORT RequestId: d7a4d7c7-48aa-425f-a00d-d15023a55eb1 Duration: 78.50 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 87 MB Init Duration: 345.32 ms

How to fix this error?

Developing skill in pt-BR.

device discovery is not working for me.

After following all the steps found that, device discovery is not working for me.
kindly help.

when i discover devices, i get bellow response.
I couldn't find any new Smart Home devices. If you’ve ‎n't already, please enable the smart home skill for your device from the Alexa App.

Task timed out error

Response:
{
"errorMessage": "2020-11-10T05:46:57.874Z 160788cd-45ff-4583-809f-c7e31127cb95 Task timed out after 3.07 seconds"
}

Request ID:
"160788cd-45ff-4583-809f-c7e31127cb95"

Function logs:
START RequestId: 160788cd-45ff-4583-809f-c7e31127cb95 Version: $LATEST
END RequestId: 160788cd-45ff-4583-809f-c7e31127cb95
REPORT RequestId: 160788cd-45ff-4583-809f-c7e31127cb95 Duration: 3071.27 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 21 MB
2020-11-10T05:46:57.874Z 160788cd-45ff-4583-809f-c7e31127cb95 Task timed out after 3.07 seconds

Documentation

Is there any documentation to describe usage of AlexaReponse.js ?

Thanks

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.