A headshot of Joey.
  • iot
  • typescript
  • aws-lambda
  • aws-sns
  • aws-eventbridge
  • aws-cdk

Washing machine notification lambda

washing machine notification lambda diagram

Most smart devices record much more data than we ever see or even know about. What might surprise you even more is that many smart device management apps retrieve this data every time you open the app, but never show it to you.

A couple reasons for this could be: 1) it's easier to reuse an API that already exists rather than create a new one that only gets the data needed or 2) there is a feature being worked on that uses this data. However, neither of those is a valid reason because retrieving extra data has performance and security implications.

The idea for this project first started when I decided to use Fiddler as a proxy for my smartphone's traffic to see what kind of APIs and data the apps on my phone are using. I started looking at all the data about my washer and dryer that was available using the LG ThinQ app and realized that I could use this information to solve a common problem at home: forgetting to take the clothes out of the washing machine.

The app already sends a notification when the washing machine or the dryer finish a cycle which has reduced the number of times my wife or I forget to unload the washing machine but it occasionally gets lost in the plethora of smart phone notifications we receive every day.

I decided to use AWS to solve this problem. I created an AWS Lambda function that is triggered by an AWS EventBridge scheduled event, AWS Systems Manager Parameter Store for the application secrets, and AWS Simple Notification Service (SNS) to send an email notification.

The application flow goes like this:

  1. AWS EventBridge publishes an event every hour at minute zero using a cron expression.

  2. The AWS Lambda function is triggered by that event.

  3. The lambda function retrieves the application secrets from AWS Systems Manager Parameter Store.

  4. The lambda function queries the LG ThinQ API to see if the washing machine finished more than the threshold number of hours ago and if the dryer is running or was run after the washing machine.

  5. If there are still clothes in the washing machine and it is during the configured quiet hours, send an email using SNS.

  6. If there are still clothes in the washing machine and it is outside the configured quiet hours, make an announcement on all my Alexa devices using a webhook.

  7. If errors, also send a notification via email or an Alexa announcement depending on the current time.

If you have any questions or suggestions regarding my lambda function, please create an issue on the GitHub repository using the source code link below!

Source code link

github.com