How to change the value shown in the device card on the Home screen

I have a device which is both a motion sensor and contact sensor among others. I am only using it as a motion sensor, the device card on the Home screen is only showing the status of the contact sensor.

Is there a way to change the value being displayed?

If not , I recommend that (1) the value being displayed in the device card is configurable, (2) the device card displays the last updated value, (3) allow copies of the device card displaying different values, (4) allow for multiple values to be displayed in the device card.

2 Likes

I believe the only way is to modify the code yourself - Custom Capability and CLI Developer Preview

The classic app shows motion while the new app shows the contact sensor status.

That is presumably because the device handler includes the UI definition used by the Classic app and that explicitly tells it to use motion.

The device handler doesn’t include the UI definition for the new app and so the new app is trying to do something sensible with what it can find. Unfortunately for you it has plumped for Contact Sensor rather than Motion Sensor.

It can be educated and @hongtat has linked to an introduction to a tool that can do the job. It is a little fiddly because the new way of doing things has to be retrofitted to a legacy device handler. When building new device integrations it is just a point and click change.

Thanks @orangebucket, @hongtat

I wrote the device type a long time ago, in a different life. I looked at the video in post @hongtat had linked to and didn’t have a clue what he was talking about. I guess I need to go back to the basics.

I noticed that my driver is running in the cloud and I assume that redoing the driver would allow me to move the execution local.

I did the development in Graph IDE; do I need to move to the Developer Workspace?

No it wouldn’t. It is possible to set custom handlers to run locally but they will be running default code in the firmware and not your custom code.

Device handlers for hub connected devices are still using the Graph IDE at the moment.

To change the attribute displayed as a status on dashboard tiles requires an explicit device presentation to be included in the DTH. That is just extra parameters in the β€˜description()’ saying something like:

mnmn: "SmartThings", vid: "generic-motion"

or

mnmn: "SmartThingsCommunity", vid: "UUID"

The first style uses stock presentations that ST have already created. You can see them at https://vid-selector.glitch.me/ - if one of them matches up with the capabilities of your device and also selects motion for dashboard status then great.

The second version uses a custom presentation that is based on your DTH. If you did have the CLI installed it would be a matter of doing a sequence like:

smartthings presentation:device-config:generate <dth id> --dth --output=config.json
edit config.jso
smartthings presentation:device-config:create --input=config.json
edit your DTH with the resulting mnmn: and vid:

It only takes a few minutes once you are geared up to it, though last time I looked there were a couple of bugs that had been introduced into the CLI to complicate things.

I have tried four things: (1) change the order of the capabilities and list motion first, (2) change the order of the tiles to list motion first (3) remove contact from β€œmain”

main([β€œmotion”, β€œtemperature”, β€œilluminance”])

(4) add vid:β€œgeneric-motion” to the definition

definition (name: β€œPhilio PSM02”, vid:β€œgeneric-motion”)

So far no success to display the status of the motion sensor.

I need the same info to change the default display value on tile icon for devices with multiple attributes, Can anyone please help ?

1 Like

I need this info too

OK, firstly bear in mind that you may find the process a bit arcane, complicated or think that it just sucks. Fair enough, but it is functionality designed for the β€˜new’ environment being retrofitted into the legacy environment, it isn’t going to be pretty.

The following content is based on an actual example that appeared in another post. The object of the exercise was to have a device display the illuminance in the dashboard tile.

The tool that will be used is the CLI. Yes, that is CLI as in Command Line Interface. It is essentially being used to make it easier to use the SmartThings REST API.

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 those for the stock capabilities as they are 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 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 β€˜smartthings’.

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

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

The resulting config.json file is a device config. You can think of it as describing at a macro level how you want your device handler to be presented, but basically it is the user configurable bits of your device presentation. The bit of interest 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
        }
    ],

The first entry in the β€˜states’ array is the one that is used to display the attribute status in the array. The other entries aren’t currently used by the app as dashboard tiles currently only support one state. In this case the illuminance measurement is shown first which was exactly what was required.

At the time of writing, there is a bug in the CLI/REST API that requires an extra edit to this file. The two lines containing presentationId and manufacturerName need to be deleted. These duplicate the lines vid and mnmn which are still needed. What is happening is that old terminology is being replaced by something more suitable and it hasn’t been implemented quite right yet.

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

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

   Basic Information
    β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ VID  β”‚ a3fe3c0d-1f51-3d51-9309-566ba1214f9b β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ MNMN β”‚ SmartThingsCommunity                 β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ Type β”‚ dth                                  β”‚
    β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

8< SNIP 8<

At the time of writing you will not actually see a summary like the above. You will get a full device config thrown back at you. That is a bug that has crept into the CLI and hasn’t crept out again yet. Fortunately the vid and mnmn lines will appear at the bottom of that file so you are OK.

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 original config.json file, though they may be the same if no changes were made). So for example:

definition (name: "My Light Sensor", namespace: "fbloggs", author: "Fred Bloggs", mnmn: "SmartThingsCommunity", vid: "a3fe3c0d-1f51-3d51-9309-566ba1214f9b")

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 the job. Bear in mind that if anyone has already done this, you can use the β€˜vid’ they created. It may well be the same anyway.

1 Like