[ST Edge] vid defined in profile doesn't work

Hi, all.

I’m integrating some devices into ST and I met some problems about device config.

This one of my working device.
I use 2 standard audioMute and smokeDetector capability.

I hope ths deviceCard of audioMute only appears when device detect smoke (smoke.value is detected)

After some investigation, I found a possible way to do it.

  1. Get Device ID
    ❯ cli devices -pcn
    
  2. Get Profile ID
    ❯ cli devices ${deviceID} -y  -pcn
    [snip]
    profile:
        id: XXXXXXXXXXX
    
  3. Get device config content
    ❯ cli deviceprofiles:device-config ${deviceProfileId}  -j -pcn
    
  4. Save above content in a json.
  5. Use JSON Patch feature + visibleCondition
    This how I modify my device config
            {
                "component": "main",
                "capability": "audioMute",
                "version": 1,
                "values": [],
                "patch": [
                    {
                        "op": "add",
                        "path": "/0/visibleCondition",
                        "value": {
                            "capability": "smokeDetector",
                            "version": 1,
                            "component": "main",
                            "value": "smoke.value",
                            "operator": "EQUALS",
                            "operand": "detected"
                        }
                    }
                ]
            },
    
    
  6. Create a device config with modified config.json
    ❯ cli presentation:device-config:create -i ${modified_config.json} -pcnstg
    
  7. Then you will get a new presentationId and manufacturerName if create successfully.
  8. Then remove device && delete older EdgeDriver
  9. Add info I got in Step7 into EdgeDriver profile
    metadata:
      mnmn: ${manufacturerName}
      vid: ${presentationId}
    
  10. Package && Install EdgeDriver && Onboard my device.

Unfortunately, the newly onboared device’s vid is not what I defined in EdgeDriver.
May I ask which step I did is wrong ?

Thanks.

Hi, @liuyd96!

In this case, I haven’t seen the usage of visibleCondition+patch since in the device-config you can use it as another property, for example:

{
    "component": "main",
    "capability": "audioMute",
    "version": 1,
    "values": [],
    "visibleCondition": {
        "capability": "smokeDetector",
        "component": "main",
        "version": 1,
        "value": "smoke.value",
        "operator": "EQUALS",
        "operand": "detected"
    },
    "patch": []
}

Do you mean you keep seeing the same VID in the presentationId property of the device? I mean this one:
image

Have you checked if the device profile has the value updated when using smartthings deviceprofiles id -j?

If correct, the issue could be related to the cache. To force a refresh, you can do the following:

  1. Delete the device and change its name assigned
  2. Change the profile’s name
  3. If you’ll delete the driver and re-create it, you need to change its packageKey

NOTE: Something important to consider is that in the detail view, we cannot make capability cards disappear. The expected behavior using visibleCondition is that the capability gets “disabled” if the condition’s evaluation result is “false”. This is how it would look like using the config you shared:

1 Like

In this case, I haven’t seen the usage of visibleCondition+patch since in the device-config you can use it as another property, for example:

Thank you so much @nayelyz

It works on my smoke detector.

But my gas detector still have the following issue.

Do you mean you keep seeing the same VID in the presentationId property of the device? I mean this one:
image

Yes. And I tried these ways you mentioned, but still doesn’t work. :sob:

If correct, the issue could be related to the cache. To force a refresh, you can do the following:

Did You mean a related cloud service cache ?

Hi, @nayelyz

After some investigations, I know the reason why my gas detector can’t change vid.
This is my gas detector profile definition: Profile Definition

This part is used to limit sensitivityAdjustment.value,
but this way of definition conflicts with the way of specifying vid.

  - id: stse.sensitivityAdjustment
    version: 1
    config:
     values:
       - key: "sensitivityAdjustment.value"
         enabledValues:
           - 'Low'
           - 'High'
       - key: "{{enumCommands}}"
         enabledValues:
           - 'Low'
           - 'High'

Remove config.values then I can use my specific vid

Thank you so much ~

Ah, so you were using embedded device configurations only for stse.sensitivityAdjustment but wanted to assign your VID and it created a conflict.
Now you’re on the right path but for others’ reference, embedded configurations in device profiles (currently only for Edge drivers) are supposed to replace the process of creating a device presentation manually since once a device is created using that profile, the metadata of the device presentation is generated automatically. So, you need to choose which method you’ll use, embedded device configurations or a manually created device presentation in your “metadata” but it can only be one at a time.

Yes, you can notice that because the VID is not updated for the profile when you query it from the API, but in this case, it was caused by the usage of embedded configurations.
The ST app also uses a cache. You can identify your device is not being updated due to the app’s cache when:

  1. You query the device through the API and the VID (presentationId) is up to date
  2. Despite everything looking correct in the API, the app shows something different.

When that happens, you can clear the app’s cache on an Android device configuration. (SmartThings app > storage > clear cache)

Thank you for sharing your experience!

1 Like