Can smart Samsung washing machines be started with the SmartThings integration?

I’m not sure how familiar or not you are with calling API’s so this could be too much detail, but this may hopefully help a few people.

Some context around my take on the automation: you could do it based on the properties of the device. For example when remote control is enabled and the state is set to stop. That probably means it’s ready to go as you would only press the button on the machine when you’ve set up a load of washing.
But when I found that the stop/start state of the appliances are not trustworthy (or at least not when I tested and later accidentally started the washing machine and dryer), I still like the idea of having a separate switch. Hence my wait for the home assistant yellow as I don’t have any support for zigbee in my home yet.
Instead of relying on the device, a cheap sonoff zigbee switch will set a helper (a toggle “washerAutoStart” to “On”) to indicate I want my appliance to start going when certain conditions have been met (e.g. producing enough solar). This means that when either it’s set to go and power production it should start, or when you already have met the power threshold it should also trigger when the button is pressed as it could then immediately start.

1. Generate bearer token
https://account.smartthings.com/tokens
See more detailed instructions here on the personal access token: SmartThings - Home Assistant

2. Get the device IDs
Required for each device (washer/dryer)

URL / endpoint: https://api.smartthings.com/v1/devices/
This call lists all your devices. Get the device_id value of the appliance

Or step by step:
a. Have something to test your API calls like postman: Download Postman | Get Started for Free
b. Create a new entry (a “GET” request)
c. URL: https://api.smartthings.com/v1/devices/
d. In the Authorization tab, choose Bearer as the Type and enter the token
e. Send the API call - you should see a 200 OK response
f. Review the API response at the bottom. Find the entry of your appliance and take note of the deviceId value

3. Configuration.yaml
Add the following commands to configuration.yaml so we can call them using a HA service:

shell_command:
  # Washing machine
  washer_start: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/DEVICEID/commands'' --header ''Authorization: Bearer TOKEN'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["run"]    }]'''
  washer_pause: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/DEVICEID/commands'' --header ''Authorization: Bearer TOKEN'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["pause"]    }]'''
  washer_stop: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/DEVICEID/commands'' --header ''Authorization: Bearer TOKEN'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["stop"]    }]'''

We only need the one to start, but you could pause or stop a cycle using a button on the dashboard for example
Just replace TOKEN with the token from step one and replace DEVICEID with the device id from step two.

4. Automations

Automation 1:

Zigbee switch:
Triggers

  • Switch is pressed

Actions

  • Set the “washerAutoStart” boolean to TRUE

Automation 2:

Triggers

  • When inverter (state number value) is above (whatever value is appropriate)
    Or you could even do something more complex if you subtract power usage from production but I’m probably happy if it produces 2kw, 3kw or something like that
  • When input_boolean.washerAutoStart is changed state to On

Conditions

  • When inverter is above (whatever value is appropriate)
    AND
  • When input_boolean.washerAutoStart is changed state to On

Basically the same as triggers, as either trigger could have started the automation but both conditions have to be met before we want to turn the appliance on

Actions

  • Call the service shell command washer_start
  • Set the value of input_boolean.washerAutoStart to Off
  • Add a notification action if needed…
3 Likes

I didn’t have a note of my token so I generated a new one but as it is a different token to the one I used to initially setup the smarthings integration and devices, will this cause a problem?

I cannot seem to get to the next stage when I try and create an automation, I cannot find anyhtign called ‘washer_start’ etc

Here is the code I have put at the end of my configuration yaml

# Washing machine
washer_start: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-1*******/commands'' --header ''Authorization: Bearer *******-0445-4d37-afad-******'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["run"]    }]'''
washer_pause: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-*******/commands'' --header ''Authorization: Bearer ******-0445-4d37-afad-*****'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["pause"]    }]'''
washer_stop: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-*******/commands'' --header ''Authorization: Bearer ******-0445-4d37-afad-******'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["stop"]    }]'''

Obviously the ***** are where I have hidden my details

I have formatted my code the same way you uploaded yours to this forum but I’m now thinking that it uploaded wrong and you don’t have just 3 really long lines of code, they should be broken up into different lines. Am I right?

You can have multiple tokens. If the API call worked in postman, it meant you’ve successfully used the new token to authorise yourself. You can always delete the old token from the Samsung site if you’re no longer using it.

The zigbee button is just my preference, you can definitely do it entirely without and change the automation trigger and conditions to when the washing machine state is “stop” AND when remote control is enabled to turn it on.

Did you put those 3 lines under the section ?

shell_command:

Once that works, you can validate that the 3 services are created and that you can start the washing machine by calling the service under the developer tools → services
image

Did I put those 3 lines under what section?

I put them in the config yaml at the bottom like this but I am getting the error below

# Washing machine
washer_start: 'curl --location --request POST "https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-909090/commands" 
--header "Authorization: Bearer 8e3df9de-0445-4d37-afad-90909" 
--header "Content-Type: text/plain"
--data-raw "[
      {
          "capability":"washerOperatingState",
          "command":"setMachineState",
          "arguments":["run"]

washer_pause: 'curl --location --request POST "https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-9/comm90090ands"
--header "Authorization: Bearer 8e3df9de-0445-4d37-afad-0"90909
--header "Content-Type: text/plain" 
--data-raw "[
      {
          "capability":"washerOperatingState",
          "command":"setMachineState",
          "arguments":["pause"]

washer_stop: 'curl --location --request POST "https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-9/com9000mands" 
--header "Authorization: Bearer 8e3df9de-0445-4d37-afad-09090" 
--header "Content-Type: text/plain" 
--data-raw "[
      {
          "capability":"washerOperatingState",
          "command":"setMachineState",
          "arguments":["stop"]
    }
]'

File ‘configuration.yaml’ could not be parsed, it was referenced from path ‘configuration.yaml’.This file will be ignored. Error(s): - YAMLSyntaxError: All collection items must start at the same column - YAMLSemanticError: Multi-line single-quoted string needs to be sufficiently indented - YAMLSemanticError: Multi-line single-quoted string needs to be sufficiently indented - - And 9 more errors…

Thought I got rid of the error but it is back

File ‘configuration.yaml’ could not be parsed, it was referenced from path ‘configuration.yaml’.This file will be ignored. Error(s): - YAMLSemanticError: Multi-line single-quoted string needs to be sufficiently indented - YAMLSemanticError: Multi-line single-quoted string needs to be sufficiently indented - YAMLSemanticError: Multi-line single-quoted string needs to be sufficiently indented

this is now my code

shell_command:
# Washing machine
washer_start: 'curl --location --request POST "https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-999/commands"
--header "Authorization: Bearer 8e3df9de-0445-4d37-afad-999"
--header "Content-Type: text/plain"
--data-raw "[
      {
          "capability":"washerOperatingState",
          "command":"setMachineState",
          "arguments":["run"]
              }
]'
washer_pause: 'curl --location --request POST "https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-999/commands"
--header "Authorization: Bearer 8e3df9de-0445-4d37-afad-999"
--header "Content-Type: text/plain"
--data-raw "[
      {
          "capability":"washerOperatingState",
          "command":"setMachineState",
          "arguments":["pause"]
              }
]'
washer_stop: 'curl --location --request POST "https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-999/commands"
--header "Authorization: Bearer 8e3df9de-0445-4d37-afad-999"
--header "Content-Type: text/plain"
--data-raw "[
      {
          "capability":"washerOperatingState",
          "command":"setMachineState",
          "arguments":["stop"]
    }
]'

You cannot add line breaks in like that. It’s yaml and it requires the right indentation too. Using your values this should validate just fine:

shell_command:
# Washing machine
  washer_start: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-1*******/commands'' --header ''Authorization: Bearer *******-0445-4d37-afad-******'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["run"]    }]'''
  washer_pause: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-*******/commands'' --header ''Authorization: Bearer ******-0445-4d37-afad-*****'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["pause"]    }]'''
  washer_stop: 'curl --location --request POST ''https://api.smartthings.com/v1/devices/dfe8dba1-fe99-9897-c896-*******/commands'' --header ''Authorization: Bearer ******-0445-4d37-afad-******'' --header ''Content-Type: text/plain'' --data-raw ''[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["stop"]    }]'''

Thank you.

I have put that in to my configuration.yaml and there was an error at first. I then came out of the file editor and then back in and the error no longer shows. They still do not show up in the service section or an automation.

Home assistant reboot is all that was required.

You sir are awesome, thank you so much.

I love this community.

Can I ask though, how do you select a specific wash programme?

And with regards to the automation, I don’t get an option to select ‘call service’ in triggers or conditions so cannot input the boolean part

Glad you got it to work. And yes, configuration.yaml changes usually require a restart.
When you create a new automation, choose “Call Service” under the actions dropdown. After that you should be able to find those new services you’ve created.

image

I think for the washing cycle someone mentioned it either in this thread or another.

The Samsung API documentation can be a bit limited, but do a GET request in postman to:
https://api.smartthings.com/v1/devices/DEVICEID/components/main/capabilities/samsungce.washerCycle/status

That should return the codes for all supported cycles for your machine.
image

It’s probably a bit of testing standing next to the machine to see that it picks up the cycle change once you do a POST request to:

https://api.smartthings.com/v1/devices/DEVICEID/commands

The body of this post should contain:

[{
    "capability":"samsungce.washerCycle",
    "command":"setWasherCycle",
    "arguments":["Course_1D"]
}]

To change the cycle use the “Course_” prefix and then the code from the GET request (e.g. 1D, 1E, etc.)

Once you’ve got the request to work, you can create yet another line under the shell command section in your configuration.yaml and then use the new service in an automation or a button on the front end.

While it’s nice to see this work, I’m not sure how useful it is in practice since you already need to put the load into the machine and press the button to enable remote control. You may as well select the program then when you’re at the machine. I haven’t quite found a way to automatically put the dirty laundry in the machine form the washing basket, if only we could :slight_smile:

Valid point regarding the programme.

Think I will leave that for now.

Now I need to wait for the Growatt servers to start working in HA again so I can set the automation for when the solar is generating over 2kwh.

Thank you for your help, it is most appreciated.

Hi There,

It seems a lot of people are helping here, which is fine.
Am I correct that with this approach, I can keep everything in the LAN.
I would rather not open ports for IOT
Most of my IOT devices are on a seperate lan section lets say 192.168.44.0/24
Things inside this can’t go to the internet, but HA is installed on another lan section and can communicate with the devices in the IOT lan section.
This seem to work for my cameras and other devices.

But upon reading over the washer from samsung (so many posts) I’m not sure.
Thanks for reading and I hope somebody can clarify this…

From what I understand that is being discussed here, in the first x posts the subject is using the SmartThings integration. Then later, the subject changes to using custom switches and performing REST API calls to api.smartthings.com. That still uses the cloud service of Samsung.

I share your desire for local control and while not discussed here (yet? or it deserves a topic of its own), I assume that the cloud service sends some kind of command to the washer itself. Possibly, you could use a tool like WireShark to snoop on your network traffic and figure out what the actual commands sent to your washer are.
Keep in mind that the above contains a big IF, as I haven’t tried any of this for my Samsung devices.
Perhaps someone has some experience with this they could share?

P.S. I’m new here, looking to automate all the things in my home based on (solar) energy availability and price, as well as prioritization of appliances needing to run etc.

1 Like

I love this guide, thanks so much. I was able to easily implement it.

One question though: have you managed to actually resume a paused cycle? I can’t get this to work, since the start_cycle does not seem to work on a paused cycle.

The washing machine has a remote lock button which basically locks the door and opens remote support thought app or api.

Do the samsung dishwashers work similarly? It’s not clear from the manual.

The command":“setMachineState”, with argument run, resumes a paused cycle. On my samsung washing machine from 2022.

How can you give multiple payload comments like:

rest_command:
   kleur:
    url: "https://api.smartthings.com/v1/devices/<DeviceID>/commands"
    method: post
    content_type: 'application/json; charset=utf-8'
    headers: 
      Authorization: Bearer <Token>
    payload:
      '[{
          "capability":"samsungce.washerBubbleSoak", "command":"on",
          "capability":"samsungce.autoDispenseDetergent", "command":"standard",
          "capability":"samsungce.washerCycle", "command":"setWasherCycle", "arguments":["Course_1B"]
      }]'

Great stuff all! Already have a Smartthings capable washing machine for some years, and thanks to this thread discovered its smart capabilities :slight_smile:

I think we should integrate this functionality into the Smartthings integration of HA. I created an issue for it, see Samsung Washing Machine - No option for remote start · Issue #109357 · home-assistant/core · GitHub

I hope somebody can pick this up, as I lack python coding skills for that :frowning:

1 Like

I know this is 50% offtopic, but still heavily related: when I don’t want (or cannot) setup an external webhook, and therefore the “proper” smartthings integration not being an option, can I still trigger commands and pull information about a device via the smartthings API directly? Or is on the samsung side the API connected to the existence/setup of a webhook on my side?

I’d be totally fine with setting up tons of API calls via CURL or REST sensors, but it has to work without a webhook on my side.

Thanks in advance!

You should not need a webhook if you set up the API commands like I’ve done here :

Fully local control would be ideal, but I’m not sure if that would be even possible. But if you’re happy to fire the API calls that should work

1 Like