HomeHome AutomationDIY Smart Washing Machine - for about 15 bucks!

DIY Smart Washing Machine – for about 15 bucks!

What can you do with cheap washing machine and Sonoff POWR2

I bought a dumb washing machine for about $150. It’s not the most advanced machine I had seen, but the physical dimentions were the biggest consideration. The machine isn’t “smart” or “connected” but for the most part, I’m OK with it. The biggest problem is me! Putting “whites” with reds to take out beautiful pinks, is one of the things I do. That’s not fixable.

What’s my other sin? I tend to leave my washing inside the machine for days! It’s equally daft behaviour, but fixable with NodeRED. I will show you how to turn your not so smart washing machine into DIY Smart Washing Machine for about $15! Without voiding the warranty!

Now, whenever the washing is ready, I get an Android|Windows|Alexa|Google Home notification to go and take the laundry out.

The flow had been updated on 17/01/2021 – you may see differences between the one downloaded and imported to NodeRED and the one presented in the video.

DIY Smart Washing Machine

There is more than one way to skin this cat. I think mine is the most sensible and probably one of the cheapest options to pick. If you try hard, you won’t even have to touch the washing machine, to begin with, and spare its warranty.

Notifications available for:

  • Google Home (with “nagging”)
  • Alexa (tutorial)
  • Android Phone
  • Windows 10

I don’t want to set anything, just put the washing in, start the washing machine and get notified on my prefered devices once the washing is done. To save my marriage from the impending doom, and make some extra bucks from affiliate sales (which also saves my marriage from the impending doom) I found the solution to the problem. The answer is Sonoff POW R2.

Wait, how are you going to issue washing machine notifications with Sonoff? – Let me tell you all about it!

Sonoff POW R2 and DIY Smart Washing Machine

None of the required functions is really available in the off the shelf version of the device so I’m going to flash Tasmota firmware on it. This way, I can do whatever I want with the data coming from the Sonoff POW R2.

The unique ability of the Sonoff POW R2 is to share information about the power used by the device connected via Sonoff. I’m able to tell when the washing machine is operational, and when is no longer washing. All I have to do at this point is to dress it up with some logic to create the washing machine notifications. No modifications needed to the washing machine!

Buy Sonoff POWR2

Buy it using these links to support NotEnoughTech.

Just make sure to check the power ratings for your washing machine. This Sonoff POW R2 can handle 15A with 3500W of power – I’m on the safe side as my washing machine is rated for 2000W.

If you are clever enough, you can splice the cable from a short extension instead of cutting the power cord. This way your “dumb” washing machine remains intact and gets all the smart features.

Using NodeRED for washing machine notifications

You know by now, I love NodeRED. You can argue how cool is Home Assistant all day, but you won’t come close to what you can achieve with NodeRED. I have a series for beginners if you are ready to make the jump. I’m actually going to reuse an idea I had for my 3D Printer notifications. I calculated the power consumption before, there is no point in reinventing the wheel. Time to modify it.

DIY Smart Washing Machine – flow

How does it work? The washing machine, or Sonoff POWR2 to be precise, reports back to NodeRED with power measurements. These will vary depending on the current state of the operating machine. In principle the average load of the machine in the last couple of minutes is:

  • average === 0 (washing machine is off)
  • average <= 5 && average > 0 (washing machine in standby)
  • average > 5 (washing cycle)

In addition to that, the script can distinct separate operation states of the machine: off|standby|washing|finished – to make sure things happen in order and to deal with scheduled washing.

Settings

//Electrical tariff info   

var tariff = {"CostDay": 0.183,
              "CostNight": 0.183,
              "Start": 7,
              "End": 19};
flow.set("Tariff", tariff);
flow.set("CostArray", [0]);

//Google Home Nagging
var nagging = {
    "status" : false,
    "frequency" : 5};
flow.set("Nagging", nagging); 


// washing Machine settings
flow.set("StandbyPower", 1);   //average power in standby mode
flow.set("hostname", "washingmachine.lan");   //in case you use HTTP
flow.set("TotalPower", []);   
flow.set("Resolution", 5);         // number of measurements taken for rolling power average
flow.set("MetricFrequency", 60);  // how often washing machine reports back
flow.set("Operation", "off");     //current operation state   off/standby/washing/finished

var cycle = {"standbyTimeStart": null,
        "standbyTimeStop": null,
        "washTimeStart": null,
        "washTimeStop": null,
        "washFinishStart": null,
        "washFinishStop": null,
        "totalCost": 0,
}
flow.set("CurrentWashCycle",cycle);
flow.set("WashingHistory", []);  

I’m trying to make this as user friendly as possible so you don’t have to change much code yourself, therefore, a lot of things are coded in for you. This means we have to configure the flow to work with your washing machine. There are a couple of things that you have to provide:

  • Cost of electricity (if you want to have cost calculations)
  • Resolution (Frequency of MQTT updates)
  • Standby Power (the power draw of your washing machine measured when in standby – powered on, but not in use)
  • Nagging (on/off repeat Google Home notifications every 5min until the washing machine is turned off, nagging has to be enabled each time)

The main difference in the updated script is the change of the HTTP protocol to MQTT. As your Sonoff POWR2 needs to be flashed with Tasmota, you will be able to set up MQTT – I suggest to set the reporting to 60 seconds or less in Configure Login: Telemetry Period. Remember this value, as you will need later.

Another value that you have to pay attention to is standby power. Turn on the washing machine and select one of the washing programs. Don’t start it just yet, monitor the load for 2-5 min until you know what’s the average power use in standby. This will be your threshold value set in settings as StandbyPower.

If you want, you can also calculate the cost of use. Each wash cycle is stored in an array with following information:

  • Time in Standby
  • Time in Wash cycle
  • Time waiting to be emptied
  • Cost of the wash

Cost calculator supports 2 electricity tariffs, and you can also pick the times these start and end. This info is also available in notification (Android and Windows, but not in voice assistant).

When the washing machine goes into standby after being odd, nothing really happens. The first event is recorded when the power uses exceeds the standby value. The washing has started (plus/minus 60 sec or whatever login resolution had been set) and the time is noted. At this point, I also start calculating how much each minute costs me and push that value into another array.

If the washing machine stops, I calculate the cost of power used (sum of all elements of the array ), time taken to complete and push that as a notification to Google Home or Android via Join. If you never used Join in NodeRED I have a handy tutorial to get you started. I also created a loop that goes on every 5 min and issues a nagging notification to Google Home. That loop is stopped when washing is taken out and the collected flag is set to true

FUNCTION NODE: Calculate power
var power = msg.payload.Outputs[0].Load;  //adjust message structure to your needs 
var res   = flow.get("Resolution");
var total = flow.get("TotalPower");
var cost  = flow.get("CostArray");
var tariff = flow.get("Tariff");
var metricsf = flow.get("MetricFrequency");
var standby = flow.get("StandbyPower");
var operation = flow.get("Operation");
var currentWash = flow.get("CurrentWashCycle");
var history = flow.get("WashingHistory");

var date = new Date();
var dateS = date.getTime()/1000;
var hour = date.getHours();

function secondsToHms(d) {
    d = Number(d);
    var h = Math.floor(d / 3600);
    var m = Math.floor(d % 3600 / 60);
    return ('0' + h).slice(-2) + "h " + ('0' + m).slice(-2)+"min";
}

//push element
total.unshift(power);
//remove X elementh
if(total[res] === undefined) {flow.set("TotalPower", total);}
else {
    total.splice(res, 1);
    flow.set("TotalPower", total);
}

//calculate average
var sum = total;
function add(accumulator, a) {
    return accumulator + a;
}
var average = (sum.reduce(add)/total.length);
flow.set("average", average);


//power off
if(average === 0){
    flow.set("Operation", "off");
    return [msg,null];
}

var price;
 //apply day tariff
if(hour >= tariff.Start && hour < tariff.End){
    price = tariff.CostDay;
}
//apply night tariff
if(hour < tariff.Start || hour >= tariff.End){
    price = tariff.CostNight;
}

var costPerMinute =  power/1000 * price / (60* (60/metricsf));
cost.push(costPerMinute);
flow.set("CostArray", cost);


//standby
if(average >= standby && operation === "off"){
    flow.set("Operation", "standby");
    currentWash.standbyTimeStart = dateS;    
}

//washing
if(average > 5 ){
    flow.set("collected", false);
    flow.set("Operation", "washing");
    if(currentWash.standbyTimeStart === null){
        currentWash.standbyTimeStart = dateS;
        currentWash.standbyTimeStop = dateS;
    }
    currentWash.standbyTimeStop = dateS;
    currentWash.washTimeStart = dateS;
    
}

//finished washing
if(average < 5 && average >= standby && operation === "washing"){
    flow.set("Operation", "finished");
    currentWash.washTimeStop = dateS;
    currentWash.washFinishStart = dateS;
    
    //total cost
    var sumCost = flow.get("CostArray");
    var costofpower = sumCost.reduce(add);
    currentWash.totalCost = Math.round(costofpower * 100) / 100;
    return [null, msg];
}


//washing collected
if(average < standby && operation === "finished"){
    currentWash.washFinishStop = dateS;
    
    wash = {
        "date" : date,
        "cost" : currentWash.totalCost,
        "TotalWashTime" : secondsToHms(currentWash.washTimeStart -currentWash.standbyTimeStart),
        "TotalStandby" : secondsToHms(currentWash.standbyTimeStop - currentWash.standbyTimeStart),
        "TotalWash" : secondsToHms(currentWash.washTimeStop - currentWash.washTimeStart),
        "TotalFinishWait": secondsToHms(currentWash.washFinishStop - currentWash.washFinishStart)
    };
    
    flow.set("collected", true);
    history.push(wash);
    flow.set("WashingHistory", history);
    flow.set("CostArray", [0]);
    
    var cycle = {"standbyTimeStart": null,
        "standbyTimeStop": null,
        "washTimeStart": null,
        "washTimeStop": null,
        "washFinishStart": null,
        "washFinishStop": null,
        "totalCost": 0,
}       
    flow.set("CurrentWashCycle", cycle);
    flow.set("Operation", "off");
}

Notifications

My notifications are issued to 3 devices (phone, desktop and laptop) I used the credential system to serve the API keys, and I also enabled context storing for my NodeRED.

Alexa

I came across NotifyMe service which is perfect for this scenario as it creates a notification that is pending on Alexa devices until it’s read. You could experiment with Alexaremotev2 to as well if you want, but notifications are so much harder to create via this service.

Setup is simple, add the skill and pick the message you want to set as your payload – it will be sent to your Alexa devices when the washing is done.

Android

Information sent to Android and Windows machines is handled by Join. Join has perfect integration with NodeRED and it’s simple to use. As standard, the notification is sent to Android device when the washing is complete, but with a little bit of work, you could resend silent updates every 5-10 min with the information about the progress of the washing cycle.

To compose the notification, you can pick a fixed message, or compose it with a msg.push instead – I went for the latter as I want to submit data about the last wash cycle:

var currentCycle = flow.get("CurrentWashCycle");

var date = new Date();
msg.payload = {};

function secondsToHms(d) {
    d = Number(d);
    var h = Math.floor(d / 3600);
    var m = Math.floor(d % 3600 / 60);
    return ('0' + h).slice(-2) + "h " + ('0' + m).slice(-2)+"min";
}

var wash = {
        "date" : date,
        "cost" : currentCycle.totalCost,
        "TotalWashTime" : secondsToHms(currentCycle.washTimeStart -currentCycle.standbyTimeStart),
        "TotalStandby" : secondsToHms(currentCycle.standbyTimeStop - currentCycle.standbyTimeStart),
        "TotalWash" : secondsToHms(currentCycle.washTimeStop - currentCycle.washTimeStart),
        "TotalFinishWait": secondsToHms(currentCycle.washFinishStop - currentCycle.washFinishStart)
    };

var phone = global.get("JOIN_mi9");
var desktop = global.get("JOIN_desktop");
var laptop = global.get("JOIN_laptop");

msg.push = {
    "deviceIds": phone +","+ desktop,
    "title":"Your washing has been done in " + wash.TotalWashTime,
    "text":"Don't be a fool - go and take out the laundry before wife nags you! The total cost of the wash is: £" + wash.cost,
    "icon":"https://cdn3.iconfinder.com/data/icons/household-appliances-2/500/Automatic_automatic_machine_clean_machine_wash_washing-512.png",
};

return msg

Google Home

As Google Home doesn’t come with any notifications I can use on smart assistant speakers. I created a voice notification using Castv2 node and a loop that keeps on nagging you until the laundry is taken out from the washing machine. Find your Google Device IP to start using this and simply submit the text of your notification.

Additional stuff

I created a small nagging generator which picks the random nag each time Google Home needs to remind you. There is a basic function to pick a random number from the range specified by the number of elements from the nagging array:

var nagging = [
    "If you don't take care of washing I will divorce you",
    "Stop being useless and get the washing out",
    "Either you take the washing out right now, or you sleep on the sofa tonight",
    "How many times do I have to tell you to empty the washing machine",
    "Washing machine is not going to empty itself - move your bum"
    ];
var random = nagging[Math.floor(Math.random() * nagging.length)];
msg.payload = random;
return msg;

Conclusion

For less than $15 you can smart up your washing machine and probably save yourself a lot of nagging! That’s a great deal. I’m looking forward to the reaction of my misses, as she is away. She is not expecting the washing machine to talk back to her with her “favourite” quotes! There is a version for Alexa too! So if you want to add Amazon Echo devices to the mix, read this post. If you have any questions, as usual, post it in this Reddit thread.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

Getting started with Sonoff ZIGBEE 3.0 USB DONGLE PLUS

0
Testing Sonoff ZIGBEE 3.0 USB DONGLE PLUS against CC2531 and zzh (electrolama) - is it the best upgrade to your Zigbee network?

Smart Home

Remotes aren’t done with us yet: SwitchBot Remote

0
If you hate having 20 remotes hidden in your sofa, or your parents despise talking to Alexa to turn the lights on - SwitchBot Universal Remote is here to deal with all this!

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?