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…