Custom capabilities for a driver

Sure!

What do you mean by adding your capability in the preferences section?
This must be included in the device profile but in the components section. For example:

name: device-profile-name
components:
- id: main
  capabilities:
  - id: universevoice35900.harmonyCommand
    version: 1
  ...
  categories:
    - name: MotionSensor
metadata:
  ...
preferences:
  ...

Generally, when the “Connected” message appears is because there’s an issue with the device presentation matching the capabilities configuration. This means you have other capabilities in the device profile that are not included in the device presentation (VID) or vice versa.
I’ll try to use your capability on my side to see if I also get the error.

what i meant to say was ‘i also added a preference section to the device profile’

My profile looks like so…

name: harmony-bridge-simple.v1
components:
- id: main
  capabilities:
  - id: universevoice35900.harmonyCommand
    version: 1
  categories:
  - name: Switch
preferences:
  - title: "IP Address"
    name: ipAddress
    description: "IP address of the HarmonyHub"
    required: true
    preferenceType: string
    definition:
      minLength: 7
      maxLength: 15
      stringType: text
      default: ""
metadata:
  mnmn: SmartThingsCommunity
  vid: "2e9ad144-9f9e-356e-8dc9-b97ec18bedb7"

You have to put the vid without quotes

vid: 2e9ad144-9f9e-356e-8dc9-b97ec18bedb7

Mariano’s right but in this case, that’s not the main cause of the issue.
If you try to create a device-config using only your custom capability, you should get a 400 error, that’s what I received when I tried to use it.

I created a copy of your capability and changed the value in the Dashboard View to show the attribute value and it’s working correctly.

I want to check the process you are following to create capabilities. What I always do is:

  1. In a JSON file I define the configuration I will use to create the capability. For example:
{
    "name": "Harmony Command",
    "ephemeral": false,
    "attributes": {
        "harmonyCommand": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "string"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setHarmonyCommand",
            "enumCommands": []
        }
    },
    "commands": {
        "setHarmonyCommand": {
            "name": "setHarmonyCommand",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "string"
                    }
                }
            ]
        }
    }
}

Here we don’t need the id, version, and status properties because those are generated automatically.
I use this command to create the capability:

smartthings capabilities:create -j -i customCapability.json
  1. Then, I create the capability’s presentation, see the sample below (check the note in the id property):
{
    "dashboard": {
        "states": [
            {
                "label": "{{harmonyCommand.value}}" /*This is the only value I modified from the original*/
            }
        ],
        "actions": [],
        "basicPlus": []
    },
    "detailView": [
        {
            "label": "Harmony Command",
            "displayType": "textField",
            "textField": {
                "command": "setHarmonyCommand",
                "value": "harmonyCommand.value"
            }
        }
    ],
    "automation": {
        "conditions": [
            {
                "label": "Harmony Command",
                "displayType": "textField",
                "textField": {
                    "value": "harmonyCommand.value"
                }
            }
        ],
        "actions": [
            {
                "label": "Harmony Command",
                "displayType": "textField",
                "textField": {
                    "command": "setHarmonyCommand"
                }
            }
        ]
    },
    "id": "namespace.harmonyCommand", /*This is important because it indicates to which capability 
does it belong, if this is incorrect, it can make the capability faulty.*/
    "version": 1
}

Command:

smartthings capabilities:presentation:create namespace.harmonyCommand 1 -i presentation.json
  1. Then, I include the capability in the device handler where I will use it, the device-config is generated automatically for Edge Drivers, you only need to create it manually when you want to apply a custom configuration (visible condition, range change, etc.)

Is this the first custom capability you create or do you have others that are working correctly?

Thank you so much for your help @nayelyz & @Mariano_Colmenarejo

Unfortunately I’m still struggling with this,

I have followed your instructions and recreated the cap, and the presentation for the capability ensuring I set the label like you did.

I have also deleted the device configuration and removed the vid from my profile.

If I try and package my driver now with only my custom capability it refuses to package with error code 400.

If I package with an added stock capability (switch) it then packages fine but the custom capability doesn’t show on the device.

So I think there is something wrong with my capability or capability presentation, but I’m not sure what.

Do you have any more ideas for me?

# harmony-bridge-simple
name: harmony-bridge-simple.v1
components:
- id: main
  capabilities:
  - id: switch
    version: 1
  - id: universevoice35900.harmonyCommand
    version: 1
  categories:
  - name: Switch
preferences:
  - title: "IP Address"
    name: ipAddress
    description: "IP address of the HarmonyHub"
    required: true
    preferenceType: string
    definition:
      minLength: 7
      maxLength: 15
      stringType: text
      default: ""
metadata:
  mnmn: SmartThingsCommunity

{
  "name": "Harmony Command",
  "ephemeral": false,
  "attributes": {
      "harmonyCommand": {
          "schema": {
              "type": "object",
              "properties": {
                  "value": {
                      "type": "string"
                  }
              },
              "additionalProperties": false,
              "required": [
                  "value"
              ]
          },
          "setter": "setHarmonyCommand",
          "enumCommands": []
      }
  },
  "commands": {
      "setHarmonyCommand": {
          "name": "setHarmonyCommand",
          "arguments": [
              {
                  "name": "value",
                  "optional": false,
                  "schema": {
                      "type": "string"
                  }
              }
          ]
      }
  }
}

{
    "dashboard": {
      "states": [
        {
          "label": "{{harmonyCommand.value}}"
        }
      ],
      "actions": [
      ],
      "basicPlus": []
    },
    "detailView": [
        {
            "label": "Harmony Command",
            "displayType": "textField",
            "textField": {
                "value": "harmonyCommand.value",
                "command": "setHarmonyCommand"
            }
        }
    ],
    "automation": {
      "conditions": [
        {
            "label": "Harmony Command",
            "displayType": "textField",
            "textField": {
                "value": "harmonyCommand.value"
            }
        }
      ],
      "actions": [
        {
            "label": "Harmony Command",
            "displayType": "textField",
            "textField": {
                "command": "setHarmonyCommand"
            }
        }
      ]
    },
    "id": "universevoice35900.harmonyCommand",
    "version": 1
  }

Thank you

Thank you for the confirmation of the process you followed to create the capability.
Another recommendation is that every time you create a new capability based on another, you use a different name, this is because, even if you deleted the previous one, its presentation is not removed.

I created a report for the engineering team to analyze this issue, please, don’t delete the capability universevoice35900.harmonyCommand so they can look into it and I’ll let you know their feedback.

Thanks, I just created a new capability universevoice35900.harmonyCommand2

Unfortunately I am still getting the same error when I attempt to package my driver.

smartthings edge:drivers:package harmony-bridge-simple/
    Error: Request failed with status code 400: 
    {"requestId":"DA50DF62-58FF-4F4E-8770-667C6CA956C5","error":{"code":"Un
    expectedError","message":"Invalid device profile specification for 
    harmony-bridge-simple.v1","details":[]}}

Thank you for helping with this

Hi @nayelyz

Just letting you know i still have this problem, I have since added an additional custom capability so i could continue development while I await a solution and I am having the exact same problem with that capability too. (Error 400 when i package, but If i include a stock capability as well it packages but the UI doesn’t show on the app - it just shows status)

I thought I would update you though with something curios, even though the app isn’t showing the UI, my.smartthings.com does show the UI

Ps… I added the refresh capability just so that it would package

I hope a solution can be found for this soon

Hi, @lmullineux.
Thank you for the follow-up. Yes, that is because the problem is in the namespace so any custom capabilities you create will behave the same.
The engineering team is already working on fixing this problem, as soon as I get an update, I’ll let you know.

Tagging @LucasRyu in this thread as he has the same issue.

Thank you, I’ll look forward to a resolution.

Is there a work around? A way for me to delete my namespace and recreate? Or is there some other factor e.g location that means it won’t work for me at all until the issue is fixed?

Is there an ETA for resolution? Or is it just unknown at this stage?

Thanks

No, the namespace is assigned to your SmartThings account randomly when you create your first Custom Capability, there’s no endpoint in the ST API that would allow you to generate a new one.

There’s no ETA for the resolution yet, once the engineering team shares an update about this, I’ll post it here.

Hi @nayelyz

Happy New Year - is there any updates on the issue with my namespace?

Happy new year to you as well! :smiley:
The team mentioned the fix is under development but they haven’t shared an ETA for the release.

@lmullineux, @LucasRyu, @k.v.riel
Hi!
The team mentioned the root cause of this issue is now fixed so it won’t happen again for new users.
But, we need your help to refresh things on your side because you were already facing it, so, please follow these steps:

  1. Update your custom capability presentation without changing the content
  2. Update your device config so it takes the “change” made in step 1
    Note: If you’re using Edge drivers, you need to delete the current package and start a fresh install (package > publish > delete)
  3. To get the latest presentation (generated on step 2), wait for 24hrs or clear the app cache and relaunch the app.
    • The last option is for Android devices only and you need to go to the mobile device’s settings > apps > SmartThings app > storage > clear cache

Let me know your results :smiley:

1 Like

Thank you - that seems to have worked

I wasn’t sure what was meant my step 2, but this is what I did and it worked

  1. Update the presentation on the CLI
  2. Package, Publish, Install
  3. That was it, it just worked

Now I can see my UI, I realised I made an ugly one so have more work to do :smiley:

Thanks

Louis

1 Like

Finally, it works! I can see all custom capabilities I made.

Thanks!

1 Like

For me the custom capability is now working, but the automation are all gone… does anyone else also have this issue?

automation:
  conditions:
    - component: main
      capability: switch
      version: 1
      values: []
      patch: []
      exclusion: []
    - component: main
      capability: switchLevel
      version: 1
      values: []
      patch: []
      exclusion: []
    - component: main
      capability: colorTemperature
      version: 1
      values:
        - key: colorTemperature.value
          range:
            - 2900
            - 7000
      patch: []
      exclusion: []
  actions:
    - component: main
      capability: switch
      version: 1
      values: []
      patch: []
      exclusion: []
    - component: main
      capability: switchLevel
      version: 1
      values: []
      patch: []
      exclusion: []
    - component: main
      capability: colorTemperature
      version: 1
      values:
        - key: colorTemperature.value
          range:
            - 2900
            - 7000
      patch: []
      exclusion: []
    - component: main
      capability: refresh
      version: 1
      values: []
      patch: []
      exclusion: []

What do you mean? The custom capability is the one missing or the options of the other capabilities?
If the first, the custom capability is not included in the part of the device config you shared…

I removed the custom capability to see if it works with the standard capabilities… those are not showing up in the routines section of the app.

I’m still having the issue that my automation is not showing up when using a custom device configuration presentation. If I don’t use it, it all works, if I then export the working presentation via the cli and make my range changes, the automation is gone.

Anyone any idea what I can do differently?