Another question for developers. Code for default tile/value

thank you getting closer… i did as you outlined and even saved the new vid in the device handler and republished but still getting “checking status” on the dashboard view

ie

C:\st>cli-win presentation:device-config:generate 7e6bf0ba-7cb0-40a1-876a-a56adcd2084c --dth -j > st814.json.orig

C:\st>copy st814.json.orig st814.json.new
1 file(s) copied.

C:\st>e st814.json.new

C:\st>dir /od
Volume in drive C is Windows
Volume Serial Number is B259-C6B9

Directory of C:\st

07/31/2020 01:04 PM 99,544,590 cli-win.exe
08/05/2020 03:35 PM 28,301,141 smartthings-win.zip
08/05/2020 03:41 PM 1,090 st814.dv
08/05/2020 03:42 PM smartthings-win
08/05/2020 03:42 PM 0 smartthings.log
08/06/2020 02:15 PM 7,647 st814.json.orig
08/06/2020 02:15 PM .
08/06/2020 02:15 PM …
08/06/2020 02:19 PM 4,480 st814.json.new
6 File(s) 127,858,948 bytes
3 Dir(s) 365,772,607,488 bytes free

C:\st>cli-win presentation:device-config:create -i st814.json.new
mnmn: SmartThingsCommunity
vid: 97ba8873-f610-3322-a2be-ec1650316228
type: dth
dpInfo: null
iconUrl: null
dashboard:
states:
- component: main
capability: temperatureMeasurement
version: 1
values:
visibleCondition: null
actions:
- component: main
capability: temperatureMeasurement
version: 1
values:
visibleCondition: null
detailView:

  • component: main
    capability: temperatureMeasurement
    version: 1
    values:
    visibleCondition: null
  • component: main
    capability: relativeHumidityMeasurement
    version: 1
    values:
    visibleCondition: null
  • component: main
    capability: battery
    version: 1
    values:
    visibleCondition: null
  • component: main
    capability: configuration
    version: 1
    values:
    visibleCondition: null
  • component: main
    capability: healthCheck
    version: 1
    values:
    visibleCondition: null
    automation:
    conditions:
    • component: main
      capability: temperatureMeasurement
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: relativeHumidityMeasurement
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: battery
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: alarm
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: configuration
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: healthCheck
      version: 1
      values:
      visibleCondition: null
      actions:
    • component: main
      capability: temperatureMeasurement
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: relativeHumidityMeasurement
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: battery
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: alarm
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: configuration
      version: 1
      values:
      visibleCondition: null
    • component: main
      capability: healthCheck
      version: 1
      values:
      visibleCondition: null

C:\st>cli-win presentation 97ba8873-f610-3322-a2be-ec1650316228 -j
{
“mnmn”: “SmartThingsCommunity”,
“vid”: “97ba8873-f610-3322-a2be-ec1650316228”,
“iconUrl”: null,
“dashboard”: {
“states”: [
{
“label”: “{{temperature.value}} {{temperature.unit}}”,
“alternatives”: [
{
“key”: “C”,
“value”: “°C”,
“type”: “active”,
“description”: null
},
{
“key”: “K”,
“value”: “°K”,
“type”: “active”,
“description”: null
},
{
“key”: “F”,
“value”: “°F”,
“type”: “active”,
“description”: null
}
],
“group”: null,
“capability”: “temperatureMeasurement”,
“version”: 1,
“component”: “main”,
“visibleCondition”: null
}
],
“actions”: ,
“basicPlus”:
},
“detailView”: [
{
“capability”: “temperatureMeasurement”,
“version”: 1,
“label”: “___PO_CODE_SMARTTHINGS_DREAM_SAC_TMBODY_TEMPERATURE”,
“displayType”: “slider”,
“toggleSwitch”: null,
“standbyPowerSwitch”: null,
“switch”: null,
“slider”: {
“range”: [
-20,
50
],
“step”: null,
“unit”: “temperature.unit”,
“command”: null,
“value”: “temperature.value”
},
“pushButton”: null,
“playPause”: null,
“playStop”: null,
“list”: null,
“textField”: null,
“numberField”: null,
“stepper”: null,
“state”: null,
“multiArgCommand”: null,
“component”: “main”,
“visibleCondition”: null
},
{
“capability”: “relativeHumidityMeasurement”,
“version”: 1,
“label”: “___PO_CODE_SMARTTHINGS_DREAM_SAC_HEADER_HUMIDITY_CHN”,
“displayType”: “slider”,
“toggleSwitch”: null,
“standbyPowerSwitch”: null,
“switch”: null,
“slider”: {
“range”: [
0,
100
],
“step”: null,
“unit”: null,
“command”: null,
“value”: “humidity.value”
},
“pushButton”: null,
“playPause”: null,
“playStop”: null,
“list”: null,
“textField”: null,
“numberField”: null,
“stepper”: null,
“state”: null,
“multiArgCommand”: null,
“component”: “main”,
“visibleCondition”: null
},
{
“capability”: “battery”,
“version”: 1,
“label”: “___PO_CODE_SMARTTHINGS_DREAM_SAC_TMBODY_BATTERY”,
“displayType”: “slider”,
“toggleSwitch”: null,
“standbyPowerSwitch”: null,
“switch”: null,
“slider”: {
“range”: [
0,
100
],
“step”: null,
“unit”: null,
“command”: null,
“value”: “battery.value”
},
“pushButton”: null,
“playPause”: null,
“playStop”: null,
“list”: null,
“textField”: null,
“numberField”: null,
“stepper”: null,
“state”: null,
“multiArgCommand”: null,
“component”: “main”,
“visibleCondition”: null
}
],
“automation”: {
“conditions”: [
{
“capability”: “temperatureMeasurement”,
“version”: 1,
“label”: “___PO_CODE_SMARTTHINGS_DREAM_SAC_TMBODY_TEMPERATURE”,
“displayType”: “numberField”,
“slider”: null,
“list”: null,
“numberField”: {
“value”: “temperature.value”,
“unit”: “temperature.unit”,
“range”: [
-20,
50
]
},
“textField”: null,
“emphasis”: null,
“component”: “main”,
“visibleCondition”: null
},
{
“capability”: “relativeHumidityMeasurement”,
“version”: 1,
“label”: “___PO_CODE_SMARTTHINGS_DREAM_SAC_HEADER_HUMIDITY_CHN”,
“displayType”: “numberField”,
“slider”: null,
“list”: null,
“numberField”: {
“value”: “humidity.value”,
“unit”: null,

here is new header in the dth

metadata
{
definition (name: “EverSpring ST814 V4a”, namespace: “lgkapps”, author: “@Ben chad@monroe.io and lgkahn”, ocfDeviceType: “x.com.st.d.sensor.moisture”, mnmn: “SmartThingsCommunity”, vid: “97ba8873-f610-3322-a2be-ec1650316228” )
{
capability “Battery”
capability “Temperature Measurement”
capability “Relative Humidity Measurement”
capability “Configuration”
c

i also created a whole new device handerl ver 4b on the code in case that was the issue but still coming up with checking status

No it DOES work with the new version 4b dth Thanks that is the kind of help we needed guess it took a while to load on the shard… see attachment . Thanks again… Do you have a link for the stock capabilities I am looking to show a simple text message on the dashboard view as the current state of a device…

larry

Hi @Lgkahn,

Glad to help! You can find the predefined capabilities in this document, also, what allows you to show the status in the dashboard view is the capability presentation, you can see their configuration using this command:

smartthings capabilities:presentation capabilityID -j

If none of them works for you, you should consider the alternative of creating a custom capability.

If one of the previous posts answered your question, can you please mark it as solved? If not, let me know what’s going on and I can dig in further.

ok when i looked at the presentation for contactsensor capability it only shows me the enumeration type but in the detailed view it shows a little color graphic next to it… Why and i not seeing that.
I want to have a custom ccapability with 3 sttates but also a color on the text or nect to it.
also another capability or presentation below it with 2 text (display only) fields and then finally a push button below it

on the dashboard view I just want to display the first custom enumation value

i tried to get the display info for a specfic device handler ie z-wave door/contact by going in the id to he edit devic etype option and finding the id in the page source but it doesnt seem to work?

C:\st>smartthings capabilities:presentation 813a1f28-7ec4-4f6a-b5a2-d1ffd8609ca5 -j
[2020-08-06T15:47:18.218] [ERROR] cli - caught error Error: could not find any namespaces for you account. Perhaps you haven’t created any capabilities yet.

i want to create a capability showing info like this

{
“id”: “alarmStatusPanel”,
“version”: 1,
“name”: "Alarm State,
“status”: “live”,
“attributes”: {
“armStatus”: {
“schema”: {
“type”: “object”,
“additionalProperties”: false,
“properties”: {
“value”: {
“type”: “string”,
“title”: “String”,
“enum”: [
“Disarmed”,
“Armed Stay”,
“Armed Away”,
“Unknown”
]
}
},
“required”: [
“value”
]
}
},

    "lastAlertType": {
        "schema": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "value": {
                    "type": "string",
                    "title": "String".
                    "enum": [
                        "Smoke/CO2 Alert",
                        "Water Alert",
                        "IntrusionAlert",
                        "Unknown"
                    ]
                }
            },
            "required": [
                "value"
            ]
        }
    },

    "lastAlert": {
        "schema": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "value": {
                    "type": "string",
                    "title": "String",
                    "maxLength": 150
                }
            }
        }
    },

    "statusText": {
        "schema": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "value": {
                    "type": "string",
                    "title": "String",
                    "maxLength": 150
                }
            }
        }
    }




},
"commands": {

}

}

Capability: peaceparty20604.alarmstatuspanel

Attributes:
±--------------------------------+
¦ Name ¦ Type ¦ Setter ¦
±--------------±-------±-------¦
¦ armStatus ¦ string ¦ ¦
¦ lastAlert ¦ string ¦ ¦
¦ lastAlertType ¦ string ¦ ¦
¦ statusText ¦ string ¦ ¦
±--------------------------------+

C:\st>

Hi @Lgkahn,

The smartthings capabilities:presentation command is only for capabilities, if you add --help at the end you can get a brief description.

If you want to see the presentation of an existing device, you should consider to get the devices list through an API request, there, you can find a property “presentationId” and use it in the command to visualize it.

For the custom capabilities, I recommend you to focus in one functionality for each one of them, also, the setter command is used to change the value in the attribute, you can take switchLevel capability as an example

Hi @nayelyz,

If I have a DTH for a hub connected device that uses a predefined capability (illuminance) referenced in the document from your post #24, what is the proper way I should be calling that so that illuminance is the default instead of battery level? Since this is a predefined capability, do I still need to use the CLI to create my own VID?

I appreciate any help since I’m just now getting up to speed and I have a couple DTH’s used by the community that do not present the default tile as expected. Thanks!!!

im confused right above you told me to use this command to view a standard capabilities presentatin… or am i missing something

as i said i ran it for an existing capabliity ie contactsensor and i what comes back does NOT match when i am seeing on a deivce which is u sing this stock capability in the display

yes just follow that example that is exactly the same thing i did except my stock capablilty was temperature Measurement

aslo this appears to be unix as case matters

you also need to be using your own device handler or a copy of th estock one so that you can change the vid in the decice handler code in the last step to match your newly generated vid

Capabilities have their own presentations that define how they look when they are used as the status on the dashboard tile, as the action on the dashboard tile, as tiles on the detail pages, and in automations. You don’t need to worry about that here as that is already defined.

What you need to work with is the device config, which says which capabilities are to be used in the dashboard, details page and automations for anything using your device handler, and sometimes in what order.

This device config is combined with the info in the capability presentations, and probably some other fluff, to create a device presentation.

Prerequisites:

The UUID for your device handler as installed in your IDE. It is in the URL.
The CLI installed. Let’s call it ‘st’.

First you need to generate a default device config for your DTH, using the UUID of your device handler in the below.

st presentation:device-config:generate UUID --dth --output=config.json

The resulting config.json file is a ‘device config’. It describes at a macro level how you want your device handler to be presented. You need to edit it to make sure that illuminance is being used as the status in the dashboard tile. The bit you are interested in is near the top:

"dashboard": {
    "states": [
        {
            "component": "main",
            "capability": "illuminanceMeasurement",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "battery",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "configuration",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "sensor",
            "version": 1,
            "values": [],
            "visibleCondition": null
        },
        {
            "component": "main",
            "capability": "healthCheck",
            "version": 1,
            "values": [],
            "visibleCondition": null
        }
    ],

You want the first entry in the ‘states’ array to be your illuminance measurement. The other entries aren’t currently used by the app as dashboard tiles currently only support one state. When I tried it using what I think is your DTH it was already OK.

Now you need to create a device presentation that is based on the description in your potentially updated device config.

st presentation:device-config:create --input=config.json

   Basic Information
    ┌──────┬──────────────────────────────────────┐
    │ VID  │ a3fe3c0d-1f51-3d51-9309-566ba1219b4f │
    ├──────┼──────────────────────────────────────┤
    │ MNMN │ SmartThingsCommunity                 │
    ├──────┼──────────────────────────────────────┤
    │ Type │ dth                                  │
    └──────┴──────────────────────────────────────┘

8< SNIP 8<

Behind the scenes a perhaps surprisingly large JSON file has been created that is your 'device presentation`. You now need to tell your device handler to use that presentation by adding the VID and MNMN from the above (NOT from the config.json file). So for example:

definition (name: "My Xiaomi Mijia Smart Light Sensor", namespace: "jsconstantelos", author: "jsconstantelos", mnmn: "SmartThingsCommunity", vid: "a3fe3c0d-1f51-3d51-9309-566ba1219b4f")

The new app needs to load this presentation for each device that is using your device handler. This is on a twelve hour cache (apparently), so you may need to give it a nudge. You can clear the cache on the app and that is said to do the job, but I prefer to update the devices in the IDE (you’ll need to change the name or something to make it a proper update).

That should do it.

2 Likes

Thank you @orangebucket, you have been extremely helpful, as has @Lgkahn. Really appreciate the help!

1 Like

Hi @orangebucket,

That worked beautifully, thank you so much. Your VID example for my light sensor DTH helped me a lot, and it worked exactly the way I always wanted it to look in the new app. Now time to work on all my other DTH’s.

It’s contributions like yours that make this community a great and valuable source of information and help.

:clap: :trophy:

2 Likes

this is slightly wrong the correct command is this
C:\st>smartthings presentation:device-config:generate UUID --dth --output zooz4in1.json.orig -j

I pasted the actual command I used with the UUID masked. You don’t need the -j if the output file has the .json extension.

1 Like

Either way gave me the same results. What I’m starting to see is that I have one DTH I’m trying to work with and reorder tiles, but when I run create it doesn’t honor the changes I made in the json file. Driving me a bit nuts, so I think I’ll take a break for some lunch and try again later today.

im seeing the same thing… i just made changes and they are not being honored… i know the device type work as it is the same handler that is working fine in my other location… Maybe the shards are not communicting and updating today for some reason… I will also take a break and hope it updates later.

As a side note still havent found a display method or example just to display text or an enumeration type of states

1 Like

I’m not sure that the order of tiles is actually respected. I tend to see the switch capability displayed first and then hints of alphabetical order, with exceptions.

A lot seems to happen at the device plugin level that is undocumented. If you compare the capability presentations for the standard capabilities with what you actually get, they can be very different. For example temperature and humidity get merged into one tile and a link to graphs is provided. Then there are the Quick Controls for switches and buttons. Nothing in the API mentions such things. Nice features but they make a mockery of the API.

Hi @Lgkahn,

The parameter received in that command is the capability ID, the way you use it for contactSensor:

smartthings capabilities:presentation contactSensor -j

Before, I was referring to this one:

Here is an example analyzing a device I have installed:
I got the presentationId, Manufacturer name, and deviceId values from the devices list and used them as parameters to get the device presentation.


You can see in both the dashboard configuration. If you see differences, it can be due to the manufacturer.

Would you mind to please share your entire use case to help you implement it and guide you through the process?

ya, well that is the biggest issue . All our custom work for layout etc on the detail pages for devices is now in the #$itter. That is on the things I am pissed about. However, i understand because from a support standpoint it makes more sense to have a standard view of a device etc… I dont know why they couldnt of kept the detailed view however… oh well. So I assume you have changed the order the .json and it is not working?