Custom Capability and CLI Developer Preview

Which capabilities did you use in each case? I mean when the tiles were displayed and when they weren’t.

With capabilities:
capability “Battery”
//capability “Sensor”
capability “Button”
capability “Holdable Button”
//capability “Actuator”
capability “Momentary”
capability “Configuration”
capability “Health Check”
capability “Refresh”
capability “Temperature Measurement”
and showing Momentary, Button and Battery in the DetailView, I get the extra tile.

However with:
capability “Actuator”
capability “Sensor”
capability “Configuration”
capability “Refresh”
capability “Switch”
capability “Momentary”
capability “Button”
capability “Holdable Button”
capability “Temperature Measurement”
capability “Health Check”
capability “Power Meter”
capability “Energy Meter”
capability “Polling”
capability “Battery”
capability “Voltage Measurement”

and showing Momentary, Button, Temperature and Battery, I don’t get the extra tile.

Ok, I see you include some deprecated capabilities and this is not recommended.

For the second case, I removed actuator, sensor, Holdable Button, and Polling. Using the config shown in the VID c6c70425-f7b7-36f6-9eef-a40781549c46 displayed the extra tiles for Switch

EDIT:
To display the automation tiles in the Detail View related to the Button capability, you need to use the supportedButtonValues event and, an OCF type related to button, eg.:

//This should be initialized when the device is installed
sendEvent(name:"supportedButtonValues", value: ["down","down_hold","down_2x"].encodeAsJSON())

//Located in the DTH definition
ocfDeviceType: "x.com.st.d.remotecontroller"

It’s been almost a year since this topic was released. I don’t know what improvements the tool has. I executed the command "smartthings presentation:device-config:generate a408b37d-ae65-4c3d-a974-189ae9f4848f --dth -o=deviceConfigX.json -j "
Among them, “a408b37d-ae65-4c3d-a974-189ae9f4848f” comes from the title bar of my IDE (my DTH is in the state after saving). The results obtained are as follows:

{
 "dashboard": {
     "states": [
         {
             "component": "main",
             "capability": "battery",
             "version": 1,
             "values": [],
             "patch": []
         }
     ],
     "actions": [
         {
             "component": "main",
             "capability": "battery",
             "version": 1,
             "values": [],
             "patch": []
         }
     ]
 },
 "detailView": [
     {
         "component": "main",
         "capability": "battery",
         "version": 1,
         "values": [],
         "patch": []
     },
     {
         "component": "main",
         "capability": "configuration",
         "version": 1,
         "values": [],
         "patch": []
     },
     {
         "component": "main",
         "capability": "button",
         "version": 1,
         "values": [],
         "patch": []
     },
     {
         "component": "main",
         "capability": "sensor",
         "version": 1,
         "values": [],
         "patch": []
     },
     {
         "component": "main",
         "capability": "actuator",
         "version": 1,
         "values": [],
         "patch": []
     },
     {
         "component": "main",
         "capability": "healthCheck",
         "version": 1,
         "values": [],
         "patch": []
     }
 ],
 "automation": {
     "conditions": [
         {
             "component": "main",
             "capability": "battery",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "configuration",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "button",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "sensor",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "actuator",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "healthCheck",
             "version": 1,
             "values": [],
             "patch": []
         }
     ],
     "actions": [
         {
             "component": "main",
             "capability": "battery",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "configuration",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "button",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "sensor",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "actuator",
             "version": 1,
             "values": [],
             "patch": []
         },
         {
             "component": "main",
             "capability": "healthCheck",
             "version": 1,
             "values": [],
             "patch": []
         }
     ]
 },
 "type": "dth"
}

There are no “mnmn”, “vid”, “dpInfo”, “iconUrl” in the result, just ending with “dth”.
Does this result affect the execution of the next command?(Run “smartthings presentation:device-config:create -j -i deviceConfigX.json” after modifying “dashboard”, “detailView”, and “automation”)

This output did once include a ‘mnmn’ (also seen as ‘manufacturerName’) and ‘vid’ (‘presentationId’) but it was a bit confusing for it to do so as at this stage it is just a suitable file that could be used to create a device presentation and no actual presentation exists in the system with those identifiers. It was possible for a ‘vid’ to be shown because it isn’t simply a unique ID, it is a hash of the contents of the file and if nothing was changed that would indeed have been the ‘vid’ used for the actual presentation.

You may be able to add the ‘dpinfo’ and ‘iconUrl’ to the device config (last time I looked they weren’t usefully documented), just as there are other things you can include if you want to, but this is really just a default configuration based on the DTH that gives you a sensible base to work with. You don’t have to use the ‘generate’ command at all, you can build a device config from scratch if you want.

Once you have used the ‘create’ command there will be a device config and presentation created in the system sharing the ‘vid’ as a key.

3 Likes

I could use some help. Previously, the custom capabilities I’ve created had only one attribute and maybe one command - and I’ve had success with those. Now I’m trying to define multiple attributes within one custom capability, but nothing from my custom cap is getting displayed in the mobile app (only the refresh capability). Could someone please look at my json below and advise what I’m doing wrong? Can I even do what I’m trying to do - that is, display all 5 attributes within one capability?

Note that I really don’t have any use for the command setters I’ve defined here, I added them in an act of desperation. I think I can safely remove them, yes? All of my attributes are used as simple text display (output only) of the attribute values which will be emitted by the device handler. (no actions in the mobile app and no need for automations). And my device app is able to update my custom capability attributes with no errors - it’s just that they aren’t getting rendered in the app.

CAPABILITY

{
    "id": "partyvoice23922.genericupnp",
    "version": 1,
    "status": "proposed",
    "name": "genericupnp",
    "attributes": {
        "modelName": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "string"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setmodelName",
            "enumCommands": []
        },
        "usn": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "string"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setusn",
            "enumCommands": []
        },
        "seqNum": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "integer",
                        "minimum": 0
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setseqNum",
            "enumCommands": []
        },
        "networkID": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "string"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setnetworkID",
            "enumCommands": []
        },
        "expiration": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "string"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setexpiration",
            "enumCommands": []
        }
    },
    "commands": {
        "setseqNum": {
            "name": "setseqNum",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "integer",
                        "minimum": 0
                    }
                }
            ]
        },
        "setnetworkID": {
            "name": "setnetworkID",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "string"
                    }
                }
            ]
        },
        "setmodelName": {
            "name": "setmodelName",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "string"
                    }
                }
            ]
        },
        "setexpiration": {
            "name": "setexpiration",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "string"
                    }
                }
            ]
        },
        "setusn": {
            "name": "setusn",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "string"
                    }
                }
            ]
        }
    }
}

CAPABILITY PRESENTATION

{
    "dashboard": {
        "states": [],
        "actions": [],
        "basicPlus": []
    },
    "detailView": [
        {
            "label": "Model",
            "displayType": "state",
            "state": {
                "label": "{{modelName.value}}"
            }
        },
        {
            "label": "Device Network ID",
            "displayType": "state",
            "state": {
                "label": "{{networkID.value}}"
            }
        },
        {
            "label": "UPnP USN",
            "displayType": "state",
            "state": {
                "label": "{{usn.value}}"
            }
        },
        {
            "label": "Expiration",
            "displayType": "state",
            "state": {
                "label": "{{expiration.value}}"
            }
        },
        {
            "label": "Event Sequence Number",
            "displayType": "state",
            "state": {
                "label": "{{seqNum.value}}"
            }
        }
    ],
    "automation": {
        "conditions": [],
        "actions": []
    },
    "id": "partyvoice23922.genericupnp",
    "version": 1
}

DEVICE CONFIG

{
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "switch",
                "version": 1,
                "values": [],
                "patch": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "switch",
                "version": 1,
                "values": [],
                "patch": []
            }
        ]
    },
    "detailView": [
        {
            "component": "main",
            "capability": "partyvoice23922.genericupnp",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [],
        "actions": []
    },
    "type": "profile",
    "presentationId": "92d6e2cd-f6d1-343c-a994-65b1872a7a37",
    "manufacturerName": "SmartThingsCommunity",
    "vid": "92d6e2cd-f6d1-343c-a994-65b1872a7a37",
    "mnmn": "SmartThingsCommunity",
    "version": "1.0"
}
1 Like

Displaying Multiple Attribute capabilities is not supported.
As a capability is considered one property of the device, each one should measure/save only one value and belong to the device metadata to use them.
This way, the same capability can belong to several devices because not all would have the same characteristics of a multi-attribute capability.

1 Like

So you are saying that I have to define separate and distinct capabilities for each attribute.

I don’t think I can even re-use one ‘generic’ capability multiple times in the same device because you can have only one instance of a particular capability within a device, is that correct?

You’re right.

You can use the same capability more than once in the same device if you separate them into different components in your device profile.

Ahh… separate components may be the solution for me then. What is the limit on number of components?

Up to now, the limit is 20 components per device profile, @TAustin. If you’ll take this path, make sure the metadata is well organized.

1 Like

I’ll experiment to see what works best for me. Thank you for answering my questions so quickly!

1 Like

Trying to mess with this again. I just edited a device presentation, drastically simplifying the automation conditions and actions - are those working yet? I got a new vid and updated my DTH, but when I go to create a new automation in the app, none of my changes seem to be respected as I’m seeing tons more automation options than I want. Is this still the cache issue? I tried flipping a few things on the device, but nothing seems to make a difference. Presentation is below - I would expect with this that I would no longer see battery or switch capabilities showing up in either automation conditions or actions.

{

    "manufacturerName": "SmartThingsCommunity",

    "presentationId": "90e15025-bbce-3360-8c78-2b4a5c56a18b",

    "mnmn": "SmartThingsCommunity",

    "vid": "90e15025-bbce-3360-8c78-2b4a5c56a18b",

    "version": "0.0.2",

    "dashboard": {

        "states": [

            {

                "label": "{{door.value}}",

                "alternatives": [

                    {

                        "key": "closed",

                        "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSED",

                        "type": "inactive"

                    },

                    {

                        "key": "open",

                        "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPEN",

                        "type": "active"

                    },

                    {

                        "key": "unknown",

                        "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_UNKNOWN",

                        "type": "active"

                    },

                    {

                        "key": "opening",

                        "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPENING",

                        "type": "active"

                    },

                    {

                        "key": "closing",

                        "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSING",

                        "type": "active"

                    }

                ],

                "capability": "doorControl",

                "version": 1,

                "component": "main"

            },

            {

                "label": "{{battery.value}} {{battery.unit}}",

                "capability": "battery",

                "version": 1,

                "component": "main"

            }

        ],

        "actions": [

            {

                "displayType": "toggleSwitch",

                "toggleSwitch": {

                    "command": {

                        "on": "open",

                        "off": "close"

                    },

                    "state": {

                        "value": "door.value",

                        "on": "open",

                        "off": "closed"

                    }

                },

                "capability": "doorControl",

                "version": 1,

                "component": "main"

            }

        ],

        "basicPlus": []

    },

    "detailView": [

        {

            "capability": "doorControl",

            "version": 1,

            "label": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT",

            "displayType": "toggleSwitch",

            "toggleSwitch": {

                "command": {

                    "on": "open",

                    "off": "close"

                },

                "state": {

                    "value": "door.value",

                    "on": "open",

                    "off": "closed",

                    "label": "{{door.value}}",

                    "alternatives": [

                        {

                            "key": "closed",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSED",

                            "type": "inactive"

                        },

                        {

                            "key": "open",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPEN",

                            "type": "active"

                        },

                        {

                            "key": "unknown",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_UNKNOWN",

                            "type": "active"

                        },

                        {

                            "key": "opening",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPENING",

                            "type": "active"

                        },

                        {

                            "key": "closing",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSING",

                            "type": "active"

                        }

                    ]

                }

            },

            "state": null,

            "component": "main"

        },

        {

            "capability": "towertalent27877.lastActivity",

            "version": 1,

            "label": "LastActivity",

            "displayType": "state",

            "state": {

                "label": "{{lastActivity.value}}"

            },

            "component": "main"

        },

        {

            "capability": "towertalent27877.connectedSensor",

            "version": 1,

            "label": "ConnectedSensor",

            "displayType": "state",

            "state": {

                "label": "{{connectedSensor.value}}"

            },

            "component": "main"

        },

        {

            "capability": "battery",

            "version": 1,

            "label": "___PO_CODE_CAPABILITY.SMARTTHINGS.BATTERY_DEFAULT",

            "displayType": "slider",

            "slider": {

                "range": [

                    0,

                    100

                ],

                "step": null,

                "unit": "battery.unit",

                "value": "battery.value",

                "valueType": "integer"

            },

            "state": null,

            "component": "main"

        }

    ],

    "automation": {

        "conditions": [

            {

                "capability": "doorControl",

                "version": 1,

                "label": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT",

                "displayType": "list",

                "list": {

                    "alternatives": [

                        {

                            "key": "closing",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSING",

                            "type": "active"

                        },

                        {

                            "key": "opening",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPENING",

                            "type": "active"

                        },

                        {

                            "key": "closed",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSED",

                            "type": "inactive"

                        },

                        {

                            "key": "open",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPEN",

                            "type": "active"

                        },

                        {

                            "key": "unknown",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_UNKNOWN",

                            "type": "active"

                        }

                    ],

                    "value": "door.value"

                },

                "exclusion": [],

                "component": "main"

            }

        ],

        "actions": [

            {

                "capability": "doorControl",

                "version": 1,

                "label": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT",

                "displayType": "list",

                "list": {

                    "alternatives": [

                        {

                            "key": "close",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_COMMANDS_CLOSE",

                            "type": "inactive"

                        },

                        {

                            "key": "open",

                            "value": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_COMMANDS_OPEN",

                            "type": "active"

                        }

                    ]

                },

                "component": "main",

                "exclusion": []

            }

        ]

    },

    "dpInfo": [

        {

            "os": "ios",

            "dpUri": "plugin://com.samsung.ios.plugin.stplugin/assets/files/index.html"

        },

        {

            "os": "android",

            "dpUri": "plugin://com.samsung.android.plugin.stplugin"

        },

        {

            "os": "web",

            "dpUri": "wwst://com.samsung.one.plugin.stplugin"

        }

    ],

    "language": [

        {

            "locale": "en_US",

            "poCodes": [

                {

                    "label": "Door",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT"

                },

                {

                    "label": "Door",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR"

                },

                {

                    "label": "Closed",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSED"

                },

                {

                    "label": "Closing…",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_CLOSING"

                },

                {

                    "label": "Open",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPEN"

                },

                {

                    "label": "Opening…",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_OPENING"

                },

                {

                    "label": "Unknown",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_ATTRIBUTES_DOOR_UNKNOWN"

                },

                {

                    "label": "Closed",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_COMMANDS_CLOSE"

                },

                {

                    "label": "Open",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.DOORCONTROL_DEFAULT_COMMANDS_OPEN"

                },

                {

                    "label": "Battery",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.BATTERY_DEFAULT"

                },

                {

                    "label": "Battery",

                    "po": "___PO_CODE_CAPABILITY.SMARTTHINGS.BATTERY_DEFAULT_ATTRIBUTES_BATTERY"

                }

            ]

        }

    ]

}

You can check if your device is using the latest VID you configured from the devices list.

To force the refresh, it is recommended to:

  • Create a new DTH and assign there the new VID.
  • Delete the device and install it again using the recent DTH.

Also, I checked your device-configuration using the command below and it says the presentation type is “profile” instead of “dth”. It is recommended to use each type with the corresponding integration.

smartthings presentation:device-config 90e15025-bbce-3360-8c78-2b4a5c56a18b -j -o=devConfigPres.json

I created a device using your presentation and this is what I see in conditions and actions:

2 Likes

That is very helpful, thank you. I was able to get it going and switched to DTH.

1 Like

I’m running into 2 new issues, but I’m not sure when they started…

  1. The detailView order in the device config is being ignored. (example) The weird thing is that the presentations I created prior to August are still displaying the tiles in the correct order.

  2. The inclusion process is sometimes assigning the closest matching built-in DTH instead of a custom DTH that matches the mfr, prod, and model. If you remove the device and join it again then it will usually assign the matching custom DTH, but not always…

Hi!

  1. I checked the VID of your example and also installed the device. It seems the only one out of order is "battery", it can be because, for most devices, this value is shown at the end of the UI.
    In your use case, must it be the second tile?
  2. We’ve observed something similar and we’re keeping an eye on that to see if it’s replicated and get it documented. Don’t worry
2 Likes

Help!

Is there anyone that can help me recode a device handler and smart app for the new system. I’ve tried to understand the new way to build but I’m not a coder at all and brain just doesn’t get it. I’m happy to pay fro the help.

Thanks to anyone willing

Thought I would share this: the new iOS update that just came out a few days ago finally fixes issues with automation and custom capabilities. For the first time, my devices actually show up to select within the Automations function in the mobile app and they work!! I created these devices over 9 months ago and they would never showed up or work right for Automations. I was convinced it was something I had wrong in my automation json definition. But today after updating the mobile app they finally work!!

So if any of you out there on iOS had given up, try it with the new app update, you might be pleasantly surprised as I was!

Hey there Mike. Did you get any takers?

If not, can you explain a little more what you need to do?