Smartthigs CLI to switch channel

I am trying to call smartthings CLI to switch channel. I believe I followed the example well.

smartthings devices:commands XXXXX 'tvChannel:setTvChannel(1)' 

But this returns this error.

AxiosError: Request failed with status code 422:
{“requestId”:“2260968512939144970”,“error”:{“code”:“ConstraintViolationError”,“message”:“The request is
malformed.”,“details”:[{“code”:“UnprocessableEntityError”,“target”:“commands[0].arguments[0]”,“message”:“commands[0].arguments[0]:
integer found, string expected”,“details”:}]}}
Code: ERR_BAD_REQUEST

I believe I followed the example well described here (GitHub - SmartThingsCommunity/smartthings-cli: Command-line Interface for the SmartThings APIs.).

 # capability and command with an argument (note: single quote command arg to prevent specific shell parsing errors)

    $ smartthings devices:commands 00000000-0000-0000-0000-000000000000 'switchLevel:setLevel(50)'

Please let me know what is the write format to call this CLI with arguent.

In the example you followed, the argument to setLevel is an integer. For the setTvChannel, the argument is a string and must be quoted.

1  setLevel(level<integer>, [rate<integer>]) 

2  setTvChannel(tvChannel<string>)  

bep@debian12:~$ smartthings devices:commands xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx 'tvChannel:setTvChannel("20")'
Command executed successfully
1 Like

Thank you so much. It works!

1 Like