How to add an additional "displayType" on top of an existed one in my Custom Edge Driver?

Hi everyone,

I’m working on a Custom Edge Driver for a sensor and would like to add a power switch to allow the user to turn off the sensor if not needed.

My current Custom Capability and presentation were able to update its state as I want it to be on the ST app, but I don’t know how to add a power switch on top of the “state” displayType.

Do I need to add additional Properties/Commands/Alternatives? If so, how could I do that?

Also, I have trouble displaying the Temperature unit in the detailView so if anyone can catch the bug in my code below. I would appreciate it!

I hope to get y’all assistance soon.

Thanks a lot,

-------------------------Code-------------------------------

Here is the example that I used for my Custom Capability (JSON):

{
"name": "Temperature Measurement",
"status": "live",
"attributes": {
    "temperature": {
        "schema": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "value": {
                    "title": "TemperatureValue",
                    "type": "number",
                    "minimum": -460,
                    "maximum": 10000
                },
                "unit": {
                    "title": "TemperatureUnit",
                    "type": "string",
                    "enum": [
                        "F",
                        "C"
                    ]
                }
            },
            "required": [
                "value",
                "unit"
            ]
        }
    }
},
"commands": {
    
},
"id": "temperatureMeasurement",
"version": 1
}

Here is my current CC presentation (JSON):

{
"dashboard": {
    "states": [
        {
            "label": "Temp: {{temperature.value}}{{temperature.unit}}",
            "alternatives": null
        }
    ],
    "actions": []
},
"detailView": [
    {
        "label": "Temperature",
        "displayType": "state",
        "state": {
            "label": "Temperature: {{temperature.value}}",
            "unit": "temperature.unit"
        } 
    }    
],
"id": "...",
"version": 1
}

Hi @quan.vo

For the first question, Can you explain me more about what problem are you trying to solve?

For the second question yo need add the temperature.unit something like this:

"state": {
            "label": "Temperature: {{temperature.value}}{{temperature.unit}}",
            "unit": "temperature.unit"
        } 

Note: this is a workaround, the issue is already reported.

Hi @AlejandroPadilla,

Thank you for your helpful response!

For the first question, I created a Custom Capability for a sensor. I can set the temperature and display it on the ST app. Now I want to add a power switch to it to allow the user to turn it on/off as they desired both in the “Dashboard” and “Detail View”.

I included the two pictures below to help explain. I hope these help!

Thanks again,
Quan

in this case, you can add the action on the dashboard and add it to the detail view on your presentation

for example, there are the dashboard actions from the SmartThings capability switch

"actions": [
            {
                "displayType": "standbyPowerSwitch",
                "standbyPowerSwitch": {
                    "command": {
                        "on": "on",
                        "off": "off"
                    },
                    "state": {
                        "value": "switch.value",
                        "on": "on",
                        "off": "off"
                    }
                }
            }
        ]

after that, you must add the commands and states to your custom capability

one question, I’m interested in the reason that you are using a custom capability instead of a SmartThings capability, customs capabilities don’t can apply for certification and they don’t are supported on other platforms such as Alexa.

How can I use the SmartThings capability?

I have trouble including the ST switch capability into my code.

Whenever I added these JSON code into my capability and create it. I received this error:

Can you share with me the vid to check it? if you want can send me it in a private message.