St-schema-nodejs - no support to add deviceCookie in discovery response

I am trying Cloud connected device integration with smartthings platform using st-schema and i am using nodejs based st-schema from here GitHub - SmartThingsCommunity/st-schema-nodejs: ST Schema helper library for NodeJS

I wanted to use deviceCookie to identify custom info. As i understand from the documentation deviceCookie shall be sent as part of discoveryResponse, there after this will present in other requests like stateRefresh, Command, etc.,

However i do not see support in st-schema-nodejs for adding deviceCookie as part of discoveryResponse. Please refer properties supported currently in the below image
image

How to overcome this issue? Please suggest.

@AlejandroPadilla
@JDRoberts

Hi, @prakash_m!

You can add the property “deviceCookie” in the discovery response as follows:

.discoveryHandler((accessToken, response) => {         
      const d = response.addDevice('external-device-id', 'friendly-name', 'profile-id')
      //Device manufacturer
      d.manufacturerName('manufacturer');
      //Device model
      d.modelName('model-name');
      d["deviceCookie"]={key1:"this is a cookie"}
})

And, as you mentioned, this is present in other requests as shown below:

//-------stateRefreshRequest
{
  "headers": {
    "schema": "st-schema",
    "version": "1.0",
    "interactionType": "stateRefreshRequest",
    "requestId": "..."
  },
  "authentication": {
    "tokenType": "Bearer",
    "token": "..."
  },
  "devices": [
    {
      "externalDeviceId": "external-device-id",
      "deviceCookie": {
        "key1": "this is a cookie"
      }
    }
  ]
}

//-------commandRequest

{
  "headers": {
    "schema": "st-schema",
    "version": "1.0",
    "interactionType": "commandRequest",
    "requestId": "..."
  },
  "authentication": {
    "tokenType": "Bearer",
    "token": "..."
  },
  "devices": [
    {
      "externalDeviceId": "external-device-id",
      "deviceCookie": {
        "key1": "this is a cookie"
      },
      "commands": [
        {
          "component": "main",
          "capability": "st.switch",
          "command": "on",
          "arguments": []
        }
      ]
    }
  ]
}

Please, let me know if this is helpful for you or if you have any questions :smiley:

1 Like

Is there any plans to update GitHub - SmartThingsCommunity/st-schema-nodejs: ST Schema helper library for NodeJS in the future?

1 Like

Hi, @prakash_m
I asked the engineering team about this and they mentioned that you can create an issue about “deviceCookie” being missing in the SDK’s repository and they’ll put it in their backlog to update the SDK with it.

Here:

Adding the issue link here, just for tracking
deviceCookie missing in Device class · Issue #68 · SmartThingsCommunity/st-schema-nodejs (github.com)

1 Like