Samsung AirComditioner (2019) - Samsung Smart Things

Thanks.

I apologise in advance for any less than smart questions… I’m a simple network/infra guy, not a coder. :blush:

Are you using the binding that Jan Grønlien posted connecting directly to the inverter, or did you write your own code connecting to the SmartThings cloud api?

As my first use case is to simply assert control over the inverter through OpenHAB so I can start automating things. Details are definitely of use.
I’ll see if I can replicate parts of your implementation during my vacation later this summer.

I would be more than interested as i got also a windfree version and face issues using Jan’s binding. Maybe you guys could all bring it together into one solution?
Looking forward to your details!

Hello,

no, I´m not using the binding from Jan as my windfree models are too new to use it with. I am only using the Rest API from Smart Things.

Just FYI, came across this SmartThings API tool in case helpful.

Okay - here we go. As the solution needs several different steps (and also my time is quite limited) I´m splitting it up.

  • First step: Make sure to have all your AC devices registered in your Samsung Smartthings APP - logged in with your Samsung account.

  • Second step: Generate a personal access token here and save it somewhere: https://account.smartthings.com/tokens

  • Download software “Postman” (it´s for free) here: https://www.postman.com/downloads/

  • Start Postman to get your Device ID´s - this is how you do it:

GET
URL: https://api.smartthings.com/v1/devices
Tab Authorization - Type - Bearer Token - add your personal Token

It should look like this:

  • Click SEND

As a result you should get in the “body section” all your devices listed.

Copy all the Device ID´s and save it.

Now you are able to control the device directly from Postman (or command line in Windows using command “curl”). Please see the API documentation here: https://smartthings.developer.samsung.com/docs/api-ref/capabilities.html
and here: SmartThings API

So for an example this is how to switch your AC on with Rest API:

Method: POST
URL: https://api.smartthings.com/v1/devices/yourDeviceID/commands

Don´t forget to add your Authorization bearer

Add the capability under “Body” Tab:
[{“component”:“main”,“capability”:“switch”,“command”:“on”}]

Click SEND to submit your request.

So that´s the first step to get the integration into OH. If this step is working you should be safe to continue.

More is coming soon!

2 Likes

Thank you for much for taking the time to explain everything :pray::pray::pray:
I will try it during the weekend :muscle:

Sorry if this is a foolish question, but how do I run the GET->URL->Tap Authorization… process in Postman?
I downloaded Postman and searched for GET in the search bar, I got a few “get” options, but I’m not sure how to proceed. I tried to fork one of the GET projects, but the app showed me an error message.

You should see “My Workspace” somewhere on the left side. Try to create there a new Collection and then open a new Tab with the “+” Button to enter your Request details.

I was struggeling also when I opend Postman the first time but I can´t reproduce it anymore because my Postman installation is already configured and ready to use.

Please also check out this video: https://www.youtube.com/watch?v=VywxIQ2ZXw4

1 Like

Thank you,
I was able to run the GET command, as you explained, and get my devices ID’s.
However, when I tried to follow your next step and run POST, I got the following error message.

Did I do something wrong?

Please check the quotes ” - while using copy / paste the format often gets corrupted.

Im only on my mobile phone and that’s the only thing I can see at the moment.

1 Like

Amazing! You were right :pray: :pray:
Once I deleted and re-entered all the quote " symbols in the body text, the command worked properly.
Moving forward to the next step :slight_smile: :slight_smile:

Alright - here´s part two!

Now we need to collect all our commands we want to use in our OH integration.
I am using the following API´s:

  • Power ON / OFF
  • Set Cool Mode
  • Set Temperature
  • Set Operating Mode
  • Status Updates

Of course we want to send commands directly from OH to our AC units. But what if someone is using the AC remote and is changing something or turning it completely on or off?
Therefore we need to check the status regulary and get these informations asweel into OH.

Afterwards we will create python scripts and store them directly on the Openhab server. The python scripts will then be executed using the Exec binding.

So this is how I do it:

ON/OFF:
URL: https://api.smartthings.com/v1/devices/yourDeviceID/commands
Command: [{“component”:“main”,“capability”:“switch”,“command”:“on”}]

COOL MODE: (Cooling, heating, drying, auto,…)
URL: https://api.smartthings.com/v1/devices/yourDeviceID/commands
Command: [{“component”:“main”,“capability”:“airConditionerMode”,“command”:“setAirConditionerMode”,“arguments”: [“cool”]}]"

TEMPERATURE:
URL: same as above
Command: [{“component”:“main”,“capability”:“thermostatCoolingSetpoint”,“command”:“setCoolingSetpoint”,“arguments”: [“23.0”]}]"

OPERATING MODE: (Windfree, Fast, Normal, WindFreeSleep, …)
URL: same as above
Command:
[{“component”:“main”,“capability”:“custom.airConditionerOptionalMode”,“command”:“setAcOptionalMode”, “arguments”:[ ““windFree””]}]

Now the status updates. They only return information to you - e.g. if the device is on or which temperature is set at the AC unit.

STATUS UPDATES:

ON/OFF:
URL: https://api.smartthings.com/v1/devices/yourDeviceID/components/main/capabilities/switch/status
Command: none

TEMPERATURE:
URL: https://api.smartthings.com/v1/devices/yourDeviceID/components/main/capabilities/thermostatCoolingSetpoint/status
Command: none

OPERATING MODE:
URL: https://api.smartthings.com/v1/devices/yourDeviceID/components/main/capabilities/custom.airConditionerOptionalMode/status
Command: none

So if you have all your commands and status updates collected you can begin with the next step.

In my case I converted the Rest API commands with Postman to Python language. You can also use http Binding to achieve this but I decided to go with python.

To do so open the Code snippet (located top right corner) and choose your output format.

Copy this and create the python scripts directly on your OH installation.
I created a folder and adjusted the authorizations so that the user which is running Openhab is able to launch the python scripts:

2 Likes

Thanks a lot @Mario084 ! Took me 5min to get Part 1 working, finally able to control my windfree AC.
Now to Part 2, will most likely try to use the http binding as I am using it already for some other stuff, but I guess it should be as easy as sending the different commands/pulling via rules the status updates (?).

Might be interesting to work on a binding for this process as it could be expanded potentially to other SmartThing devices?

Many thanks, Mario! You are really helping us all achieve something we’ve been struggling with for months :pray:

I was able to run in Postman a few of the commands that you included :slight_smile:
These commands worked for me with your examples: “on”, “off”, “auto”, “cool”, “heat”, “dry”, “windFree”.
Unfortunately, these commands didn’t work with my AC: “fast”, “normal”.

Do you have a clue as to where we can find commands that you didn’t mention? (see attached photo of wireless remote)

  1. for example, my windfree AC remote has these optional commands : 2-Step, Fast, Comfort, Single user, Quiet, d’light Cool, Beep, Display…
  2. are there commands that allows to set the AC fan speed (auto, 1, 2, 3, 4)?
  3. is there a command to enable the Purify function (indicated on the remote with a Tree symbol)?
  4. I tried to run the Fast command that you included, but I got an error message. I think my AC might have this function in a different capability/command group.

For your question, have a look into the first postman Code which includes your ID, it also shows below that in the code all channels available.
Then cross reference them with Mario’s link to the API in his first post and you can identify the commands to send to each channel.

1 Like

Thanks Chris, This helps :slight_smile:
I will check what you suggested :pray:

You´re welcome!

Yes - for sure you can use http binding and then get all the status updates within rules.

A binding would be great and to answer your questions: yes - the logic is the same for all other smart things devices too!

Here an example:

Postman output:
image

API page:

Attributes of the API:

Thanks :pray:
Should the command be something like this?

(this one didn’t work): [{“component”:“main”,“capability”:“audioVolume”,“command”:“setVolume(volume)”,“arguments”:[“0”]}]

Looks about right if I understand the API and Mario’s examples well enough.

1 Like