Custom Capability and CLI Developer Preview

Yes, you can use the visibleCondition in the device-config.
When the defined condition is met (True), the capability with the visibleCondition property is enabled in the ST app otherwise, the user cannot send commands from there.

You could declare a condition that would always be evaluated as True. Here’s an example:

  • Imagine we have a device with the switch capability and a custom capability named “vacation”.
  • If we want to disable the Switch control when the vacation mode is “enabled”, we should set the following condition:
"visibleCondition": {
    "capability": "namespace.vacation",/*compared capability*/
    "version": 1,
    "component": "main", /*device's component where the capability is located*/
    "value": "vacationMode.value", /*reference to which attribute will be compared*/
    "operator": "DOES_NOT_EQUAL",
    "operand": "enabled" /*value assigned to the attribute compared in this condition*/
}

Does the visibleCondition property affect the color highlighting of the button on the device details screen? I’d still want the switch button to turn to blue color when set to ‘on’ from the driver like it normally would. I haven’t tried it, but I’m worried if I used that and set it to false, it would grey the button out completely and I’d lose the visible on/off cue.

@TAustin when switched on physical device, device status is updated on Details page even that app control is disabled. I think that @krlaframboise has this implemented on his Zooz driver for double switch. This allows control from app, or from physical device or both

Best I can think of is to leave the switch out of the device config for the details page and to use a custom capability for the on/off status using the state (?) tile.

1 Like

Yea, I was trying to avoid yet another custom capability but that’s probably what I’ll need to do. After thinking about it some more, what would really work for this case would be a custom contact sensor - it has the graphical element I’m looking for, PLUS it has no button. But don’t think I can reproduce that in a custom capability, as there is no ‘contact’ display type.

The button remains with the blue color, not as bright but we can still differentiate visibly the state.

Hi, I created two custom capabilities after reading this page.
Unfortunately, two components that I desired to see are never shown up on dashboard or detail view in my app. I have no clue at all how I fix this.

My custom capabilites are below
appleinside37634.plantFertility
appleinside37634.plantMoisture

and VID 70f5bc6f-646a-3b7b-8ee8-a469d9f6b6ac

Please help me.

It seems it is caused by the special characters you use in the labels of both capabilities’ presentations. I tried to use them but I got a 400 error creating the device-config. I created new ones changing this value and I got them to work:
VID: 8573113c-9c49-377f-a752-24cb862a9765

I will still report this to the engineering team to get their feedback.

Thanks for help

At first, I put all characters in English without any special characters. But no luck
So I did change everythings from attributes to presentations. It wasn’t working at all.

I put VID as you mention into DTH. It’s working well.
I will try to re-create attributes as the same as yours.

Thanks again.

1 Like

I tried to create attributes as new and put labels in English. It’s not working.
I put both custom capabilites and standard capablilites (“Temperature Measurement” ,“Illuminance Measurement”). Two standards capabilities are only shown up.

So I removed two standard capabilities to test. An error is occured when generating VID hash

Error: Request failed with status code 400: {"requestId":"F309B299-0DBD-4E0D-9922-459B6C93773F","erro r":{"code":"UnexpectedError","message":"unsuccessful-http-call status=400","details":[]}}"

With standard capabiliteis. VID is generated without errors. But custom capablities are never shown up

Below is generated JSON from command “presentation:device-config:generate”

{
“dashboard”: {
“states”: [
{
“component”: “main”,
“capability”: “appleinside37634.plantFertility”,
“version”: 1,
“values”:
}
],
“actions”: [
{
“component”: “main”,
“capability”: “appleinside37634.plantFertility”,
“version”: 1
}
]
},
“detailView”: [
{
“component”: “main”,
“capability”: “appleinside37634.plantFertility”,
“version”: 1,
“values”: ,
“patch”:
},
{
“component”: “main”,
“capability”: “appleinside37634.plantMoisture”,
“version”: 1,
“values”: ,
“patch”:
}
],
“automation”: {
“conditions”: [
{
“component”: “main”,
“capability”: “appleinside37634.plantFertility”,
“version”: 1,
“values”: ,
“patch”: ,
“exclusion”:
},
{
“component”: “main”,
“capability”: “appleinside37634.plantMoisture”,
“version”: 1,
“values”: ,
“patch”: ,
“exclusion”:
}
],
“actions”: [
{
“component”: “main”,
“capability”: “appleinside37634.plantFertility”,
“version”: 1,
“values”: ,
“patch”: ,
“exclusion”:
},
{
“component”: “main”,
“capability”: “appleinside37634.plantMoisture”,
“version”: 1,
“values”: ,
“patch”: ,
“exclusion”:
}
]
},
“type”: “dth”
}

What do you mean by this?
Did you delete the custom capability and create it again using the same name?
I tried to create the device-config using your capability and I got the same error.
The capabilities I used seem to have the same configuration, so if only yours are not working I suggest you create other ones with a different name.
There’s no error using the standard capabilities because they are not faulty, it only happens when we leave those two.

yes, I meant delete and create it again using the same name. I just wanted to start over without
non-english characters in label of capability presentation. ( you commented special characters can be a problem)

I tried to create new attribute with diffrent name. The result is the same as before. It’s not working
appleinside37634.moisture / appleinside37634.fertility
vid : 211653d3-8d30-3cb6-810d-3f658e39aeb9

1 Like

I’ll send you a DM to continue our conversation there @LucasRyu. I need more information about this situation.

Hi, @LucasRyu

I’ve been reviewing your issue and initially, I got the same results and the capabilities were not populating properly the app. Fortunately, with a few tweaks, I was able to find the needle in the haystack.

I noticed that your capabilities were not supporting alternatives at all, so, to have at least the minimal reference as an alternative I created a copy of your capabilities and included the following state alternative in both capability presentations:

  • At dashboard.states and detailView.state:
"alternatives": [
    {
        "key": 0,
        "value": 0
    }
]

With this update, both capabilities populated the app accordingly:

(the device on the left implemented your capabilities, the device on the right implemented my copy of your capabilities with the alternatives)

If you wanna take a better look, query the presentation of these capabilities:

  • againschool57104.fertility
  • againschool57104.moisture
  • vid (presentationId): 4eb2de3e-3880-3822-88c5-7232fd475850
  • mnmn (manufacturerName): SmartThingsCommunity

Let us know if this addresses your issue.

Thanks for your reply.

I updated capabilitiy presentation as you commented. I added “alternatives” to it
However, the result is the same as before. Is there any way to debug or see any logs?

1 Like

@LucasRyu Out of curiosity… did you try recreating the device with a new name / label?

I ask this because, as UI metadata of devices is cached by label/name, you might need to recreate the device to force a metadata update (just as I had to, as you can see in the screenshots above).

Also, there are a few methods to force a metadata update (most of them only for Android) i.e.:

  • Menu > Settings > Tap “Developer Mode” > RESTART APP
  • Phone Settings > Apps > SmartThings > Storage > Clear Cache
  • At API level, recreate device presentation with a minimal update (add a new presentation-less capability to detailView such as Health Check, Refresh, etc.)
  • In the case of DTHs, create a new DTH instance at the Groovy IDE.

Yes. I can’t count how many times I recreate device / dth / capabilites… with different name.
And I also did clear cache and almost everything I can do.

The thing is custom capabilities someone else created is shown up very well without ‘alternative part’ or recreating device or dth … It’s just affected right away. But my custom capabilities are always problem. So I just copied same attributes and presentation from other one working well and created same capabilities But it’s not working.

1 Like

@erickv

I don’t want to distract too much from the ongoing discussion, but a thought came to mind while reading it. A device config has a type key, set to either dth or profile. It doesn’t seem to carry through to the presentation or have any obvious influence on the contents of the rest of the config, so does it make a difference to how the presentation is created? To put it another way, if you have dth when you should have profile, or vice versa, do things break?

2 Likes

Hey, @orangebucket

Exactly that came to my mind as well, but it seems that the Presentations API is no longer considering the type (dth or profile) necessary, as the final output doesn’t even reference it.

However, under this same context, I decided to run a few more tests directly using DTHs and found out that @LucasRyu is right, the issue is directly related to his capabilities, i.e. his own namespace (appleinside37634).

So this is something that I’m currently documenting using as reference the following vids / presentationIds whose custom capabilities are the same (in schema and presentation) but differs in namespace:

  • 029340fa-ffd7-3762-8a53-e7aee26a1772 (using appleinside37634)
  • 19b9e5b3-07c1-3d32-a6ce-6f8318993681 (using againschool57104)

Hey, @LucasRyu

Great news! Our engineers have been looking into this issue, and it was indeed related to the namespace appleinside37634.

So, the fix will be implemented as soon as possible and once I get the update, I’ll share the details with you.

Cheers!