Category Archives: Uncategorized

1 Click IoT Buttons And Laundry

So, I have a “typical” problem, in that I forget when the washing cycle is supposed to end, leading to clothes sitting in the machine for some amount of time.

I’ve tried setting reminders on my phone but I’m not always 100% at remembering to do that either, especially if there’s multiple batches or a washer and a dryer cycle running.

I should note that these are “dumb” machines, which are unlike current models which send you a ping to your phone when they’re done (which actually seems like a sensible idea for IoT / embedded systems in consumer devices).

I wondered whether I could come up with some really automated way of doing this like:

  • Monitoring the power consumption (through a connected load monitor) which looks for a spike then zero for a period.
  • Sticking vibration monitors to the side.

But I couldn’t figure out something that was really reliable (didn’t suffer from false positives like someone walking past) or didn’t need a bunch of processing power running on a brittle VM at home.

The answer then is to go all out on a crazy serverless architecture in AWS using 1 Click IoT buttons.

The idea is that you can mash the button stuck to the washer or dryer as you start the program, then based on the normal program you use (let’s face it, it’s always the same) you can get a notification a set amount of time later.

The AWS IoT buttons are no longer directly available but you can get them off eBay for £10 each or so – they’re basically the same as the Dash buttons used to be but unbranded.

The buttons can be programmed using Bluetooth, via a phone app, to connect to your wifi and then directly send an email. Unfortunately this won’t do for our needs as we need to send that mail an hour later. Luckily the buttons can trigger a Lambda function of our choosing – great!

But not so fast – Lambda functions can only run for a short time, and all the while they’re running, they incur costs, so it’s not just a matter of putting in a sleep(). What we need to do then is the following:

  1. Button press triggers Lambda function
  2. Lambda invokes a Step Function with a pause
  3. Step Function triggers another Lambda function, which calls:
  4. An SNS notification
  5. People are subscribed to the SNS Topic, and get an email, SMS or push notification

Want to setup this idiocy yourself?

Start by creating a templated Step Function. This will use Cloud Formation to create the Step, SNS Queue, IAM role, and Lamba function for you. You’re looking for the “Wait state” template:

Now go into Lamba and create a function called “washer” with the following Python 3.x snippet:

from __future__ import print_function

import json
import urllib
import boto3
import time

print('Starting washer notification with 60 minute delay')


def lambda_handler(event, context):

    # Edit the message and timer duration below as needed
    
    data = {
  "topic": "arn:aws:sns:eu-west-1:xxxxxxx",
  "message": "Washer Done",
  "timer_seconds": 3600
}

    json_string = json.dumps(data)
    
    client = boto3.client('stepfunctions')
    response = client.start_execution(
        stateMachineArn='arn:aws:states:eu-west-1:xxxxx',
        name=context.aws_request_id,
        input=json_string
    )
    

    return ('Triggered step function')

You will need to edit the SNS topic and the state machine ARNs that cloud formation created for you, which you can find within the SNS and State Function areas of the console, e.g:

You will then need to go into the IAM console and give the cloud formation-created IAM role the ability to access Step Functions (probably not full access, but as there’s only me in this account I don’t think it matters):

You lastly need to go into 1 Click, and create a template for button clicks that call your “washer” lambda function, and then provision the buttons into your account via the iOS/Android mobile apps:

I then use Pushover to take an email generated as an output from the SNS Topic to turn that into a mobile alert, but an email or SMS is equally doable.

And there you have it, a stupidly over engineered solution for telling you when your laundry is done, ish.

As for costs: Lambda and Step Functions have a free tier and you’re unlikely to go over those limits with this little project.
Buttons have a 25 cent a month charge.
SNS has no charge for emails or SMS within the US, ~£0.02 per text otherwise.

Nice to see Apple finally gets it. A bit.

Nice to see Apple finally gets it. A...

It wasn’t long ago that editing a document in Apple’s own flagship apps, like Pages and Numbers, meant that your data was now firmly locked away inside (unless you wanted to start emailing it back to yourself) although there were plenty of Office-editing apps that could.

Now you can at least save your edits straight back into a supported app like Dropbox or FileExplorer which can save and sync to home and corporate network drives via CIFS. Maybe the ipad now starts to become a viable content creator and not just a content consumption device.

Half way

Eugh, half way on this blasted polymeric (liquid) diet. No noticable improvement in my Crohn’s symptoms either, in fact, I was pretty badly affected when I dropped my steroid dose down last week. That’s now back up again

I’m taking some time off at the end of this week to try and relax a bit as well. Super stuff.