setInputSource syntax for SamsungTV?

Hello all!

I’m been struggling for the last 2 hours with the syntax of the setInputSource for a Samsung TV

This are the options
setInputSource(mode<enum {AM, CD, FM, HDMI, HDMI1, HDMI2, HDMI3, HDMI4, HDMI5, HDMI6, digitalTv, USB, YouTube, aux, bluetooth, digital, melon, wifi}>)

Tried with setInputSource(HDMI1) … setInputSource(“HDMI1”) etc… but nothing, always returning “the request is malformed” or setInputSource not a valid value…

I’ve tried a lot a loooot of combinations but none works, im really missing how the syntax works… and I can’t find nothing on Google…

Any help on this?

Hi, @Niiky. How are you doing?
From where are you sending this command?
I created a virtual device that uses the mediaInputSource capability, and I can send the command through Postman as follows:

[POST] https://api.smartthings.com/v1/devices/deviceID/commands
{
    "commands": [
        {
            "component": "main",
            "capability": "mediaInputSource",
            "command": "setInputSource",
            "arguments": ["AM"]
        }
    ]
}

Hi, @nayelyz thank you for your response.

I was trying to send that command though smartthings cli : GitHub - SmartThingsCommunity/smartthings-cli: Command Line Interface (CLI) for the SmartThings APIs. Provides CRUD operations for platform artifacts as well as ability to control devices.

But still I had to figure out how to send the command through a google home device, I may try Postman, I will be able to send commands from there to the TV? How it connects?

Thank you very much

This is how I send the command:

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

The CLI expects a String value of the command and the ENUM type is also String, that’s why I placed those symbols. I hope it helps :smiley:

1 Like

Wow!!! It works!! Thank you so much!! I

But how did you know how to send it? I was really lost on this, tried a lot of combinations and none worked, using this setInputSource(1) returned error that string was expected then I tried (HDMI) and (“HDMI”) but didnt work either.
Whats the logic on the slashing the quotes?

Thanks again @nayelyz

Anytime, @Niiky! Well, based on this parsing method from the CLI I saw that the values were separated correctly.

So my guess was (because it has happened to me before) that the terminal wasn’t sending the values as expected (Strings) that’s why I wrapped the command with the quotes. As the argument also needs them, you need to escape (\) the character to include it in the String and it won’t be considered as a closure symbol anymore.

1 Like

Thank you again for the explanation!
kind regards

1 Like