Custom Capability and CLI Developer Preview

Incidentally, if somebody has already created a presentation for say a text box or a button, can you paste the code here, or can it be reused in other device handlers without any changes? If I took the presentation for one text box of somebody else’s DTH, could I just change one line in my DTH to use the existing presentation?

1 Like

Even if you have a reusable capability with a presentation you’ll need to create a custom configuration file to display it on the UI for your DTH. The platform doesn’t render custom capabilities (proposed) automatically the way it does with stock (active) capabilities. Feel free to PM me for more details.

1 Like

Oh boy… I’m not even sure where to start.

I’ve been on the platform for about three years and have written a bunch of custom DTHs to integrate my (non-smart) alarm system and various automations to automate just about everything I care about. I’ve been extremely happy with the platform… until now!

Migrating my custom work to the new app is just about the most frustrating experience I’ve had – and I’ve been in the tech industry for 20+ years and have architected/oversaw/executed on several large scale technology migrations so I’ve seen a lot of frustrating things before.

First off, the development process is horrendous. If someone has a better process, please enlighten me. This is what I’ve been able to cobble together for myself through trial and error but the development-feedback loop is painful. There’s just too much “run this command, edit this file, run this other command, copy this value into a browser and click some buttons” type actions for this to be efficient. This is what I’ve found as a reasonably reliable workaround to the seemingly arbitrary app refresh issues:

  1. Update the capability’s presentation.
  2. Update DTH with different combinations of capabilities to force generation of a new vid & publish.
  3. Generate a device presentation config from DTH and move/delete elements as needed.
  4. Create a new presentation config to get a new vid.
  5. Update the DTH with the new vid & publish.
  6. Update the device name and/or device type.
  7. Open the app and my device is (usually) updated to reflect my presentation changes.

This was somewhat reliable and I was able to make some progress. But over the last day or so, this process stopped working for me. No matter how I changed up the combinations of capabilities or updated the device name and type, I can’t seem to force a refresh. Using the CLI to pull up the device definition shows a few things:

  • When I update the device name and device type, the name and dth sections in the response does indeed update correctly as expected.
  • The presentationId is stuck with some old vid and doesn’t reflect the one used in the DTH. This results in the app not showing the latest capabilities.
  • The components section does not always (but does change sometimes but I’ve yet to discern a pattern to this) update to reflect the capabilities defined in the DTH. This results in a mismatch between the device presentation that the vid is pulling up and the underlying components so the capabilities without the corresponding component present will show up with the disabled cloud icon in the card.

Second, even when I get things to show up properly everything is functionally broken even if they may appear visually correct:

  • The schema for detailView indicates that an array of objects is accepted but only the first component ever shows up. I’ve resorted to breaking my capability into multiple capabilities just to get multiple cards to render. Not sure why the JSON payload takes an array if only one component is ever intended to be displayed in the app per capability.
  • Likewise, the actions array in the dashboard only shows the first item. I was expecting multiple items to show up (eg. two switches if I had two actions defined) since the schema for the payload specifies that an array of objects is valid.
  • The pushButton component doesn’t work. It shows up but clicking on it results in the circular spinner but the command is never executed.
  • The toggleSwitch also doesn’t work. It renders fine and displays the alternative text as expected but pressing on the button to toggle results in a network error popup.
  • The numberField does not work. I can bring it up and enter in some numbers but when I try and accept the values entered, the corresponding command does not get triggered.
  • The list component does work and triggers the correct command with the expected parameter. But it also doesn’t quite work in the way that I expected it to. I’d assumed that the commands mapped to the popup list of actions that the user can select and the states mapped to the label displayed in the card. In my particular case, I have more states that can be displayed than I have actions that can be executed so my command list is only a subset of my state list. The popup does indeed work as I’d assumed but the label seemed to use the alternatives defined with the commands and not the state. So for values that do not have a matching alternative in the command list, they show the raw value even though the state alternatives do have matching values. How do we decouple the label from the commands?
  • Child devices – what is the equivalent of childDeviceTiles to have child devices show up as part of the parent device’s UI? Child devices show up as separate standalone devices as well as being listed as child devices.

With a few weeks left before the classic app is sunset, I have no idea how I’ll be able to get all my custom devices migrated over to the new app. As I said before, I’d been pleased with smartthings up to now and it’s been running reliably for a long time but with the classic app going away, I’m going to be left with integrations and automations that won’t work anymore. It doesn’t sound like I’m alone in this boat since this thread seems rife with documented issues.

How on earth is the classic app supposed to sunset successfully within this timeline when it appears that many of us are struggling with even getting basic functionality working? Is the sunset date going to be pushed back? It feels like I’m working with a pre-beta product at this point and not anything ready for primetime.

17 Likes

I am not an IT guy but I had been able to integrate all the devices I have to ST that includes several custom DTH, Echo Speaks, Rule Machine etc. Now this CLI preview is getting over my head. I cant find a step by step guide to do it either. All I need is to to show the Value I want on device icon in the new ST APP.

For example on Aeon energy meter I want to see current instead of watts when I open the app. I was able to do all this easily on Classic App. New is very messy and I can’t find anyway to do it. Can someone please help me with this ??

1 Like

Basically want the same thing. My custom DH’s are simply showing a data value it gets from either the device or external apps. Worked like a charm in the Classic app. Seems like a whole lot of headaches to convert…

@cdikland and @DjAnu,

I changed my DTH for a light sensor to show lux instead of battery. Here’s how I got started. Just have a little (ok, a lot) of patience…

Thanks for the example but I cant even get past the first CLI command of
presentation:device-config:generate MYUID --dth --output=config.json

Which returns

[2020-09-27T11:23:12.441] [ERROR] login-authenticator - received “server_error” error when trying to authenticate
[2020-09-27T11:23:12.441] [ERROR] login-authenticator - Unexpected server error.

See the config notes in the first post.

1 Like

This is probably a stupid question, but if you have a custom capability with a command that doesn’t take any arguments and isn’t tied to an attribute, how do you add it to the Automation section of the capability presentation?

There isn’t a displayType that just takes the command name and I haven’t been able to find an example…

Update: It turns out the pushButton displayType on the device details screen isn’t displaying for that command either, but a different attribute in that custom capability is showing so I know the custom capability is being displayed and it’s not a caching issue.

Refresh and Momentary have presentations of the form:

"automation": {
    "conditions": [],
    "actions": [
        {
            "label": "___PO_CODE_SMARTTHINGS_DREAM_SAC_BUTTON_REFRESH_8",
            "displayType": "list",
            "list": {
                "alternatives": [
                    {
                        "key": "refresh",
                        "value": "___PO_CODE_SMARTTHINGS_DREAM_SAC_BUTTON_REFRESH_8",
                        "type": "active"
                    }
                ]
            }
        }
    ]
},

Of course, what the app actually does with the capability may be another story …

I’ve not been keeping up with events. Are automations now being implemented for custom capabilities?

I just want to use the standard button capability and create a capability with 4 buttons but I can’t understand the syntax. Does anyone have an example I can look at? This is the problem with this new CLI. By the time someone creates a DTH, all the ‘how to’ is hidden so there is no way for me to re-use/modify.

If you say so.
All I get is

Configuration

The CLI can be configured by creating a YAML file called config.yaml in the following location:

  • $HOME/.config/@smartthings/cli on OS/X or Linux
  • %LOCALAPPDATA%\@smartthings\cli on Windows

Authentication

The CLI supports an automatic login flow that pops up a browser window asking you to log in and give the CLI permission to access your account. The CLI will automatically request login as needed.

More details about configuration of the CLI can be found on the configuration documentation page.
I

The first screen I get is Allow “smartthings-cli” to access all your locations, devices and scenes Allow/Deny.

I click Allow and get the error I mentioned above. Never saw any login popup.

1 Like

I never had the “automatic login flow” work either. Just go to $HOME/.config/@smartthings/cli and create a config.yaml file. All it needs to contain is:

default:
token: “insert your personal access token here”

Good luck. I have spent hours working on this and managed to finally make a few things work. However, it has been incredibly frustrating. I agree and have personally experienced almost everything @carcuss said.

I was on vacation and came back and installed the latest CLI. Now I notice a new error. When I rung the presentation:device-config:generate, the resulting file has these two lines:

"presentationId": "blah",
"manufacturerName": "SmartThingsCommunity",

I cannot successfully run the device-config:create until I delete these lines. Not sure why they are there or why the next step won’t accept them but it is annoying.

Where do you this token from???

This is really crazy. I just want my custom temperature (Acurite Tower) gauges to work… Nothing fancy just simple numbers supplied by an external app.

You can generate a token from this link https://account.smartthings.com/tokens

1 Like

Did you create the original dth?

Thank you for posting that, but how did you generate it? The first version of the cli had some commands related to the built-in capabilities, but it looks like those were removed…

No, but I’d rather not have to go back and change all my presentations again once it’s implemented.

Well that got me a bit further but still no luck. The error I get now is: “Error: null profile specified. Check config.yaml for errors.”

I just used the CLI, which I have installed as st

st capabilities:presentation momentary -j

(I think - I often get my singulars and plurals wrong as the API is a little inconsistent).