No more events for capability "execute" from Samsung AirCons

Hi,

I have successfully set up a SmartApp (via WebHook on my local server) to monitor my Windfree ACs. The thing is that some settings can only be set and retrieved via the “execute” capability (e.g. light on/off or quiet mode, see also here).

The SmartApp was running absolutely fine, but since recently there are no more events for the “execute” capability.

Does anybody know the reason for this?
Is there a way to get these events back to work?

Thanks
Peter

Hi, @hal2000pd! What do you mean by this?

  1. You’re not getting the subscription event for when this capability gets a new value
  2. The commands you send from the app are rejected and you get an error. If the last, can you share the error message, please?

Hi @nayelyz,

Its 1. I don’t get any subscription events for capability “execute”. I log everything that the webhook receives and other capabilities (e.g. “switch”, “temperatureMeasurement”) work fine, but there is just nothing coming for “execute”.

Have you tried re-creating the subscription?
In the update lifecycle of the app, we generally use the unsubscribeAll() function and then create all again, especially because we could have selected another device or remove it:

.updated(async (context, updateData) => {
        await context.api.subscriptions.unsubscribeAll();
        return Promise.all([
            context.api.subscriptions.subscribeToDevices(context.config.sensor, 'switch', 'switch', 'meterDeviceEventHandler')
        ])
    })

Also, you can check which subscriptions exist for your SmartApps by making a query to the installedApps endpoint.

URL: https://api.smartthings.com/v1/installedapps/installedAppId/subscriptions
In the Authorization header, you must use the SmartApp token, otherwise, you won’t get the corresponding info. This is a sample using Postman:

The subscription looks like this:

{
  "items": [
    {
      "id": "4...",
      "installedAppId": "0...",
      "sourceType": "DEVICE",
      "device": {
        "deviceId": "6...",
        "componentId": "main",
        "capability": "*",
        "attribute": "*",
        "value": "*",
        "stateChangeOnly": true,
        "subscriptionName": "myDeviceEventHandler_0",
        "modes": []
      }
    }
  ],
  "_links": {}
}

The thing I am wondering is, whether stateChangeOnly = true causes the execute-events not to be sent. However, I don’t know much about JavaScript. How do I specify that stateChangeOnly shall be false in the subscribeToDevices? (Sorry for the stupid question, though!)

Ok, I found out how to set stateChangeOnly to false. (Sorry :man_facepalming:)

And yes, when I set it to false I seem to get events for “execute”. I guess I will change my program so that it receives "*" with stateChangeOnly = true and subscribes to “execute” specifically with stateChangeOnly = false.

I’ll check that it’s working as I expect and I’ll report here.

@nayelyz: Thanks a lot!

2 Likes

Just to wrap this up: Yes it’s working now. Execute events come with "stateChange": False.

So my updated call now looks like this:

.updated(async (context, updateData) => {
    await context.api.subscriptions.unsubscribeAll() // clear any existing configuration
    await context.api.subscriptions.subscribeToDevices(context.config.airConditioner, 'execute', '*', 'dehExe',
        { "stateChangeOnly": false }
    );
    await context.api.subscriptions.subscribeToDevices(context.config.airConditioner, '*', '*', 'dehAll',
        { "stateChangeOnly": true }
    );
})

Peter