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.
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
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
If the washing machine stops, I calculate the cost of power used (sum of all elements of the array ), collected
flag is set to true
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
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.