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.