Custom Capability and CLI Developer Preview

@guxdude I can’t help with stepper, but here’s a working example of a DTH with a custom capability slider. You should be able to query platinummassive43262.mySlider in the CLI to see my (extremely basic) capability and capability presentation. Hopefully this gives you a starting point.

metadata {
	definition (name: "mySliderTest", author: "philh30", namespace: "philh30", vid: "bb7e2167-c7ad-37ce-b44d-6a83619ae225", mnmn: "SmartThingsCommunity") {
        capability "platinummassive43262.mySlider"
        capability "Health Check"
	}

	simulator {}

	tiles {}
}

def parse(String description) {
	log.trace "parse($description)"
}

def installed() {
	log.trace "Installed"
	initialize()
}

def updated() {
	log.trace "Updated"
	initialize()
}

def setSliderThing(arg){
    log.trace "Slider: ${arg}"
    sendEvent(name: 'theSliderThing', value: arg)
}

private initialize() {
	log.trace "Initialize"
	sendEvent(name: "theSliderThing", value: 30)
	sendEvent(name: "healthStatus", value: "online")
}

Thanks so much for this. I had missed your summary above on what is working and not working. This is also very helpful. One note I discovered:

I found the syntax described in the documentation was incorrect. I was able to get the presentation to execute fine once I switched to this syntax:

    "displayType": "stepper",
	"stepper": {
		"command": { "name": "setValueOne"},
		"value": "valueOne.value",
		"unit": "valueOne.unit",
		"range": [-1000,1000],
		"step": 1
	}

Of course, I still was unsuccessful in getting anything to actually display. I was thinking I might try the numberField as you suggested above. All I really want is a number with up/down buttons anyway.

1 Like

Are you referring to the json or the device handler? Not sure what you mean.

That did it. Thanks!

@DavinD Your capability defines the attribute as “Pressure” while your capability presentation uses “pressure”. I’m pretty sure the capitalization matters. I’d suggest you change the attribute in the capability to match the presentation - I’ve gotten caught by the caching issue when trying to change the capability presentation, so you might have better luck with the capability (also, you’ll have less to edit).

Edit: I missed that you were getting an error at the device-config:generate step. I think this line in your DTH is causing it - I don’t think Execute is a valid capability.

Well, I’m not sure what I am doing incorrectly. Everything runs with no errors but I still get nothing in the display. Just ‘status: connected’. I even went in and added the ‘unit’ I didn’t need. I’m not sure if things are going wrong in the presentation or device-config. Here are the commands I ran:

gux@Guxs-MBP DTHMigration2 % smartthings capabilities:update dictionaryfabric11101.adjustIntegerValues 1 -i AdjustOneIntegerValueCapability.json -o AdjustOneIntegerValueCapabilityOut.json

gux@Guxs-MBP DTHMigration2 % smartthings capabilities:presentation:update dictionaryfabric11101.adjustIntegerValues 1 -i AdjustOneIntegerValuePresentation.json -o AdjustOneIntegerValuePresentationOut.json

gux@Guxs-MBP DTHMigration2 % smartthings presentation:device-config:generate <DTH ID> --dth -o AdjustOneIntegerValueGenericConfig.json -j

gux@Guxs-MBP DTHMigration2 % smartthings presentation:device-config:create -i AdjustOneIntegerValueConfig.json -o AdjustOneIntegerValueConfigOut.json

Then I copied the vid from he last file and put it in the DTH. nothing.

Hello @DavinD,
The capability “Execute” could be the one causing the error because it doesn’t have a presentation. The device-config is generated based on that, so, when it is not found, it shows the error. You can query the capabilities presentation as the example below:

smartthings capabilities:presentation execute -j
2 Likes

Does your DTH still have runLocally: true in it? If so I’d suggest removing it as it may help. Let’s just say things made a lot more sense when you simply couldn’t have that in a custom handler and it almost certainly doesn’t do what you think it does.

Thanks for the suggestion. Yes, I wondered about that so I removed it a little while back. Didn’t seem to make difference. I did notice, I had changed namespace to the one assigned when I started this process instead of my GitHub namespace. Not sure which is correct but noticed @philh30 used his regular user name so I switched back to that. Also didn’t make a difference. There is obviously some trick I am missing. When I have some time later, I think I need to start from scratch again and see if I can get something working.

I commented out the “Execute” capability and still get the same error.

I figured it out. I was using the GUID from my device, not my device handler. Doh!

1 Like

Hello
Does anyone manage to display multiple displayTypes in detailView?
is there any solution?

I have some custom capabilities I created before the outage. When they came back, they displayed units in the detail view. That is great :+1:

I have now created a some new capabilities. But it wont display the units until i pull down the page in the detail view and get the refresh circle. If I go out and back in they are gone. I cant find any difference from the capabilities that display unit all the time, except that they were created earlier.

1 Like

First of all, thanks again for all your help. I finally got one value to display using a numberField. I edited the device type I was working with to match exactly but it wouldn’t work. Had to start from scratch. I think this is the ‘cache’ issue others have discussed? Very frustrating.

Now, regarding the statement above, I tried to put two numberFields in one capability and only the first displays. Should I be able to display two numbers or do I need two different capabilities for this? Thanks again!

3 Likes

Same issue here

1 Like

Hello @Panos and @guxdude,
Custom capabilities should be focused on one functionality, if you want to show several tiles and control them, you could create a set of capabilities and add them in one device profile or DTH to define they belong to the same device.

I’ve finally made some progress on my “Hello World” capability.

The “pressure” attribute shows up on the dashboard.

However, it does not show up on the “details”

I’ve seen this issue referenced above to having null values, but my device has a value for “pressure”

I tried changing the device name to clear the cache.

Edit
Here’s my 2 json files.

"dashboard": {

        "states": [

            {

                "label": "{{pressure.value}}"

            }

        ],

        "actions": [],

        "basicPlus": []

             },

    "detailView": [

        {

            "label": "pressure",

            "displayType": "state",

            "state": {

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

                "unit": "pressure.unit"

            }

        }

    ],

    "automation": {

        "conditions": [

            {

                "label": "pressure",

                "displayType": "numberField",

                "numberField": {

                    "value": "pressure.value",

                    "unit": "pressure.unit"

                }

            }

        ],

        "actions": []

    },

    "venturecircle58707.pumppressure",

    "version": 3

}

…and the other one.

{
    "mnmn": "SmartThingsCommunity",
    "vid": "df86bc05-5068-30b0-8149-89c059eb0137",
    "type": "dth",
    "dpInfo": null,
    "iconUrl": null,
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "venturecircle58707.filterpumppressure",
                "version": 3,
                "values": [],
                "visibleCondition": null
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "healthCheck",
                "version": 1,
                "values": [],
                "visibleCondition": null
            },
            {
                "component": "main",
                "capability": "execute",
                "version": 1,
                "values": [],
                "visibleCondition": null
            },
            {
                "component": "main",
                "capability": "venturecircle58707.filterpumppressure",
                "version": 1,
                "values": [],
                "visibleCondition": null
            }
        ]
    },
    "detailView": [
        {
            "component": "main",
            "capability": "healthCheck",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "execute",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "venturecircle58707.filterpumppressure",
            "version": 1,
            "values": [],
            "visibleCondition": null
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "healthCheck",
                "version": 1,
                "values": [],
                "visibleCondition": null
            },
            {
                "component": "main",
                "capability": "execute",
                "version": 1,
                "values": [],
                "visibleCondition": null
            },
            {
                "component": "main",
                "capability": "venturecircle58707.filterpumppressure",
                "version": 1,
                "values": [],
                "visibleCondition": null
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "healthCheck",
                "version": 1,
                "values": [],
                "visibleCondition": null
            },
            {
                "component": "main",
                "capability": "execute",
                "version": 1,
                "values": [],
                "visibleCondition": null
            },
            {
                "component": "main",
                "capability": "venturecircle58707.filterpumppressure",
                "version": 1,
                "values": [],
                "visibleCondition": null
            }
        ]
    }
}

It’ll help with the readability if you enclose your code in code quotes as described here:

This is how it meant to be?
One capability per one attribute?

Currently I use one capability with 3 attributes.
If I want to display all 3 attributes, should I create one new capability per attribute?

How we can define the order of display of each capability to device’s detailview?
And which capability should be displayed on dashboard view?

Your device-config has version 3 of venturecircle58707.filterpumppressure in the dashboard but version 1 in the detailView.

1 Like