I am developing a SmartThings Schema connector to integrate my own service which provides third-party devices to ST. I use the webhook method for this purpose. Currently my service could respond to all interaction types (discovery, stateRefresh, grantCallbackAccess, discovery callback) correctly except the device state callback. In other word, I could use “My Testing Devices” to add devices in my own service; my service can push newly added devices to ST; ST can actively pull device states from my service. However, my service fails to push device states to ST actively.
for (accessToken in accessTokens_ST) {
console.log(accessToken);
const stateUpdateRequest = new StateUpdateRequest(process.env.ST_CLIENT_ID, process.env.ST_CLIENT_SECRET);
stateUpdateRequest.updateState(accessTokens_ST[accessToken].callbackUrls, accessTokens_ST[accessToken].callbackAuthentication, deviceState, async (refreshCallbackAuthentication) => {
console.log("here2");
accessTokens_ST[accessToken].callbackAuthentication = refreshCallbackAuthentication;
db.addTokens(accessTokens_ST);
}).then(res => {return res.json()}) // expecting a json response
.then(json => {console.log(json)}, err => {console.log(err)}).finally(() => {});
}
As the code block shows, I use the st-schema-nodejs APIs to send stateUpdateRequest to SmartThings with the access token (which is used to send discovery callback requests successfully). However, I receive a 500 response from SmartThings cloud.
FetchError { statusCode: 500, message: '500 - Internal Server Error' }
Does anybody have the same issue? Do state callback and discovery callback use different access tokens for authentication? Or is it just because SmartThings cloud does not allow me to update the states of devices provided by my service. I appreciate any interest or feedback.