Why Cloud connected stateCallback interaction type has BAD-REQUEST error response?

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"
    }
}

Hey, @exosite

I’m quite sure that it is because you’re trying to push a Health Check (healthStatus) state, but such capability is not supported by any Device Handler Type.

Please remove it and let me know if it helps.

Hi, Eric

But the Device State Callback example in document has health check. And in the beginning of device handler page says the Health Check and Refresh Capabilities are mandatory for each Device Profile. The health check is legal in State Refresh Response and Command Response but illegal in Device State Callback? I am very confused. Please clarify that I should follow your suggestion or the document? I will try your suggestion by the way.

It’s really interesting some of the inconsistencies you’ve found right there.

You’re right, it shouldn’t have it, since the c2c-rgbw-color-bulb, doesn’t support Health Check.


This is true for device profiles, which is the case of the second device example (pdevice-2) which provides usage reference of a custom device profile.


I’ll suggest some changes to that document to improve the context provided. Also, to have a better level of consistency across your integration, I recommend you build your custom device profile at the Developer Workspace.

Hi Eric,

I tried your suggestion but still got the same error. I have removed the Health Check state. During my working daytime, I won’t see this error. After a night, when I came back to the office in the morning. I push the device button to change the status then my log shows this error again.

{
    "authentication": {
        "tokenType": "Bearer",
        "token": "###"
    },
    "deviceState": [
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_LIGHT",
            "states": [
                {
                    "attribute": "level",
                    "value": 25,
                    "capability": "st.switchLevel",
                    "timestamp": 1633572680000,
                    "component": "main"
                },
                {
                    "attribute": "switch",
                    "value": "on",
                    "capability": "st.switch",
                    "timestamp": 1633572680000,
                    "component": "main"
                }
            ]
        },
        {
            "externalDeviceId": "20F543E0ED3BD5CC5661D4F1_FAN",
            "states": [
                {
                    "attribute": "fanSpeed",
                    "value": 1,
                    "capability": "st.fanSpeed",
                    "timestamp": 1633572680000,
                    "component": "main"
                },
                {
                    "attribute": "switch",
                    "value": "on",
                    "capability": "st.switch",
                    "timestamp": 1633572680000,
                    "component": "main"
                }
            ]
        }
    ],
    "headers": {
        "requestId": "FA1F6B1FBB76FE02B79",
        "interactionType": "stateCallback",
        "schema": "st-schema",
        "version": "1.0"
    }
}

The response:

{
    "body": "{\"headers\":{\"schema\":\"st-schema\",\"version\":\"1.0\",\"interactionType\":\"stateCallback\",\"requestId\":\"FA1F6B1FBB76FE02B79\"},\"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\"}]}]}",
    "status_code": 400,
    "headers": {
        "x-amz-apigw-id": "G0KTWEiYoAMF3zw=",
        "X-Amz-Cf-Pop": "SFO5-C1",
        "X-Cache": "Error from cloudfront",
        "Date": "Thu, 07 Oct 2021 02:11:20 GMT",
        "Content-Type": "application/json",
        "Content-Length": "454",
        "X-Amzn-Trace-Id": "Root=1-615e5748-5437539f250b95e93c1f5ee4;Sampled=0",
        "Connection": "keep-alive",
        "x-amzn-RequestId": "1816cb8a-8958-4bfd-888e-d09b124c9167",
        "Via": "1.1 36a6d536e73f7d347cd93b9a754ee828.cloudfront.net (CloudFront)",
        "X-Amz-Cf-Id": "vXXNZAff15RCOIaMc-mCmUCbSmhSnsRrF1AtuLye9btpUMKVdEKphA=="
    }
}

The response body:

{
    "headers": {
        "schema": "st-schema",
        "version": "1.0",
        "interactionType": "stateCallback",
        "requestId": "FA1F6B1FBB76FE02B79"
    },
    "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"
                }
            ]
        }
    ]
}
1 Like

Hmmm, this is interesting. Let me share this with our team and double-check if we’re not hitting an unexpected bug.

I am pretty sure my Reciprocal Access Token is not expired and even I refreshed it, the error is still the same.

{
    "message": "SmartThingsModel.refreshCallbackAccessToken response",
    "refreshCallbackAccessTokenResponse": {
        "body": "{\"headers\":{\"schema\":\"st-schema\",\"version\":\"1.0\",\"interactionType\":\"accessTokenResponse\",\"requestId\":\"61DA1E9C216F2796951\"},\"callbackAuthentication\":{\"tokenType\":\"Bearer\",\"accessToken\":\"###\",\"refreshToken\":\"###\",\"expiresIn\":86400}}",
        "status_code": 200,
        "headers": {
            "x-amz-apigw-id": "G0QbCGogIAMFi4A=",
            "X-Amz-Cf-Pop": "SFO20-C1",
            "X-Cache": "Miss from cloudfront",
            "Date": "Thu, 07 Oct 2021 02:53:07 GMT",
            "Content-Type": "application/json",
            "Content-Length": "569",
            "X-Amzn-Trace-Id": "Root=1-615e6113-3910ce4846e1ce98292707f5;Sampled=1",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "87171a27-7210-4c02-838d-3b97d38505d5",
            "Via": "1.1 67c5370c4ea2e5f9f865960e31ef2d86.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "gz2ZB5BrLdTYe9ZTyxf_Oh3UyEel7IhLgUkAChb5rDLKg10ZwWbfgA=="
        }
    },
    "module": "smartthings_model"
}

There’s another finding.
Under current error situation if I send Discovery Callback request, The response was 204 seems successful but the new device did not show in SmartThings APP.

My Discovery Callback Request:

{
    "authentication": {
        "tokenType": "Bearer",
        "token": "###"
    },
    "devices": [
        {
            "externalDeviceId": "88835D98B2BF366A5E61B058_LIGHT",
            "deviceHandlerType": "c2c-dimmer",
            "manufacturerInfo": {
                "hwVersion": "4.0.0",
                "modelName": "type1-1",
                "swVersion": "2.4.0",
                "manufacturerName": "TENX"
            },
            "friendlyName": "88835D98B2BF Light 88835D98B2BF366A5E61B058"
        },
        {
            "externalDeviceId": "88835D98B2BF366A5E61B058_FAN",
            "deviceHandlerType": "c2c-fan-controller-4speed",
            "manufacturerInfo": {
                "hwVersion": "4.0.0",
                "modelName": "type1-1",
                "swVersion": "2.4.0",
                "manufacturerName": "TENX"
            },
            "friendlyName": "88835D98B2BF Fan 88835D98B2BF366A5E61B058"
        }
    ],
    "headers": {
        "requestId": "913C15B331F5182A810",
        "interactionType": "discoveryCallback",
        "schema": "st-schema",
        "version": "1.0"
    }
}

Received Discovery Callback Respoonse:

{
    "discoveryCallbackResponse": {
        "body": "",
        "status_code": 204,
        "headers": {
            "x-amz-apigw-id": "G0XS8GA0IAMFu-w=",
            "X-Amz-Cf-Pop": "SFO5-C1",
            "X-Cache": "Miss from cloudfront",
            "Date": "Thu, 07 Oct 2021 03:40:03 GMT",
            "Content-Type": "application/json",
            "Content-Length": "0",
            "X-Amzn-Trace-Id": "Root=1-615e6c12-4c639c632f0607521f598de3;Sampled=1",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "fd54b74b-7ad0-4cee-b299-998618a82e4d",
            "Via": "1.1 be84d08eeed51234cd122d3c30e6f7c1.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "A-RVlqPRO_fbNeXs7xceRWhL83V4qKq2AQ3eOJVPorGTYxXJ5v3R-g=="
        }
    },
    "module": "smartthings_model",
    "message": "SmartThingsModel.sendDiscoveryCallback response"
}

But send list devices API to list my devices, I cannot see my device “88835D98B2BF Light 88835D98B2BF366A5E61B058” added successfully.

[
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-dimmer",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.4.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "3a743caf-1268-424f-8d7a-c0a280a82910"
        },
        "createTime": "2021-10-06T11:03:55.802Z",
        "deviceId": "51dc0809-57e2-4854-a023-2e801f30022a",
        "label": "device1 Light 88835D98B2A2AB785D61C101",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-dimmer",
        "components": [
            {
                "categories": [
                    {
                        "name": "Light",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "switchLevel"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "healthCheck"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    },
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-fan-controller-4speed",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.2.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "d77d72d7-5912-4e4b-a474-b093ce42fbac"
        },
        "createTime": "2021-10-06T05:51:48.619Z",
        "deviceId": "489ddc99-7623-41c0-9d8c-7c121dfc8bba",
        "label": "My device1 Fan 20F543E0ED3BD5CC5661D4F1",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-fan-controller-4speed",
        "components": [
            {
                "categories": [
                    {
                        "name": "Fan",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "healthCheck"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "fanSpeed"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    },
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-dimmer",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.2.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "3a743caf-1268-424f-8d7a-c0a280a82910"
        },
        "createTime": "2021-10-06T05:51:48.618Z",
        "deviceId": "0b0cd219-caa0-4375-ac52-6f22acf1990d",
        "label": "My device1 Light 20F543E0ED3BD5CC5661D4F1",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-dimmer",
        "components": [
            {
                "categories": [
                    {
                        "name": "Light",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "switchLevel"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "healthCheck"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    },
    {
        "restrictionTier": 0,
        "roomId": "7b3a428b-1ce0-4e2a-9781-800fc71d1912",
        "name": "c2c-fan-controller-4speed",
        "viper": {
            "hwVersion": "4.0.0",
            "modelName": "type1-1",
            "swVersion": "2.4.0",
            "manufacturerName": "TENX"
        },
        "profile": {
            "id": "d77d72d7-5912-4e4b-a474-b093ce42fbac"
        },
        "createTime": "2021-10-06T11:03:55.803Z",
        "deviceId": "b65e4bba-54c6-4310-93b6-974c499e97b6",
        "label": "device1 Fan 88835D98B2A2AB785D61C101",
        "manufacturerName": "SmartThings",
        "type": "VIPER",
        "presentationId": "SmartThings-smartthings-c2c-fan-controller-4speed",
        "components": [
            {
                "categories": [
                    {
                        "name": "Fan",
                        "categoryType": "manufacturer"
                    }
                ],
                "capabilities": [
                    {
                        "version": 1,
                        "id": "healthCheck"
                    },
                    {
                        "version": 1,
                        "id": "refresh"
                    },
                    {
                        "version": 1,
                        "id": "switch"
                    },
                    {
                        "version": 1,
                        "id": "fanSpeed"
                    }
                ],
                "id": "main"
            }
        ],
        "locationId": "f64d1996-db82-4ee0-92cc-06a9c4a75371"
    }
]

In conclusion:

  1. After a period of time(for me, after leaving office from 7:00pm to the next day 9:30AM ) the error showed up. It’s hard to test how long it will happen.
  2. I have checked the the access token was not expired.
  3. Under the error situation, even I refreshed access token, I still got the same error.
  4. Under the error situation, the Discovery Callback returned 204 which seems successful, but my new device wouldn’t show in SmartThings APP. And I checked with list devices API. It is truly not added in my device list.

The error can be gone if I do adding devices in SmartThings APP ( Discovery ) again. But users won’t know that. They will feel weird why need to do adding devices again. Please notice that the error will happen again after a nighttime.

I agree, and that’s the purpose of the callbacks, to provide consistency across platforms.

So, I’ve been checking if other partners were experiencing these or similar issues, and yes, some of them reported unexpected errors from callbacks, stateCallback precisely.

In addition, I’ve documented your issue specifically, and as soon as I have a resolution from our engineers, I’ll share with you the details.

Hey, @exosite

Following up on this issue, our team has reviewed the backend logs according to the request Ids referred above, and they’ve mentioned that the callbacks were failing because the externalDeviceId wasn’t consistent with the actual Ids of the devices recently created.

Also, could you confirm if you’re still having issues while sending State Callbacks.

After Oct 13, my Cloud Connect Project got same problem. (even published and use in business)

callback and even discovery, command…

BAD-RESPONSE (Invalid schema specified)

but I don’t change anything 3 months.

interactionResult have no originatingInteractionType (just “”).

{
    "headers": {
        "schema": "st-schema",
        "interactionType": "interactionResult",
        "requestId": "F1BB1EA0-A977-4957-8474-1372A3101121",
        "version": "1.0"
    },
    "globalError": {
        "errorEnum": "BAD-RESPONSE",
        "detail": "Invalid schema specified"
    },
    "originatingInteractionType": "",
    "authentication": {
        "tokenType": "Bearer",
        "token": "3RD TOKEN"
    }
}

My topics are hidden by spam detect bot(I don’t know why they do)

It’s work properly at this time.

1 Like

Hi, Erik.

I added some devices in SmartThings APP and will leave them after duty for a night. I will observe if the errors still come out next day.

{
    "payload": {
        "response": {
            "code": 200,
            "request_id": "MjAuMjk=-b1ziusij85etc0000-29f35443",
            "message": {
                "requestGrantCallbackAccess": true,
                "devices": [
                    {
                        "externalDeviceId": "88835D98B2BF2C396E61DC58_LIGHT",
                        "deviceHandlerType": "c2c-dimmer",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D3 Light 88835D98B2BF2C396E61DC58"
                    },
                    {
                        "externalDeviceId": "88835D98B2BF2C396E61DC58_FAN",
                        "deviceHandlerType": "c2c-fan-controller-4speed",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D3 Fan 88835D98B2BF2C396E61DC58"
                    },
                    {
                        "externalDeviceId": "20F543E0ED3B465C6E61EAF1_LIGHT",
                        "deviceHandlerType": "c2c-dimmer",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.2.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D1 Light 20F543E0ED3B465C6E61EAF1"
                    },
                    {
                        "externalDeviceId": "20F543E0ED3B465C6E61EAF1_FAN",
                        "deviceHandlerType": "c2c-fan-controller-4speed",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.2.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D1 Fan 20F543E0ED3B465C6E61EAF1"
                    },
                    {
                        "externalDeviceId": "88835D98B2A23A4E6E61D101_LIGHT",
                        "deviceHandlerType": "c2c-dimmer",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D2 Light 88835D98B2A23A4E6E61D101"
                    },
                    {
                        "externalDeviceId": "88835D98B2A23A4E6E61D101_FAN",
                        "deviceHandlerType": "c2c-fan-controller-4speed",
                        "manufacturerInfo": {
                            "hwVersion": "4.0.0",
                            "modelName": "type1-1",
                            "swVersion": "2.4.0",
                            "manufacturerName": "TENX"
                        },
                        "friendlyName": "D2 Fan 88835D98B2A23A4E6E61D101"
                    }
                ],
                "headers": {
                    "requestId": "51D35B35-32DD-4BB5-BDB9-5017E9638298",
                    "interactionType": "discoveryResponse",
                    "schema": "st-schema",
                    "version": "1.0"
                }
            },
            "headers": {
                "content-type": "text/plain"
            }
        }
    },
    "module": "SmartThingsController",
    "message": "SmartThingsController.discovery response"
}
1 Like

Great! I’ll stay pending on these results.


@Britzy That’s unfortunate, but I’m glad it is now working as expected. Next time you face this or similar issues with your Schema Connector, please do not hesitate in writing to us at build@smartthings.com.

Hi Erik.

So far the receiving state callback responses are all 204.

{
    "message": "SmartThingsModel.sendStateCallback response",
    "stateCallbackResponse": {
        "body": "",
        "status_code": 204,
        "headers": {
            "x-amz-apigw-id": "HjeW8HQZoAMFwRg=",
            "X-Amz-Cf-Pop": "SFO5-C3",
            "X-Cache": "Miss from cloudfront",
            "Date": "Thu, 21 Oct 2021 10:42:52 GMT",
            "Content-Type": "application/json",
            "Content-Length": "0",
            "X-Amzn-Trace-Id": "Root=1-6171442c-38ca90f7585a9cfd08467445;Sampled=0",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "14798927-29b5-4935-b094-59df8933dd58",
            "Via": "1.1 6328d32449cd285f3f7c7b3c41dbe9ad.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "6PAZQzU5jHvaWZAAA-i1VTLDRePqmTraIZo8u7DynnQvhvZh8NtY-w=="
        }
    },
    "module": "smartthings_model"
}

These days I did some modification. Previously I saved the callback access token in our Redis with key smartthings_access_token. However, this caused an issue, Let me explain step by step:

  1. In the phone A, the user A logged in our ExoHome APP(our product) and paired our device then in SmartThing APP OAuth logged in the do adding devices and saved the callback access token.
  2. In the phone B, the user B logged in our ExoHome APP and paired another device then surprisedly the device will show in user A’s SmartThings APP!!!
  3. This issue happened because the user B use the user A’s callback access token to do discovery callback. so the user B’s device will be added in the user A’s SmartThings APP.
  4. I changed to save each user’s callback access token in the Redis with key user_{{user_id}}_callback_access_token.
  5. So far there’s no BAD-REQUEST i mentioned.

Just for reference, user A and userB are using different ExoHome account, right? Because it seems that user sessions were overlapping on your Schema Connector.


So, your Schema Callbacks are now working as expected, right?

Sure, different email.

Yeah, after 3 days still working well.

{
    "message": "SmartThingsModel.sendStateCallback response",
    "stateCallbackResponse": {
        "body": "",
        "status_code": 204,
        "headers": {
            "x-amz-apigw-id": "HvbpbH2aIAMFZ8Q=",
            "X-Amz-Cf-Pop": "SFO5-C1",
            "X-Cache": "Miss from cloudfront",
            "Date": "Mon, 25 Oct 2021 01:47:14 GMT",
            "Content-Type": "application/json",
            "Content-Length": "0",
            "X-Amzn-Trace-Id": "Root=1-61760ca2-2986122273108edf00723249;Sampled=0",
            "Connection": "keep-alive",
            "x-amzn-RequestId": "eaff1c24-9da3-409d-987e-44e0cdbb27eb",
            "Via": "1.1 afb9be97319013ab1a18f338fce40f2a.cloudfront.net (CloudFront)",
            "X-Amz-Cf-Id": "YG42w_KzelwAnMlEMNDdA2hV0KEKPC9VPC9NYs-v8v82RZZP7FOkBg=="
        }
    },
    "module": "smartthings_model"
}
1 Like