Closed NathanielFeldman closed 2 years ago
The problem is in the parsing of the command line by the shell (not the CLI itself). In particular, the parentheses are an issue. Quoting the entire command should work. For example:
.\smartthings.exe devices:commands <DEVICE_ID> 'samsungce.robotCleanerCleaningMode:setCleaningMode("auto")'
You can also execute commands from a file. If you have this file named cmd.json
:
[
{
"component": "main",
"capability": "samsungce.robotCleanerCleaningMode",
"command": "setCleaningMode",
"arguments": ["auto"]
}
]
You would run the command:
.\smartthings.exe devices:commands <DEVICE_ID> -i cmd.json
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.
If I am missing the proper syntax I apologize, but I feel like I've tried all potential ways of supplying a string argument to the command. I know this is a "custom" capability and not in the documentation so I'm not sure if the parsing issue (if there is one) is with devices:commands or with the capability itself.
For an OCF robot cleaner (Samsung) there is a capability
samsungce.robotCleanerCleaningMode
with commandsetCleaningMode(cleaningMode<enum {stop, auto, manual, spot, area, object, map, pet uncleanedObject, patternMap}>)
. Attempting to pass "auto" (in many permutations) results in this syntax error:.\smartthings.exe devices:commands <DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode(auto)
SyntaxError: Unexpected token a in JSON at position 1
.\smartthings.exe devices:commands <DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode("auto")
SyntaxError: Unexpected token a in JSON at position 1
.\smartthings.exe devices:commands <DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode('auto')
SyntaxError: Unexpected token ' in JSON at position 1
.\smartthings.exe devices:commands<DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode([auto])
SyntaxError: Unexpected token a in JSON at position 2
.\smartthings.exe devices:commands <DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode(["auto"])
SyntaxError: Unexpected token a in JSON at position 2
But supplying "null" or an integer does not result in a syntax error:
.\smartthings.exe devices:commands <DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode(null)
Error: Request failed with status code 422: {"requestId":<REQUEST ID>,"error":{"code":"ConstraintViolationError","message":"The request is malformed.","details":[{"code":"NotNullError","target":"commands[0].arguments[0]","message":"commands[0].arguments[0] cannot be null.","details":[]}]}}
.\smartthings.exe devices:commands <DEVICE ID> samsungce.robotCleanerCleaningMode:setCleaningMode(0)
Error: Request failed with status code 422: {"requestId":<REQUEST ID>,"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":"UnprocessableEntityError","target":"commands[0].arguments[0]","message":"commands[0].arguments[0]: does not have a value in the enumeration [stop, auto, manual, spot, area, object, map, pet, uncleanedObject, patternMap]","details":[]}]}}
Which would seem to indicate a parsing issue with string arguments? Potentially in the
JSON.parse
assignment of the args? Or I am completely misunderstanding on how to supply a value for the enum.