Recently I’ve bought a new Samsung Washer (wasmachine), with wifi connectivity. As a home automation nerd I try to have every new equipment in a certain way connected to my Homeseer system. I’ve seen the SmartThings plugin in Homeseer but I read in the comments that the newer models from Samsung were not compatible. I’m not a fan of connect my devices to the cloud but sometime there is no other way to reach your goal, so it is in this way as well. Because I tried already long time ago to make a script with an authentication option in it (and I’ve failed many times), I installed Home Assistant (or hassio) on a Raspberry Pi. Home Assistant has a standard integration for SmartThings, so in this way I was able to see a few things, like this:

homeassistant

Very interesting here is the “Completion time” and the “Washer Mode” aka the program is running. But instead of “Cotton” you’ll see the value “Table_00_Courese_5B”…. well, a little dissapointment actually, so I tried to get my script skills and spend some evenings to get the autorisation script again, afterall the script was able to make a connection to SmartThings.

Even I set up the saving of these devices to a MQTT broker so I was able to see the washer integration from Home Assistant in HomeSeer…The should be done better, right?

 

Needs:

  • Samsung/SmartThings user account
  • SmartThings token
  • Added washer device in SmartThings Android/iOS app

No needs:

  • Samsung hub

 

SmartThings

Make sure you have your Samsung washer connected via wifi to the SmartThings platform. It’s up to you to assign the washer to a certain room. With the Android/iOS app you can do the setup to the washer easily and in the end you see very nice things, in real time, like the current running program (i.e.”cotton”), the set temperature, the current mode that is running (weight sensing, rinse, spin, etc), the remaining time and so much more.

If the authentication script can connect to SmartThings, then it should be possible to grab the data from the platforms and store it in Homeseer, so here wel go.

 

Be sure you’ve connected your washer to the SmartThings app.

Create an account first on https://account.smartthings.com/login, you can login with a Smasung account, or you can create a SmartThings account. I had already an Samsung account, so I’ll continue with it. It’s fore sure not necessary to have also a SmartThings account next to your Samsung account. AFter the account is created, make sure you’re logged in.

Go to https://account.smartthings.com/tokens here you will see your current tokens (could be empty), and you can create a new tokenin the top right corner. Click on “GENERATE NEW TOKEN”.

Give the token a name, like “HomeSeer” and authorize the token for all scopes. On the bottom of the page, click  “GENERATE TOKEN”. Your Personal access token is created now. The personal token is valid for 50 years, so don’t worry about an expiry date. In the blue pane a warning is visible to copy the token code to a save location, because it’s true that you can’t see this full code anymore, after the page is closed.

ST-token-confirmation

Postman

With the generated token, it’s time to make a connection to the SmartThings API.

To activate the token and find the device-id of the washer, we have to download an app called “Postman” on your computer. This app is wildly used by developers to do GET and POST request to API’s.

  • Go to https://www.postman.com/pricing and click the download button in the FREE plan.
  • Install the download on your computer. In case an account is necessary for download or installation, you’ll find your way to do this.
  • Start the Postman program on your computer.

In the left op corner click on the orange “NEW” button and choose for “Request”.

Enter a name like “SmartThings” and click in the bottom of the top for the “1” folder in the collection section. Press “Save to 1”.

postman-get_devices

Make sure the “GET” command is selected. Copy paste the following command into the “Enter request URL” field (without quotes): “https://api.smartthings.com/v1/devices“.

To add the generated token, you have to select the “Authorization” tab below the url:

postman-authorisation-tab

At the TYPE dropdown, select “Bearer Token”.

What is a Bearer token? Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the Authorization header when making requests to protected resources.

On the right side of the TYPE dropdown manu, you can enter the earlier generated token, without quotes.

postman-bearer-token

It’s now time to make the first API requst to SmartThings, so press the blue SEND button the the right side of the screen.

If authentication is done successfully withthe Bearer token and the API request is done successfully, a JSON result will be shown below. an example is visible here:

postman-result-json

Depending on how many devices are present in your SmartThings environment, it could be a very long list. In this case we are only interested in the Samsung washer, so scroll down untill you see that device.

postman-json-washer-id

Regarding the result for the Samsung washer, we are interested only in the “deviceId”, which start in this case with “59846602-………”. Copy your complete deviceId to another location, like Notepad because we need it for later use.

If you’re interesed in a more structured overview to read this JSON output, copy all the code in this pane and open the website http://jsonviewer.stack.hu. Paste all the code into the “Text” tab. Switch then to the “Viewer” tab. Click on the plus sign to expand the several menus or right click on JSON and coose for “Expand all”.

 

HomeSeer

So we have now a token for SmartThings and we have the deviceId of the Samsung washer. These 2 variables will be used in the vb.NET script that can be downloaded at the bottom of this blog post.

The HomeSeer script will make the same way cinnection as we have used inthe Postman program, also with the same Bearer token. The Bearer token is now activated and authorised, so any script can now grab data from SmartThings.

Open the SmartThings_Washer.vb script

  • On script line 13, Debug mode is default set to set to True (debug mode = ON).
  • On script line 13, device creating in HomeSeer is set to true as well.
  • On script line 21 the SmartThings access token has to be filled in, between the double quotes.
  • On script line 22 the deviceId has to be entered, between the double quotes.

Save the script in the HomeSeer script directory.

Create an event, recurring, depending on your needs, with action to run the script.

With the first script run, the virtual devices will be created, like this:

Homeseer3-virtualdevices2

To do improvements:

  • Create virtual devices for all devices from the SmartThings devices result
  • Create more dynamically virtual devices from the JSON output from each device. In version 1.0 of the script some minor values are grabbed statically from the JSON output. This could cause issues with different washers
  • Use prefix naming convention based on device name from JSON result
  • Parent-Child devices relationship for additional created devices.

 

Release Notes:

April 27, 2020v1.0

Tested on HomeSeer 3, version 3.0.0.548 on Windows 8.1 and 10.

Tested with Samsung Washer: WW90K6605QW/EN

  • SmartThings API connection
  • Static deviceID for Samsung washer only
  • Virtual devices creation in HomeSeer 3
  • Parent-Child relationship working (also with new created virtual devices in case payload is different))

 

Downloads:

Privacy Preference Center