Washing Machine Notifications

8,533

121

31

About: I am passionate about technology, cycling and art. This would explain why my bike has more computing power than your average office. I'm an editor for pocketables.com and xda-developers.com . Follow me throu...

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.

Features:

  • Google Home integration with (optional) nagging
  • Random nagging notifications every 5 min
  • Android notifications
  • Cost of wash and total time of the wash
  • neat graph (because of big data)
  • absolutely no hardware hacks to the washing machine (full warranty retained)
  • no need to arm or disarm the alarms (Start washing to start, turn off washing machine to stop)

Supplies:

Step 1: 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.

I want to have a notification on my mobile/computer/Google Home when the washing is done. I don’t want to remind myself about setting timers, arming anything, just put the washing in and get someone else other than my wife to remind me that the washing needs attending.

So in order to save my marriage from the impending doom, and make some extra bucks from affiliated 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!

You will need to get Sonoff POW R2 - I linked few shops for you, but if you find a better deal, it's even more awesome:

(Just don't think I'm so nice, these links give me a tiny kickback if you use it - thank you!)

Sonoff POW R2

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!
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.

Step 2: 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.

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)

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 the 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;

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.

Step 3: Final Words

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!

In addition, if you want to get informed about the updates to this or other projects - consider following me on the platform of your choice:

and if you feeling like buying me a coffee or supporting me in a more continuous way:

I hope you have enjoyed the project! Check more projects out on notenoughtech.com

Share

    Recommendations

    • Gardening Contest

      Gardening Contest
    • Classroom Science Contest

      Classroom Science Contest
    • IoT Challenge

      IoT Challenge

    31 Discussions

    0
    None
    Diez66

    24 days ago on Step 3

    OK, so I am hoping to post in the "I made It" soon.
    Already been a few days, part time, playing with and getting the setup correct.
    I have the Sonoff, it now has Tasmota.
    I have Node-Red running and now I am playing with "how that works".

    Next I actually have to do this.
    So, holding my breath, just about to jump in".
    See you on the other side, eventually.

    4 replies
    0
    None
    Diez66quintaar

    Reply 15 days ago

    So, it’s has been a little while.


    Have I got my/your project up and running, NOPE!


    Why, well I want to blame Node-Red and the complexity of
    your project but I feel that it is me.

    I have had a whole heap of issues but they all stem from me, “Not knowing How
    Too”.

    I have programmed in with assembler, Basic, Visual Basic, Word/Access macros,
    Python and even “C/C++”ish on Arduino. I
    have also made several home IOT devices in the home and away do my bidding
    linking Raspberry Pi’s to IFTTT / Gmail and the like.

    Turns out that this was not enough for this complete project all I one go. Man
    I have (1st world) suffered.


    So, how far have I got? Well I am actually quite pleased.

    Your idea was something I was thinking of, I could, with your project, answer
    the “forever asked”, “Is the washing Finished?”. It’s not quite the same as your problem it is
    from the other side. I just got fed up of going to check, of having to guess, for
    someone else! I am sooo lazy….


    So Now: I have the very basics running, the Node-Red flow
    monitors the Sonoff, it gets the date and puts this, every minute to a Google
    Sheets spreadsheet; it has taken forever.

    I am really chuffed though.

    With the flow I have produced I am letting the machine run through
    its programs and logging its power usage. I can then get to make the flow
    produce the “Washing Finished” alert.

    How I do this, unsure yet. Also need to managed the Sonoff is unplugged “error conditions”
    etc. so it can be totally unattended, the user of the machine just uses the
    machine.


    Just want so say, “Thanks”. I have done several little
    projects as I said and recently thought I should be a bit more structured and
    this has helped towards that.

    Node-Red looks like it is very powerful and there is a lot of help out there and
    I am starting to understand some of it, there was the problem, and maybe soon I
    can let you know I have what I want working. Maybe after that I can get back to
    your project and wonder why I found it so hard.


    Thanks, loving and hating it in equal amounts but it has
    keep me very busy and, I have learned a bit more.





    P.S. I know I can ask for help but my questions were so basic and general. I wanted to work through them. When I get near the end and the flow is doing my basics, then I may pop up and ask a couple of "This Project" specific questions.

    0
    None
    quintaarDiez66

    Reply 15 days ago

    Hi, first of all, CONGRATULATIONS on completing your version of the project. Makes me wonder why did you use Google Sheets API? It's really awkward to work (I was tempted to use it at some point but I gave up haha)
    I can understand the desire of working out things on your own. I learned a lot this way, and each puzzle is actually fun once you remove all the frustration associated with it.
    I actually don't think I have included anything for offline - its a good idea! Thank you! I will be making cost breakdowns with this project (day week month year) so I will proof it against the offline mode.

    The way I monitor end of washing is through pushing last 5power values to an array and clearing the oldest one. At some point, the array will equal the idle power draw - it's a fairly foolproof idea. You could automate this with Sheets as well i believe.

    If you get any questions I'm here

    0
    None
    Diez66quintaar

    Reply 15 days ago

    Thanks, it is fun eventually.
    I have seen something about adding values and then averaging to get a similar result for, have we finished but I like the array idea, just need to work it out.
    I would like Alexa to shout out FINISHED, that's my long range aim. I will update you.
    The IFTTT sheets thing I have used before, took a little time to work out but it was nice to get something comfortable. It may only be used in the interim as part of the development. Thanks for the feedback.

    0
    None
    RostislavT

    Question 19 days ago

    Hi,
    At first - very nice idea ;-)
    Now - a question - I took some parts of your instructable (I'm using it for dryer), but instead of notification I'm turning off the relay after some timeout. What I saw - the relay periodically turns on after some time without my intervention (I implemented a detection to turn it back off). Did you see something like that? Or you are keeping it "always on"?

    4 answers
    0
    None
    quintaarRostislavT

    Answer 19 days ago

    I keep the relay on as in the OFF position the washing machine is not drawing any current. My version has no controls over the relay in any way.
    If you want to use "washing done" to turn off the relay - the Join message triggers just once. You can link that in NodeRED to your relay control.

    0
    None
    RostislavTquintaar

    Reply 19 days ago

    Hi,
    My problem is a bit different - I connected a logic to turn it OFF and I have no logic to turn it ON in node-red, but what I saw - it turns ON itself after some random time. It does not look like ESP reset as Uptime is growing.

    0
    None
    RostislavTRostislavT

    Reply 18 days ago

    Answering myself - my fault. When started to play with device MQTT I sent a persistent power-on message and broker reactivated it periodically. After clearing broker db - it looks like device stopped to turn on itself ;-)

    0
    None
    quintaarRostislavT

    Reply 18 days ago

    Cool! Sometimes thinking outloud helps a lot :)

    0
    None
    Purclewan

    Question 4 weeks ago on Step 1

    When I try to run this Node-Red code I get an error. "The workspace contains some unknown node types:
    • join-message"
    I'm running an uptodate version of Node-Red 0.19.04 on a Windows 7 machine and can't find anything reffering to join-message in my nodes or in the pallette. I'm obviously being stupid but can anyone suggest what I am missing.
    3 answers
    0
    None
    quintaarPurclewan

    Answer 4 weeks ago

    Try via console and npm - my bet is on nodeRED not having permissions. So use the console with sudo.. it should force it through - if you do so, all updates for that node will have to be applied by terminal too

    0
    None
    Purclewanquintaar

    Reply 4 weeks ago

    Thanks for the prompt answer. Unfortunately, I have tried to upload the join node on three different Node red instances, two running on Raspberry Pi and my original PC running Win 7. In every case I get an error message, using the Palette I get "Failed to install" and using npm I get an invalid file message. Any ideas?

    Update: I have tried again on the PC and this time it worked. Still can't get it to download on the Raspberry Pi though.

    0
    None
    Razanur

    5 weeks ago

    Hey. Cool project. I'm just wondering, but it appears to me, that the electricity is actually the smallest part of the total cost. Have you considered adding the cost for water and detergent? Probably just as an offset... 0.11$/EUR/Pounds wouldn't make me too excited to empty the machine...

    1 reply
    0
    None
    quintaarRazanur

    Reply 5 weeks ago

    I'm not sure how I'm going to explain this to the sonoff :) hahaha in theory you could add the default offset for detergent used. That's not a problem. I just didn't want to make an interface for this at all. I'm forgetful, no way I would add each time "cup of powder & and a cup of softener"
    But if you link this to a barcode scanner in your phone, you could introduce the cost of washing powder devided by the number of washes done.

    0
    None
    Gusgonnet

    5 weeks ago

    Hey there, I read somewhere (cannot find now) that Itead "closed" somehow the possibility to flash new firmware to their Sonoff products.
    Have you faced any challenges in this regard?
    Thanks!

    1 reply
    0
    None
    quintaarGusgonnet

    Reply 5 weeks ago

    I think it's quite the opposite. In May they will release the DIY mode that opens up REST API without flash. So you would be able to keep original firmware and have the offline 3rd party access on your terms. It wont replace MQTT etc.. but it's an option for all who dont feel comfortable modding hardware

    0
    None
    ScottB231

    6 weeks ago

    Very ingenious! I'm using a couple of the Sonoff smart switches for the power monitoring myself. I wondered if it was possible to tie in or redirect that information... wow! Thank you!

    1 reply
    0
    None
    quintaarScottB231

    Reply 6 weeks ago

    Trust me, no one is happier than my wife... Constant nagging is the mother of all inventions :) haha
    Thank you! Let me know how you get along!