Can't get my Edge custom capability switch to work - missing something?

Here’s a link to my gist. I’m writing an Edge driver for an Arduino device I made to allow me to switch my wife’s oxygen concentrator output from one room to another (instead of dragging a 50ft tube around)

I’m trying to put custom labels on a toggle switch that will say “Room 1” or “Room 2” instead of “On” and “Off”. I’ve got all of the display parts to work, but I can’t press the button in the mobile app. In dashboard view the button animation circles around and eventually times out. In detail view the button label changes to the other room temporarily, then I get a message “A network or server error occurred. Try again later.”.

As a side note, if I use the beta web presentation (my.smartthings.com) the dashboard button works, but the detail view does not render an actual button, just an icon that you can’t interact with.

I took the concept from the custom capability Edge driver sample, which is zigbee based. I’ve reviewed a number of threads about custom capabilities and Edge and I’ve tried a number of suggestions, but still no love. I think I’m missing something basic - probably when I took out code related to zigbee I probably should have replaced it with something appropriate with my LAN device, but I can’t quite figure it out.

Could someone take a look at the gist and maybe make a recommendation?

Hi, @edleno.

There’s an open report about this issue, it is caused by the usage of separate commands, so, you need to use a setter like shown in the sample.
Remember to specify in the capability definition that the command roomSet it’s the setter of the attribute. For example:

"attributes": {
    "powerSwitch": {
        "schema": {
            "type": "object",
            "properties": {
                "value": {
                    "type": "string",
                    "enum": [
                        "On",
                        "Off"
                    ]
                }
            },
            "additionalProperties": false,
            "required": [
                "value"
            ]
        },
        "setter": "setPower"
    }
},

As a side note, this line is no longer needed, the issue about failing to recognize custom capabilities is solved.

For future reference, in Edge, if you see that the command is received in the driver’s logs but it is not handled correctly, it is due to your “capability_handlers” configuration.
If the “network error” is received but there are no logs about the event, the issue is in the capability presentation. If you have the correct configuration, then it is caused by something internal and that’s what we report.
But don’t worry, even if you had an error, we are here to help you out. Getting another pair of eyes to look at your configuration is very useful.

Please, let me know if this solves the issue in the dashboard view as well

1 Like

Thanks nayelyz, that works! I updated the gist (here’s the link again) with the corrected answer. If anyone is interested in how I did it before you can review the history of the gist.

This works in both the dashboard and detailed views.

I’m going over old messages on the developer community board and hadn’t seen this solution yet!

1 Like