Home Home Automation Washing machine notifications - making "dumb" machine "smart"

Washing machine notifications – making “dumb” machine “smart”

£150 washing machine with a "nagging mode" on.

I have a “dumb” cheapo washing machine for about £150. The size was the biggest constraint, so don’t judge me too harshly. The dumber thing in my household is me. Washing white underwear with red jumpers is one of my sins. The other one is not remembering that something has been put into the washing machine. In result, I have washed the same batch about 3 times once, leaving it in for days to come. It was time to adjust my behaviours, especially as failure to comply will result in a divorce. I’m getting old, I cannot have this happen. Time for the washing machine notifications, there is no remedy for pink underwear, I guess I just have to wear it.

This is an updated article, contains the NodeRED 1.0 compatible flow with settings and Alexa integration via notify me. The video comes without Alexa integration.

Washing machine notifications

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 washing machine notifications

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.

Settings

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 (a JSON object that has 2 tariffs. Fill in the price and times the tariff changes, if you only have a single tariff, duplicate your price)
  • Timeout (time in minutes after which the notification will be issued. It’s set to 5 min, but feel free to change it. Increase the timeout if your washing machine notification triggers mid wash)
  • 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)

Washing machine notifications – flow

How does it work? I used a clever trick of trimming an array to number of values which equal the timeout in minutes. This means the flow ALWAYS checks the average power draw of the washing machine.

  • average === 0 (washing machine is off)
  • average <= x && average > 0 (washing machine in standby)
  • average > 0 (washing machine in use)

Since I’m checking the power use of the washing machine every 60 sec (the lowest value I recorded was 3W), I can easily tell when the machine is washing, in standby or off. It’s time to wrap a working logic around it and add some notifications.

FUNCTION NODE: Calculate power
var power = msg.payload.StatusSNS.ENERGY.Power;
var timer = flow.get("timeout");
var total = flow.get("Total");
var cost = flow.get("CostArray");

//check if array exists
if(!total || !total.length || total === undefined){
        total = [];
    }

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

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) 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. I’m also arming the notification.

If the washing machine stops, I calculate the cost of power used (sum of all elements of the array ), time taken to complete (minus timeout) 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 loa op that goes on every 5 min, and issues a nagging notification to Google Home. That loop is stopped when the power used by washing machine = 0. I also have to disarm the notifications.

FUNCTION NODE: announce false
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";
}

flow.set("announce", false);
var start = flow.get("WashStart");
var timer =  flow.get("timeout");

//calculate wash time
var date = new Date();
var ms = date.getTime();

var totaltimeinsec = (ms-start)/1000 - 60 *timer;
var totalWashTime = secondsToHms(totaltimeinsec);

flow.set("TotalWashTime",totalWashTime);
flow.set("WashStart", 0);

// save the wash power session
var washtotal = flow.get("WashTotal");
var sum = washtotal;

function add(accumulator, a) {
    return accumulator + a;
}

var average = sum.reduce(add);
msg.average = average / washtotal.length;
flow.set("WashTotal", null);

//total cost
var sum = flow.get("CostArray");

function add(accumulator, a) {
    return accumulator + a;
}

var costofpower = sum.reduce(add);
var totalcost =  Math.round(costofpower * 100) / 100;
flow.set("CostArray", null);
flow.set("TotalCost", totalcost);

msg = {};

msg.payload = "Your washing is ready";
msg.ms = ms;
msg.totalWashTime = totalWashTime;

return msg;

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.

FUNCTION NODE: reset notification
flow.set("announce", true);
var power = msg.payload;
var total = flow.get("WashTotal");
var start = flow.get("WashStart");



// just starting the wash
if(start === 0){
    var date = new Date();
    var sec = date.getTime();
    flow.set("WashStart", sec);
}

//check if array exists
if(!total || !total.length || total === undefined){
        total = [];
    }

//push element
total.unshift(power);
flow.set("WashTotal", total);
msg.payload =  total;

return msg;

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

I also linked the controls for the Sonoff if you want to turn it on or off and added the status update if you want to include this in a dashboard or something. I also implemented a dashboard so you could see how different wash cycles consume power. That should be interesting.

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 in style with crypto-currency

Smart Ideas with

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

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

ESP8266 WIFI lights under $5

0
Your Sonoff device can't do this!

Free wireless doorbell (Amazon Dash button hack)

0
The most terrifying situation I can imagine* is missing a parcel

New Amazon Dash Buttons

0
You can teach new buttons old tricks!

ESP8266 ceiling light – demo

0
Testing the ESP8266 as a WIFI light controller

Try Tasker and Raspberry Pi for your home automation needs!

0
Raspberry Pi can help you with your Tasker profiles

Smart Home

Army of robots: SwitchBot Curtain

0
An army of SwitchBot Curtains - adorable CurtainBots to open and close practically any curtains!

Zemismart Roller Shade Driver

0
Frustrated with UK's roller measurements I reached out for Zemismart Roller Shade Driver

Most affordable smart lightbulbs: Sonoff B02 & B05

0
ITEAD just dropped a range of very affordable smart Sonoff lightbulbs

Creepy Alexa for Halloween

0
Turning Amazon Echo into a Creepy Alexa monster for Halloween

How to make Sonoff ZB Mini and ZigBee2MQTT work together

0
It's time to make Sonoff ZB Mini and ZigBee2MQTT work together!