SmartThings cli syntax

how is the correct way to read the current consumption parameter ?

You can use one of

smartthings devices:status [ID]
smartthings devices:component-status [ID] [COMPONENT]
smartthings devices:capability-status [ID] [COMPONENT] [CAPABILITY]

The first one shows all the device attributes, the second narrows it down to a component, and the last to a single capability.

yeah thanks i saw there has many lines with many info some of them are usefull like current power consumption and power consumption counter tnx for supporting me
do you know some way for running smartthing cli on armbian ?

Sorry for hijacking thread. How do you get information out of the CLI that would normally be done with a callback in groovy?

You can try to make HTTP requests to the SmartThings API. However, remember that Groovy is part of our legacy platform.
Can you share more details about your use case?

I completely understand Groovy is legacy, which is the driver for my prototype. I’ve been using the CLI to test commands, which mostly involve managing lock codes. I don’t see any method in the CLI to perform callback type activities which are used for a number of device commands on the legacy platform. Do we know how long CLI will be supported? Trying to keep this simple for now. :slight_smile:

If you’re referring to this CLI, there are no plans to remove it and it’s being constantly improved by the engineering team. So, you don’t have to worry about that.

That’s awesome news! Back to the original query…
smarthings devices:commands healthCheck:ping -t
Where does output go? Is there a method to receive the output?

ping() is a command from the healthCheck capability. So, if the device uses it and has a function configured to handle this command, then, it will execute the tasks defined there but it doesn’t show an output in the CLI.
Also, the healthCheck capability is no longer used in Edge-based devices, only in DTH but some have this handler, like this one.

If you want to see the device’s health, you should use the command smartthings devices:health.
Or, if you want to see if the device “keeps working” you can use the refresh capability which is more common among devices. This function mostly contains commands to read the device’s attributes and update their value.

LOL, I was going to use refresh as an example, but I still don’t see how to use the CLI and get a response. Do you have an example for refresh?

I am struggling to understand what response you are expecting. A response saying what?

There is a response from the API which will either be an HTTP 200 with a JSON body saying whether the command was accepted, completed or failed, or some other HTTP code with a JSON body giving an error message. If that body is what you are after then it doesn’t look like you get to see it when sending device commands using the CLI. That is quite unusual for the CLI as usually you can opt to see something close to the raw JSON response or a YAML translation of it instead of the ‘pretty’ version of it (I say ‘close to’ because sometimes extra bits can get added to the output). If that isn’t what you had in mind then I don’t know what you are after.

@orangebucket I’ve not found any examples on how to get the JSON response. Do you have any? Thanks!

Where it does work (e.g. smartthings devices) you just add -j or --json to the command line, specify an output file, or redirect standard output. Why it can’t do that for device:commands I don’t know.

It seems the CLI doesn’t return a JSON like when we make a direct query to the ST API, it only shows “Command executed successfully” as the output. For example:

$ smartthings devices:commands deviceID main:switch:off
Command executed successfully

Another useful syntax:

smartthings devices:commands deviceID "main:mediaInputSource:setInputSource(\"HDMI\")"

For commands using

That confirms what I’m seeing as well. Thanks.

1 Like