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

If this is the same for the washing machine, then that would be completely acceptable for me. For my particular use case it kind of makes sense to press a button on the device as this also informs Home Assistant that you actually want to do laundry. How else would HASS know that laundry needs to be done.

Of course, making it impossible to override this isn’t right. Especially when it’s changed after you bought the device already. It’s easy to imagine automations (or habits of household members) that make the needing to press a button condition problematic.

Now I just hope that Samsung SmartThings allows the same as Home Connect. Their customer service actually told me it doesn’t. One agent told me the washing machine can be switched on from a phone, but not through an automation. The second agent told me a washing machine can only be started when the phone is connected to the same wifi network, but didn’t have a clue about SmartThings. The third agent said “everything will be fine”…

1 Like

The API has the remote start binary available and the HomeConnect integration in HA has it too.

Door closed = start machine
Door open = don’t start machine

1 Like

I would trigger on the sun production

Prepare the washing machine for a run. Now wait till the power production of the sun panel equals the maximum usage of the washing machine. And again this is never exact science. When the power production is equal to the max usage of the washer trigger the automation.

Activate the power on switch of the washer.
Select the correct program
Start the program

Disclaimer, I dont have an automation running for my washer. Our machine has the iDose functionality but we dont use it because of the usage of a more environment friendly solution.

But you gave me the inspiration to look further into it, thanks!

1 Like

FWIW, the Samsung oven I bought early this year does NOT allow starting via any developer-exposed api, even when the remote button is active. It is possible to start the oven via the ST app (when the remote button is active), but they’ve gone out of their way to not expose the start feature to the apis. I can toggle the oven light on and off via the api, but not the oven or burners of the range. I also get a temperature for the oven (although it is fixed at a minimum of 175 when the oven is totally cool, so also not helpful for ambient room temp :frowning: ). Just a word of warning to really be sure the model you pick (whatever the brand) can be truly be controlled via an api.

I wish Samsung would be a little bit more clear about this. At least Home Connect has a fairly clear explanation on their website on which device types can be started remotely.

In any case, the laundry machine is already here so I’ll report the model and if it works once it’s up and running.

2 Likes

Hi all,

I managed to start the washing machine using the API:

curl --location --request POST 'https://api.smartthings.com/v1/devices/<DEVICE ID>/commands' \
--header 'Authorization: Bearer <AUTH TOKEN>' \
--header 'Content-Type: text/plain' \
--data-raw '[
    {
        "capability":"washerOperatingState",
        "command":"setMachineState",
        "arguments":["run"]
    }
]'

After that, I created a Switch in my configuration.yaml to use this in Home Assistant:

switch:
    - platform: command_line
      switches:
        wasmachine_run:
            command_on: >
                curl --location --request POST 'https://api.smartthings.com/v1/devices/<DEVICE ID>/commands' --header 'authorization: Bearer <AUTH TOKEN>' --header 'Content-Type: text/plain' --data-raw '[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["run"]    }]'
            command_off: >
                curl --location --request POST 'https://api.smartthings.com/v1/devices/<DEVICE ID>/commands' --header 'Authorization: Bearer <AUTH TOKEN>' --header 'Content-Type: text/plain' --data-raw '[    {   "capability":"washerOperatingState",        "command":"setMachineState",        "arguments":["stop"]    }]'

Example of my automation:

alias: Start wasmachine
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.power_production
    above: '2.6'
condition:
  - condition: device
    type: is_on
    device_id: <DEVICE ID>
    entity_id: switch.wasmachine
    domain: switch
  - condition: not
    conditions:
      - condition: state
        entity_id: sensor.wasmachine_washer_machine_state
        state: run
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.wasmachine_run
mode: single
14 Likes

Hi KevinVGW,

This looks awesome!

Where do you put the API part in HA? Is there a documentation/tutorial you can point to in order to integrate this myself?

Thanks!
Moody

1 Like

Hi Moody,

See the 2nd block ‘Switch’. You should put that on your configuration.yaml.
The curl command is the same as in the first block of my post.

Gr

My parents ordered the Samsung washer a while ago and recently I was able to visit them to make sure it’s connected to Home Assistant.

I can confirm that the washing machine can be started from Home Assistant if it has been switched to remote control. As expected this requires pushing an additional button when putting the laundry into the machine, but this is not really an issue.

While Smart Things is supported through an official Home Assistant integration, for the washing machine this only provides sensors. I understand this is a limitation on Samsung’s side, not on the side of Home Assistant. IFTTT also does not support starting a washing programme (not that I was planning on using them).

I managed to get it working though using virtual devices in Smart Things as a workaround.This was before @KevinVGW explained how to use the SmartThings rest API, which is probably the best and cleanest way to do it. I’ll describe my method here though just in case someone needs it.

TL;DR The washer cannot be controlled by the Smart Things Hass integration, but virtual switches can be controlled. Create a few virtual switches in Smart things and then create automations in the Smart Things app that start the washing machine when you flip a virtual switch in Home Assistant.

  1. Use this tutorial by Smarthomeowl to create virtual switches in Groovy IDE (kind of like a developer portal for Smart Things). Things might look slightly different as the IDE has gotten a layout update. If the tutorial is not clear, just search on DDG how to create virtual switched for Smart Things.

  2. Create a few virtual switches. These are the ones that I created. Not all of them might be useful for you. These switches will pop up in Home Assistant as soon as you reload the Smart Things integration or restart.

  • Switches that serve as sensors
    • switch.sensor_washer_ready_simulated_switch
    • switch.sensor_washer_smart_control_on_simulated_switch
  • Switches that serve as triggers for automations in SmartThings
    • switch.action_washer_start_simulated_switch
    • switch.action_washer_cancel_simulated_switch
    • switch.action_washer_pause_simulated_switch
  1. Create the Smart Things routines that control the washer or switch the switches based on the washer status. These are the ones that I made.
  • Sensor states
    • Washer, Device Status: Ready
      • Washer ready sensor on when ready
    • Washer, Device Status: Not ready
      • Washer ready sensor off when washing, finishing, or smart control is off
    • Washer, Smart Control: On
      • Washer smart control sensor on when smart control turns on
    • Washer, Smart Control: Off
      • Washer smart control sensor on when smart control turns on
  • Actions
    • Action washer pause simulated switch, On or off
      • Pause cycle, then wait 10 sec, then switch the simulated switch to off
    • Action washer start simulated switch, On or off
      • Start cycle, then wait 10 sec, then switch the simulated switch to off
    • Action washer cancel simulated switch, On or Off
      • Cancel cycle, then wait 10 sec, then switch the simulated switch to off
  1. Add a script in Home Assistant that allows you to easily control your washer with a service. It acts like a service with a several options for the actions that your washing machine can take.
alias: Washer services
description: Washing machine services
variables:
  washer_start_switch: switch.action_washer_start_simulated_switch
  washer_pause_switch: switch.action_washer_pause_simulated_switch
  washer_cancel_switch: switch.action_washer_cancel_simulated_switch
  washer_entity_id: switch.wasmachine
fields:
  command:
    name: command
    description: What command should be sent to the washing machine?
    example: start_cycle
    default: start_cycle
    required: true
    selector:
      select:
        options:
          - start_cycle
          - pause
          - cancel
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ command == "start_cycle" }}'
        sequence:
          - service: switch.toggle
            data: {}
            target:
              entity_id: '{{ washer_start_switch }}'
      - conditions:
          - condition: template
            value_template: '{{ command == "pause" }}'
        sequence:
          - service: switch.toggle
            data: {}
            target:
              entity_id: '{{ washer_pause_switch }}'
      - conditions:
          - condition: template
            value_template: '{{ command == "cancel" }}'
        sequence:
          - service: switch.toggle
            data: {}
            target:
              entity_id: '{{ washer_cancel_switch }}'
    default: []
  - service: logbook.log
    data:
      name: '{{ washer_entity_id }}'
      message: Sent {{ command }} to the SmartThings Washer
mode: single
icon: mdi:washing-machine

Now you can control your washing machine like this:

  1. Switches are not entirely an accurate representation of how a washing machine is started, a button is better. Create some template buttons that you can use on the dashboard to start your washing machine. These buttons use the script created in the previous step, but you can of course add any actions you want.
template:
  - button:
      - name: "Start wasprogramma"
        icon: mdi:washing-machine
        press: 
          - service: script.washer_services
            data:
              command: start_cycle
      - name: "Pauzeer wasprogramma"
        icon: mdi:pause
        press: 
          - service: script.washer_services
            data:
              command: pause
      - name: "Cancel wasprogramma"
        icon: mdi:washing-machine-off
        press: 
          - service: script.washer_services
            data:
              command: cancel
  1. Create template binary sensors for the virtual switches that we created that only represent states (so they act as sensors in Hass). The state of our template sensors is based on the virtual switches that are switched on and off by a Smart Things routine depending on the state of the washing machine.
template:
  - binary_sensor:
      - name: "Washer ready"
        icon: mdi:timeline-clock
        state: "{{ is_state('switch.sensor_washer_ready_simulated_switch', 'on') }}"
  - binary_sensor:
      - name: "Washer smart control enabled"
        icon: mdi:cellphone-key
        state: "{{ is_state('switch.sensor_washer_smart_control_on_simulated_switch', 'on') }}"
  1. The resulting entities are the following. The 5 entities at the op are the ones I created. The bottom 4 are the default ones. (I don’t think the switch from the default SmartThings entities does anything).

As I said, using the API is probably easier. But perhaps there are situations where the API is not a solution. Or where Home Assistant is used as a secondary smart home system. In that case: virtual switches will be useful.

6 Likes

Seems to be easy, but could you please advise me on how to get the DEVICE_ID? Should I register somewhere and will I need to have a Samsung hub?

Hi, so I finally managed it with this article :SmartThings API Samsung Washer/Wasmachine script integration in Homeseer - RUTG3R.COM

2 Likes

Hi Teun,

3. Create the Smart Things routines that control the washer or switch the switches based on the washer status. These are the ones that I made.

How do you do that ?

Hi KevinVGW,

Where do you put the Example of my automation: in HA ?

Grtz,
FC

This can only be done in the SmartThings app at the moment. This is a screenshot from my routines in the SmartThings app.

Hey,

When calling the SmartThings API what Device ID are you sending exactly and how to figure it out?
And would it be possible to “include” the auth token. Either from the secrets file, or the one set in the integration configuration.

the 2 templates, where do you put them ? When a make that in a script a get an error : Message malformed: extra keys not allowed @ data[‘template’].

@Frank6 Can you post your script?

Apologies for the late reply. You were replying to my comment, but I didn’t use the API. It appears though that de device ID in the curl command is simply the device ID you’d use for any call to the SmartThings API.

So you’re not limited to Home Assistant specific documentation in relation to the API, but any documentation on the SmartThings API will do.

Here I read something about obtaining the device ID: SmartThings My Device | Samsung Developers

1 Like

Hoi Teun,

I try to use your script in HA.

template:

  • button:
    • name: “Start wasprogramma”
      icon: mdi:washing-machine
      press:
      • service: script.washer_services
        data:
        command: start_cycle
    • name: “Pauzeer wasprogramma”
      icon: mdi:pause
      press:
      • service: script.washer_services
        data:
        command: pause
    • name: “Cancel wasprogramma”
      icon: mdi:washing-machine-off
      press:
      • service: script.washer_services
        data:
        command: cancel

This is nice! Is it also possible to start a specific program? Like wool, cotton, express?