Hello everyone,
I’m working on the integration of my company device in the smart things platform.
We have a cloud connected device.
The device has multiple capabilities: 5 energyMeter and 2 powerMeter.
I would like to update the state of the 5 energy meters each day (so if i’m not wrong this should be the default behaviour and smart things should call my cloud with the state refresh once per day)
While for the 2 power meters, i would like to update their values every 5 seconds.
To do this i need to push the updated state, but i’m having trouble understanding something.
I think i need to do the following requests:
-
https://c2c-eu.smartthings.com/oauth/token
accessTokenRequest
To obtain the accessToken required for the stateCallback -
https://c2c-eu.smartthings.com/device/events
To perform the stateCallback and update the data.
The problems i found are:
A. To do the first request i need a ‘code’ inside the callbackAutehntication
“callbackAuthentication”: {
“grantType”: “authorization_code”,
“code”: “device-related-code”,
“clientId”: “my-client-id”,
“clientSecret”: “my-client-secret”
}
The only way i found to obtain this code is during the “grantCallbackAccess” request i receive from smart things after the first login to the oauth client during the first device registration on the Smart thign app.
Is this code without expiration?
If it has an expiration, how can i obtain it again?
B. The other problem is related to the stateCallback.
I did some trials and what i discoverd is that, since i use a device related ‘code’ to obtain the accessToken , then the stateCallback request allows me to update the state of that device only.
So i need to retrieve the ‘code’ for each device and use it for the accessToken request and finally use for each device its own token to update its state every 5 seconds during the day. Is this correct or am i missing something? Is there a way to update all customers devices state with only one request?
In short, i need to refresh the state of all my customers base devices each 5 seconds, is there any guide or advice tou can give me to complete the integration?
Thank you so much for you time and patience