Custom Capability and CLI Developer Preview

it’s actually pretty cool. in rooms manager app i have settings to use thermostat or in room ac and/or heater to manage the temperature of the room. in the new app the settings are controllable through the thermostat modes card.

by default thermostat modes has a command named emergency mode which i have no use for in my app. after sending that event and removing emergency as a supported command here’s what it looks like afterwards when i click on the gear icon on the mode card:

for another room which has no thermostat or ac or heater after sending that event with all other commands except off removed here’s what it looks like:

the gear icon is no longer present since off is now the only supported thermostat mode for that room.

imagine it works the same way for other capabilities and adds extensibility for any capability.

1 Like

@bangali This feature has been there for a very long time and it’s implementation is specific to the new ST app using the presentation layer conditional attributes.

What’s new I see is eventType: "ENTITY_UPDATE”. The supportedThermostatModes works even without this attribute. So what’s this new attribute in sendEvent @nayelyz? What is eventType and what are the supported values?

didn’t know that could be done in classic as well to dynamically update the supported commands for a device using sendEvent … will have to give that a try.

thank you.

Not Classic, i mean this feature has been in the new app for about a year AFAIK, but the sendEvent attribute is new. It (used to) work without this attribute, so my question is what’s this new attribute in sendEvent?

ahh … got you.

I’d like to share with you a checklist for you to guide when having issues with the device presentation

  1. To use the “unit” property in the presentation, it must be included in the capability definition. (This can cause the “checking status” error)
  2. The capability presentation must not include attributes that belong to a different capability or don’t exist
  3. Verify that your presentation was created and has your configuration (After every change in the capability presentation, you need to regenerate the device presentation)
    Use the command smartthings presentation vid -j
  4. Include the correct presentation properties in your DTH (vid:”xxxx-xxxx-xxxx” and mnmn:”SmartThingsCommunity”)
  5. Make sure that you saved and published the changes you made in the DTH.
  6. Check if the device is not using the draft version of the DTH (edit the device in the IDE and see this field value)
  7. Look for the device in the list and verify if the presentation and capabilities match with your configuration
  8. Query the device status to check the capabilities’ value (the view is affected by this)
  9. Try the suggestions to force the metadata refresh (Remember that the automatic refresh is done twice a day):
  • Clear the app cache (android devices)
  • Reopen de app
  • Update the device or handler name
  • Create a new device handler with the same configuration except for the name
  • Add a new capability to the device and create a new presentation
1 Like

@nayelyz
ok. as you suggested I swapped the capabilities and now I am using “faithboard04631.coffeemachine” for the selectitem
however, I still have the same “network error occured” problem when I select an item from that list.
so both of my capabilities have the issue.
what is the problem ?

you’ve mentioned that you’d investigate that further. found anything ?

Hi, most likely, your selected item is not defined as part of the custom capability’s schema (original custom capability definition) or you have not defined/used the setter for this custom capability.

That happened to me, so I’m just sharing…

no that’s not the case.
I have just one attribute and command for this capability. And I am using only that command.
what do you mean by “selected item” ?

capability definition is :

{
    "id": "faithboard04631.coffeemachine",
    "version": 1,
    "status": "proposed",
    "name": "coffeemachine",
    "attributes": {
		"listElement": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "string"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "setter": "setListElement",
            "enumCommands": []
        }
    },
        "commands": {
        "setListElement": {
            "name": "setListElement",
            "arguments": [
                {
                    "name": "value",
                    "optional": false,
                    "schema": {
                        "type": "string"
                    }
                }
            ]
        }
    }
}

Hi, in your case, the schema’s variable “listElement”, but it seems ok.

You may have a problem in the setter function then (DTH code).

the command in DTH is:

> def setListElement(argument){
> 	sendEvent(name: "listElement", value: "${argument}")
>     make(argument)
> }

that is very simple.
then the make() command is:

def make(item) {
    sendEvent(name: "faithboard04631.coffeemachineselect.lastorder", value: "${item}", isStateChange: true, displayed: true)
	unschedule()
	runEvery1Minute(refresh)
    def hosthex = convertIPtoHex(ip).toUpperCase()
    def porthex = convertPortToHex(port).toUpperCase() 
    def path = "/coffee/$item"
    def headers = [:] 
    headers.put("HOST", "$ip:$port")
    def method = "GET"
    
    try {
    def hubAction = new physicalgraph.device.HubAction(
        method: method,
        path: path,
        headers: headers
        )
        sendHubCommand(hubAction)
    }
    catch (Exception e) {
        log.debug "Hit Exception $e on $hubAction"
    }
}

The above sendEvent seems wrong to me.

I used your capability faithboard04631.coffeemachine and the command setListElement works fine, when I check the device status, I see the value updated:

"faithboard04631.coffeemachine": {
    "listElement": {
        "value": "capuccinomix",
        "timestamp": "2020-11-09T16:25:10.068+0000"
    }
}

actually it also works for me.
but the button goes into a “working” state and after a few seconds I get the “network error” despite the fact that it actually finished its job.,
so what is this error ? why do I get it ?

ok, I included the faithboard04631.coffeemachineselect capability and both are updated, the “network error” doesn’t appear. This is how I send the events:

def setListElement(argument){
log.trace "${argument}"
	sendEvent(name: "listElement", value: "${argument}")
    sendEvent(name: "lastorder", value: "${argument}")
}

Have you verified your configuration as I mentioned here?

This is a property of the legacy events, you can see that it’s part of the events’ list filters. Due to the changes to the Events History, it can be omitted.

1 Like

I think list just took a step backwards. Anyone notice the list of commands presented now are union of the alternatives from command and state:

For example this presetation:

"detailView": [
        {
            "label": "Test label",
			"displayType": "list",
			"list": {
				"state": {
					"value": "testReport.value",
					"alternatives": [
						{
							"key": "A",
							"value": "Value A"
						}
					]
				},
				"command": {
					"name": "setTest",
					"alternatives": [
						{
							"key": "B",
							"value": "Command B"
						}
					]
				}
			}
        }
    ]
  • Earlier this used to only generate one list command “Command B”.
  • Now it seems to be consolidating the alternatives from command and state and it presents 2 commands in the list, “Value A” and “Command B” (which is incorrect).

Existing presentations aren’t impacted, but if you create a new presentation you’ll run into this issue.

this is going to be a problem. just because it’s a supported state doesn’t mean it should be a supported command in the new app UI.

might as well remove the separation of state and command then.

Yes it is because it’s not possible to make a list controls with alternatives anymore as it’s just confusing for users and calls the commands with the corresponding value for every alternative from state. @nayelyz can be a quick fix for this regression bug?

well, now I tried again and surprizingly it works with no errors. the button does not go into a working state, quickly returns to normal.
what happened ?
how was it solved ? (I did not change anything)

btw, when shall we have the pushbutton displayType working ?