Custom Capability and CLI Developer Preview

see this: https://github.com/SmartThingsCommunity/smartthings-cli/blob/master/packages/cli/doc/configuration.md

just add the config.yaml file to right folder for your platform.

1 Like

I did earlier …this is extra frustrating.

I’m missing something

contents of yaml

so long as you have these lines it should solve the authentication problem.

default:
   token: β€œyour token”

Hello @Smartphi,

For the config.yaml file, the content should look similar to the sample below, indicating that this is the default profile to use in the SmartThings CLI and with the correct indentation:

default:
          token: xxxx-xxx-xxxx

An alternative is to add the --token parameter in the command. For example:
smartthings devices --token=xxxx-xxx-xxxx


same issue: womp womp

there must be something else not configured correctly (if only there was documentation on how to properly setup and test the cli :thinking:

image

@jody.albritton can you make the token generator also create yaml file so people can just drop it inside the cli folder…

Also some test to make sure your ENV is setup correctly before even trying out the capabilities:create command…

Thanx ===>An alternative is to add the --token parameter in the command. For example:
smartthings devices --token=xxxx-xxx-xxxx

This worked, wow what a headache just to get to this step…

image

couldn’t get it to work with config.yaml file

On to the next headache not documented :video_game:

@jody.albritton

Does the cli generate the capability json file?
Where would I find the file generated in the image below: image

There’s only three files, no where is the json file.

If you want the CLI to generate a local file copy of the capability you need to ask for it.

For example, if you use the -j argument the capability will be displayed in JSON format instead of the summary form in your example.

Alternatively you can use, for example, --output=filename.json to get a file created for you.

cool thnx! generated…


Adding pics for others if it helps along this migration process.

oops don’t forget use the " "

If you do it this way does the output file also have the presentation or do we have to specify that separately in the json before doing presentation:create

I guess what I’m saying is I’m unclear when and how I set the display type and everything. Do I have to write the json for that myself? Can I auto generate it?

I have a custom capability to display a Temperature set point. I added a β€œstepper” to the presentation and I am using the increase/decrease commands as shown below:

"detailView": [
    {
      "label": "Temperature Set Point",
      "displayType": "stepper",
	  "stepper": {
    		"command": { 
				"increase": "increaseSetPoint",
				"decrease": "decreaseSetpoint"
			},
			"value": "attr.value",
			"range": [0, 100],
			"step": 1
		}
    }

I defined the increaseSetPoint/decreaseSetpoint in the capability and in my DTH, which just currently logs that command was called. However, I am not seeing any logs when the stepper buttons are pressed. Instead, it appear the stepper is automatically trying to increase/decrease the attribute value. Unfortunately, this won’t work for me b/c the β€œattr.value” is really just a string, which is populated from an API call and is displayed as friendly text which can vary (e.g. β€œ88.3 Β°F”, β€œHigh of 77 Β°F”, etc.). So I want to just have the stepper call my increaseSetPoint/decreaseSetpoint methods so that I can just call the API to increase/decrease value and then update attribute via SendEvent(…).

Any ideas?

Thanks.

I’ve decided not to waste anymore time messing with this until the caching issue is fixed. It’s so frustrating not knowing if you’ve done something wrong or if it’s just the dumb app not refreshing.

Edit: oh and the fact that device config produces the same vid for devices with a different ordering

4 Likes

Your capability for the temperature set point should define a setter command. Then your presentation just specifies the setter command:

"detailView": [
    {
    	"label": "First Value (A)",
     	"displayType": "stepper",
		"stepper": {
			"command": { "name": "setValueA"},
			"value": "valueA.value",
			"unit": " ",
			"range": [-1000, 1000],
			"step": 1
		}
    }
],

In my case β€˜setValueA’ is my setter command. Each time the value is changed by the stepper, the setter command will be called. It is up to you what you do then. The value it wants to set will be passed into your function and then you can create your string using it. If you need to know whether it is going up or down you would have to add some more logic but I don’t think you need it. Hope this helps.

I haven’t played about with this much lately. I thought I’d seen that pushButton worked, but it seems that is only in the dashboard. I don’t get any widget at all in the details view. Strange as I thought I’d got further than that previously.

The really utterly crippling thing is that you get one chance to get the order of the device config right. Given that the first entries of the dashboard states and actions arrays are used in the dashboard tile, two device configs with either the dashboard states or actions arrays orders swapped clearly represent different presentations. Yet they produce the same vid.

Question: If another user produces a device config with e.g. Motion Sensor as the first capability in the dashboard states array, and then I produce an otherwise identical device config but with the order swapped so e.g. Acceleration Sensor is first, will they result in the same vid and so leave me stuck with someone else’s configuration?

1 Like

ok. so what I understand is :

if I want to display multiple pushbutton and state β€œdisplay types” on new ST app ,

EITHER:
wait for the problem with multiple attributes be solved.
OR:
I have to create custom capabilities for all of them and include all of them in the device config.
is this a correct β€œtemporary” approach ?

And finally, how can I use the command defined to my pushbutton ?

"detailView": [
    {
        "label": "Current State 1",
        "displayType": "pushButton",
			"pushButton": {
							"command": "setActive",
			}
    },

here, I defined a function named β€œsetActive” on the DTH and just put a log.debug command under it to see if it is called.
However, when I use the pushbutton, I don’t see it being called on the log.
what am I missing ?

@morgan.bridges @nayelyz suggestion, it would be nice of the alternatives had a default option or an option where the attribute had no value. Especially that visibleCondition is not working, many attributes have a default state or a no value state (for DTH’s with dynamic controls), this one should be able to display β€œUnsupported” or some default text where there’s no value to attribute. Right now if I try to set a key with "" or null it gives me error.

2 Likes

Hello @mrmrmrmr,

The issue with the pushButton display type has already been reported to our engineering department. In this case, the lack of logs when trying to interact with this element is because no commands are being generated. Our team continues working to have it fixed as soon as possible.

1 Like

As if things weren’t bad enough, the documentation links are now giving me error 404, eg:
https://smartthings.developer.samsung.com/docs/Capabilities/capabilities.html#Creating-a-Capability-Presentation

@orangebucket @RBoy have either of you successfully made a list view custom capability, and if so, can you share your working presentation json

All I’m trying to do is make a list with three options, can’t be that hard but haven’t gotten it to work yet.

Hi,

This drives me nuts. But I have a fan that I want to control. The speed can be HIGH, LOW (or OFF). The DTH in the old code worked fine. I created a custom capability:

Attributes:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name  β”‚ Type   β”‚ Setter   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ speed β”‚ string β”‚ setSpeed β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Commands:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name     β”‚ Arguments     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ setSpeed β”‚ value: string β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ fanHigh  β”‚ value: string β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ fanLow   β”‚ value: string β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

So far so good. I’m trying to create the capability representation, but whenever I call the CLI I get a http 500 no explanation. Can anybody spot the problem in my json please?

{
    "dashboard": {
        "states": [
            {
                "label": "{{speed.value}}"
            }
        ],
        "actions": [
            {
                "displayType": "switch",
                "switch": {
                    "command": {
                        "name": "setSpeed",
                        "on": "HIGH",
                        "off": "LOW"
                    }
                },
                "group": "main"
            }

        ],
        "basicPlus": []
    },
    "detailView": [
        {
            "label": "Speed",
            "displayType": "switch",
            "switch": {
                "command": {
                    "name": "setSpeed",
                    "on": "HIGH",
                    "off": "LOW"
                }
            },
            "state": {
                "label": "speed.value"
            }
        }
    ],
    "automation": {
        "conditions": [
            {
                "label": "Speed",
                "displayType": "textField",
                 "textField": {
                    "value": "speed.value"
                }
            }
        ],
        "actions": [
            {
                "label": "Speed",
                "displayType": "textField",
                 "textField": {
                    "command": "setSpeed"
                }
            }
        ]
    },
    "id": my_id_I_got_from_creating_the_capability",
    "version": 1
}

Thank you for the help!

I’ve finally gotten the hang of these but PLEASE fix the deviceconfig.json layout hashing issue.

(ergo the vid should not be the same if the layout order is changed).