Giter VIP home page Giter VIP logo

st-schema-nodejs's Issues

Check if body.authentication exists

Hi,
in the SchemaConnector file, for each interaction type, the token is directly taken from the body.authentication, but if it don't exist, the error TypeError: Cannot read property 'token' of undefined is thrown.

Accord to SmartThings documentation, this case can throw a specific error :

{
...
  "globalError": {
    "errorEnum": "BAD-REQUEST",
    "detail": "missing st-schema authentication"
  },
...
}

It will improve the schema compliance.

Add support for 'interactionResult' interaction

If you run the framework without handling the certain phase, such as the discovery phase, your connector will print out the following message:

ERROR: {"headers":{"schema":"st-schema","version":"1.0","interactionType":"interactionResult","requestId":"C29856C5-B6F8-4374-ABD0-E42A41C9F1CF"},"globalError":{"detail":"Unsupported interactionType: 'interactionResult'","errorEnum":"INVALID-INTERACTION-TYPE"}}

This seems to occur when a required interaction does not have a corresponding & responding handler.

Question. connector's state refresh polling time

Hi,

I would like to know the reason of 6 hours polling time.
why schema connector works per 6 hours for polling ? what's the background of this number ?

Connector app structure
const connector = new SchemaConnector()
.discoveryHandler((accessToken, response) => {
/**
* Discovery request. Respond with a list of devices. Called after installation of the
* connector and every six hours after that.
* @accesstoken External cloud access token
* @response {DiscoveryResponse} Discovery response object
*/
})

request object is undefined in lambda.js

When I tested lifx-connector(https://github.com/SmartThingsCommunity/st-schema-connectors/tree/master/lifx-connector) in aws lambda, request object is undefined.

await opts[interactionType](request, response);

So I met below error message.

ERROR MESSAGE START

2019-05-26T23:53:19.544Z 32ad93e2-0f34-49e9-837f-6c4993444593 interactionType discoveryRequest
2019-05-26T23:53:19.545Z 32ad93e2-0f34-49e9-837f-6c4993444593 ERROR IN ST-SCHEMA HELPER TypeError: Cannot read property 'authentication' of undefined
at Object.discoveryRequest (/var/task/index.js:9:84)
at /var/task/node_modules/st-schema/lib/lambda.js:82:34 await opts[interactionType](request, response);

ERROR MESSAGE END

I think below line is needed before line 80.
request = event;

What do you think?

deviceCookie missing in Device class

There seem to be no support in st-schema-nodejs for adding deviceCookie as part of discoveryResponse. Please refer properties supported currently in the "class Device: in DiscoveryDevice.js
/*

Please update st-schema-nodejs lib with support for deviceCookie.

State Refresh Handler does not make devices from request available

According to the SmartThings documentation, the state refresh incoming request contains the list of devices which require a state update:
https://smartthings.developer.samsung.com/docs/devices/smartthings-schema/smartthings-schema-reference.html#State-Refresh

However, this framework's state refresh handler fails to make these available to the dev:

.stateRefreshHandler((accessToken, response) => {
    /**
     * State refresh request. Respond with the current states of all devices. Called after
     * device discovery runs.
     * @accessToken External cloud access token
     * @response {StateRefreshResponse} StateRefresh response object
     */
  })

Unlike the handler for commands, which does:

.commandHandler((accessToken, response, devices) => {})

Response's 'setError' should take precedence on any other response

If setError is called, the Response should ignore further calls to other convenience methods and it should take precedence.

If called from a loop, the method can then be used to ignore previous or future calls to other methods without a need to prevent them using a check on isError.

devices.forEach(device => {
  if (/* something */) {
    response.setError(`Something happened, let's leave it at that.`);
  }
});

Add SmartThings API framework dependency

This SDK could benefit from having a SmartThings API framework as a dependency to simplify making calls from the connector to SmartThings, such as when trying to update the state of a device outside of a connector interaction.

This could simply be a suggestion in the README, as these calls are not a requirement for integrations to operate, thus the package could be optional.

Unfortunately, there is no public SmartThings API framework at the moment (which isnt outdated). The one from https://github.com/SmartThingsCommunity/smartapp-sdk-nodejs should be extracted, and both SDKs should make it a dependency (separately maintained).

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.