Washing Machine ยท Dryer
Notify you when your washing machine has finished a load of laundry by sending a PagerDuty alert.
- .NET 6 x64 Runtime or later
- Windows 10 or Windows Server 2016, or later
- Kasa smart outlet with energy monitoring
- PagerDuty account (the free plan is sufficient)
- Download the latest release ZIP file.
- Extract the ZIP file to a folder, such as
C:\Program Files\LaundryDuty\
. - Run the
.\Install service.ps1
script file in an elevated PowerShell window.- If PowerShell throws an
ExecutionPolicy
error, you will need to runSet-ExecutionPolicy RemoteSigned -Scope Process -Force & '.\Install service.ps1'
- If PowerShell throws an
- Plug your washing machine's power cord into your Kasa smart outlet.
- Plug the smart outlet into a NEMA 5-15-R 120VAC wall outlet.
- Connect the smart outlet to your Wi-Fi network using the Kasa Android or iOS app.
- 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.
- Create an Integration in PagerDuty and get its Integration Key.
- Sign into your PagerDuty account.
- Go to Services โบ Service Directory.
- Select an existing Service for which you want to publish events, or create a new Service.
- In the Integrations tab of the Service, add a new Integration.
- Under Most popular integrations, select Events API V2, then click Add.
- 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.
- 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
, andNone
.
View logs in Event Viewer.
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.
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.
Do any of the following.
- Start the
LaundryDuty
service from Services (services.msc
) net start LaundryDuty
sc start LaundryDuty
Start-Service LaundryDuty
-
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.
-
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.
-
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.
I gave a talk about this project during PagerDuty's 2024-02-09 How-To Happy Hour on their Twitch channel.