State refresh in the SmartThings Schema Cloud Connector

The device status update does not take effect. Device registration is successful and I get all the Tokens and callbacks I need. By responding the “stateRefreshRequest”, I get the values of the device’s sensors added to the SmartApp. When I try to update (State refresh) the data, nothing happens. I don’t even get an respond data.

If I have made mistakes in the device registration, I have always received the respond that something is wrong. When I use this callback (https://c2c-us.smartthings.com/oauth/token). StateCallback doesn’t answer anything. What am I doing wrong here?

I send the following data with the POST command.
URL = stateCallback = https://c2c-us.smartthings.com/device/events

Data = body: {
        headers: {
          schema: "st-schema",
          version: "1.0",
          interactionType: "stateCallback",
          requestId: "abc-123-4567",
        },
        authentication: {
          tokenType: "Bearer",
          token: tokenObj.authToken,
        },
        deviceState: [
          {
            externalDeviceId: deviceId,
            states: deviceData,
          },
        ],
      }


deviceData = [
  {
    "component": "main",
    "capability": "st.equivalentCarbonDioxideMeasurement",
    "attribute": "equivalentCarbonDioxideMeasurement",
    "value": 200,
    "unit": "ppm"
  },
  {
    "component": "main",
    "capability": "st.airQualitySensor",
    "attribute": "airQuality",
    "value": 10,
    "unit": "CAQI"
  },
  {
    "component": "main",
    "capability": "st.temperatureMeasurement",
    "attribute": "temperature",
    "value": 22,
    "unit": "C"
  },
  {
    "component": "main",
    "capability": "st.relativeHumidityMeasurement",
    "attribute": "humidity",
    "value": 30,
    "unit": "%"
  },
  {
    "component": "main",
    "capability": "st.fineDustSensor",
    "attribute": "fineDustLevel",
    "value": 400,
    "unit": "μg/m^3"
  },
  {
    "component": "main",
    "capability": "st.tvocMeasurement",
    "attribute": "tvocLevel",
    "value": 300,
    "unit": "ppm"
  },
  {
    "component": "main",
    "capability": "st.battery",
    "attribute": "battery",
    "value": 40,
    "unit": "%"
  }
]

Hi, @Heikki_Pirttinen.

I’m confused about this part, does this mean you are sending the stateCallback to the oauthToken callbackUrls?

This URL is the correct one. Do you get any response code from the HTTP request?

Make sure you’re using the following:

  1. The reciprocal Access Token in the authentication.token property
  2. You’re using the correct callback URL. It is included in the grantCallbackAccess response when you get the reciprocal access token.
  3. The correct deviceId. Although, you should get an error if it doesn’t match any of the devices discovered.
  4. Print the content of the request to validate it is using the correct format. Using the SDK, I printed the content and it shows the following:
{
  method: 'POST',
  headers: { 'Content-Type': 'application/json; charset=utf-8' },
  body: '{"headers":{"schema":"st-schema","version":"1.0","interactionType":"stateCallback","requestId":"..."},"authentication":{"tokenType":"Bearer","token":"long string"},"deviceState":[{"externalDeviceId":"smartThermostat4","states":[{"component":"main","capability":"st.thermostatMode","attribute":"thermostatMode","value":"eco"},...]}]}'
}

I tried sending the one you posted. I get the following in response.

    "globalError": {
        "errorEnum": "INVALID-TOKEN",
        "detail": "access token provided is malformed or call is made to wrong callback URL"
    }

Looks right. When I replace the Token with the correct Token, I get an empty response {}.

The problem is that if the deviceStatus is wrong, there is no error. The POST is accepted even if the deviceStatus is wrong. The SmartApp Cloud Connector returned an error if there were errors in the content.

I just noticed that the error messages are coming to my callback address.

Hi, @Heikki_Pirttinen. Thanks for following up

So, what error did you get in your server with the command you shared above?

The response of 202 - Accepted right after you send the command is expected, early this year, there was a change applied in this integration to return this response code, which means the request is being processed, that’s why you get the error afterward. Take a look at this post: