I am implementing SmartThings Cloud Connected devices to my system.
I faced a problem while sending Device State Callback:
After OAuth login, finishing Discovery interaction type response and saving the access token to my system, I sent a Device State Callback request to smartThings like this:
{
"authentication": {
"tokenType": "Bearer",
"token": "###"
},
"deviceState": [
{
"externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
"states": [
{
"attribute": "level",
"value": 25,
"capability": "st.switchLevel",
"timestamp": 1633318280000,
"component": "main"
},
{
"attribute": "switch",
"value": "on",
"capability": "st.switch",
"timestamp": 1633318280000,
"component": "main"
},
{
"attribute": "healthStatus",
"value": "online",
"capability": "st.healthCheck",
"timestamp": 1633318280000,
"component": "main"
}
]
},
{
"externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
"states": [
{
"attribute": "fanSpeed",
"value": 0,
"capability": "st.fanSpeed",
"timestamp": 1633318281000,
"component": "main"
},
{
"attribute": "switch",
"value": "on",
"capability": "st.switch",
"timestamp": 1633318281000,
"component": "main"
},
{
"attribute": "healthStatus",
"value": "online",
"capability": "st.healthCheck",
"timestamp": 1633318281000,
"component": "main"
}
]
}
],
"headers": {
"requestId": "FAF8BE73D71D925CE3E",
"interactionType": "stateCallback",
"schema": "st-schema",
"version": "1.0"
}
}
I can receive normal response 204 and the device state in SmartThings APP was synchronized in the beginning but after a period of time I received 400 error status code and the response body is like this:
{
"headers": {
"schema": "st-schema",
"version": "1.0",
"interactionType": "stateCallback",
"requestId": "FAF8BE73D71D925CE3E"
},
"deviceState": [
{
"externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
"deviceError": [
{
"errorEnum": "BAD-REQUEST",
"detail": "deviceState[0] does not correspond to any ST device"
}
]
},
{
"externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
"deviceError": [
{
"errorEnum": "BAD-REQUEST",
"detail": "deviceState[1] does not correspond to any ST device"
}
]
}
]
}
According to the deviceError, I don’t know why deviceState[0] (st.switchLevel) is illegal for a “c2c-dimmer” device handler and why deviceState1 is illegal for a “c2c-fan-controller-4speed” device handler?
I think my Device State Callback request is legal, please tell me where I was wrong?
My Discovery Response to SmartThings is this:
{
"requestGrantCallbackAccess": true,
"devices": [
{
"externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
"deviceHandlerType": "c2c-dimmer",
"manufacturerInfo": {
"hwVersion": "4.0.0",
"modelName": "type1-1",
"swVersion": "2.2.0",
"manufacturerName": "TENX"
},
"friendlyName": "My New My Product Light 20F543E0ED3BD5CC5661D4F1"
},
{
"externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
"deviceHandlerType": "c2c-fan-controller-4speed",
"manufacturerInfo": {
"hwVersion": "4.0.0",
"modelName": "type1-1",
"swVersion": "2.2.0",
"manufacturerName": "TENX"
},
"friendlyName": "My Product Fan 20F543E0ED3BD5CC5661D4F1"
}
],
"headers": {
"requestId": "50C703D7-8C5E-4669-8CBB-7877E6CD5C71",
"interactionType": "discoveryResponse",
"schema": "st-schema",
"version": "1.0"
}
}