Skip to content

🧺 Trigger PagerDuty incidents when the washing machine is done.

License

Notifications You must be signed in to change notification settings

Aldaviva/LaundryDuty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Washing Machine · Dryer

Kenmore 500 washer LaundryDuty

GitHub Workflow Status Testspace Coveralls

Notify you when your washing machine has finished a load of laundry by sending a PagerDuty alert.

  1. Prerequisites
  2. Installation
  3. Configuration
  4. Running
  5. Alerts
  6. Presentation

Washing machine mode dial

Prerequisites

Installation

  1. Download the latest release ZIP file.
  2. Extract the ZIP file to a folder, such as C:\Program Files\LaundryDuty\.
  3. Run the .\Install service.ps1 script file in an elevated PowerShell window.
    • If PowerShell throws an ExecutionPolicy error, you will need to run
      Set-ExecutionPolicy RemoteSigned -Scope Process -Force
      & '.\Install service.ps1'

Configuration

  1. Plug your washing machine's power cord into your Kasa smart outlet.
  2. Plug the smart outlet into a NEMA 5-15-R 120VAC wall outlet.

    Washing machine power cord plugged into a Kasa KP125 smart outlet, plugged into a 120V wall outlet

  3. Connect the smart outlet to your Wi-Fi network using the Kasa Android or iOS app.
  4. Get the smart outlet's IP address from your router's client or DHCP list, or by running nmap --open -pT:9999 192.168.0.0/16.
    • You may optionally assign an A record to this IP address in DNS, and use it instead of the IP address.
  5. Create an Integration in PagerDuty and get its Integration Key.
    1. Sign into your PagerDuty account.
    2. Go to Services › Service Directory.
    3. Select an existing Service for which you want to publish events, or create a new Service.
    4. In the Integrations tab of the Service, add a new Integration.
    5. Under Most popular integrations, select Events API V2, then click Add.
    6. Expand the newly-created Integration and copy its Integration Key, which will be used to authorize this program to send Events to the correct Service.
  6. Edit the appsettings.json configuration file.
    Key Example Description
    minimumActiveMilliwatts 750 If the outlet is drawing at least this many milliwatts, then the washing machine will be considered to be currently washing a load of laundry. See power levels.
    maximumIdleMilliwatts 413 If the outlet is drawing at most this many milliwatts, then the washing machine will be considered to have completed its most recent load of laundry and had its lid opened. Readings of 0 mW are ignored. See power levels.
    pollingIntervalMilliseconds 15000 How often to check the power usage of the washing machine, in milliseconds.
    pagerDutyIntegrationKey "y5mfpn493se259tq8s6rg4yswndvj38w" The PagerDuty Events API V2 Integration Key that you created in the previous step.
    outletHostname "192.168.1.100" The FQDN or IP address of the Kasa smart outlet that is powering the washing machine.
    outletTimeoutMilliseconds 2000 How long, in milliseconds, to wait to connect to the outlet or receive a response before either retrying or giving up until the next iteration of the polling loop.
    outletMaxAttempts 10 How many times to attempt to connect to the outlet in one iteration of the polling loop if the previous attempts failed before giving up and trying again in the next iteration.
    outletRetryDelayMilliseconds 1000 How long to wait, in milliseconds, between repeated attempts to connect to the outlet in one iteration of the polling loop if the previous attempts failed.
    outletOfflineDurationBeforeIncidentMilliseconds 900000 How long, in milliseconds, the outlet can be unreachable before a PagerDuty incident is triggered to tell you it's offline. Defaults to 0, which means never trigger an outlet offline incident.
    Logging.LogLevel.Default "Information" Minimum severity of log events to emit. Values are Trace, Debug, Information, Warning, Error, Critical, and None.
    View logs in Event Viewer.

Power levels

This program relies on detecting the running state of a washing machine by observing its instantaneous wattage being consumed, as exposed by the smart outlet's energy monitoring. The wattage levels of each state require precise fine-tuning and will vary between washing machine models.

The example values given are for a Kenmore 500 Series washing machine. They were derived by writing a program using Aldaviva/Kasa to periodically log the current, voltage, and power of the washing machine when it was in each state (active, complete, and idle) to find a pattern in the energy usage. After some spreadsheets and histograms, the following state machine was derived.

state machine

Washing machine state machine. All values are power in milliwatts.

A complication is that the transition from complete to idle when the power drops below 413 mW is not symmetric — the state cannot then change directly from idle to complete without first becoming active again. This is to prevent spurious high power readings when the machine is idle from incorrectly putting it back in the complete state.

Running

Do any of the following.

  • Start the LaundryDuty service from Services (services.msc)
  • net start LaundryDuty
  • sc start LaundryDuty
  • Start-Service LaundryDuty

Alerts

  1. When the washing machine becomes active, this program will send a Change event to PagerDuty with the summary

    The washing machine is starting a load of laundry.
    

    Change event in the PagerDuty web app

  2. When the washing machine completes the load, this program will trigger a new Alert at the Info severity, with the summary

    The washing machine has finished a load of laundry.
    

    Alert in the PagerDuty Android app

  3. When the washing machine's lid is opened after it finishes a load, this program will automatically resolve the previously-created Alert. You can also manually resolve the alert from the PagerDuty web or mobile apps.

    Incident timeline in the PagerDuty Android app

Presentation

I gave a talk about this project during PagerDuty's 2024-02-09 How-To Happy Hour on their Twitch channel.

Video