Catalogue
Solving the "Did the Dishwasher Finish?" Problem with RaspberryPI + BlueButton + LINE Notify + Google Home

Solving the "Did the Dishwasher Finish?" Problem with RaspberryPI + BlueButton + LINE Notify + Google Home

🌐 日本語で読む

Overview

The problem of not being able to tell whether the dishwasher had finished was happening a lot in our home.

This is the story of how I solved it with RaspberryPI + BluetButton + LINE Notify + Google Home.

What’s the problem?

In our home, we run the dishwasher once it's reasonably full, so the time we run it is never fixed.

Because of that, every now and then, when my wife or I pulled out the dishwasher we'd wonder, "Wait, are these the washed ones?" Suspicion ran high and things got tense, and our son would come running over to give us a Dragon Stop more often than I'd like.

If only we had some kind of mechanism that kept a record, something you could just look at and know!
That would be a huge help, so I started thinking about whether I could solve it with engineering.

The solution

I made it so the start time gets posted to a LINE group as a record.*1

I wanted to make that notification mechanism simple enough to handle with a single press of a button,
so I decided to implement it with a BlueButton that I could pair with the Raspberry PI I already had at home.

How it works

  1. When you start the dishwasher, press the BlueButton.
  2. Pressing the BlueButton passes the "button pressed" information to the Bluetooth-paired Raspberry PI.
  3. A script running on the Raspberry PI that detects whether the BlueButton was pressed catches it.
  4. Triggered by step 3, LINE Notify sends a notification to LINE.
  5. Triggered by step 3, Google Home speaks a "the dishwasher has started" message.*2

The processing branches depending on how long you press.

  • Long press = notify Google Home and Line that the dishwasher has started
  • Short press = read out the dishwasher start time

What I bought

Raspberry Pi 3 Model B V1.2 (日本製) 国内正規代理店品

Raspberry Pi 3 Model B V1.2 (日本製) 国内正規代理店品

Google Home

Google Home

The BlueButton was about 100 yen on Amazon ♪ Easy on the wallet!

Google Home is really just a stand-in for a speaker, used to confirm when the button is pressed.
You could connect a USB speaker, or blink an LED instead, anything that lets you confirm it would be fine.

Setting up on the Raspberry PI

Raspberry PI information

$ uname -a

Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

Preparation

  • Sign up for LINE Notify and generate a token.
    LINE Notify

  • Pair the BlueButton over Bluetooth in advance.

There are already plenty of articles on pairing. The following article should be helpful.
Bluetoothシャットダウンボタンを作る #300円でIoTボタン

Installing google-home-notifiler

  • Install nodejs and npm
pi$ sudo apt-get update
pi$ sudo apt-get install -y nodejs npm
pi$ sudo npm cache clean
pi$ sudo npm install npm n -g
pi$ sudo n stable
  • Configure google-home-notifiler
pi$ cd ~
pi$ git clone https://github.com/noelportugal/google-home-notifier
pi$ cd google-home-notifier/
pi$ npm install
  • Edit example.js
...
const serverPort = 8091; // default port

+ var deviceName = 'ファミリールーム'; // Google Home's device name
+ var ip = '<Google Home's IP>'; // ex. 192.168.11.5
...

For how to check the Google Home's IP, see here.

Creating the google-home-notifler server startup script

  • /etc/systemd/system/googlehomenotifier.service
[Unit]
Description=google-home-notifier Server
After=syslog.target network-online.target

[Service]
Type=simple
User=root
ExecStart=/usr/bin/node example.js
Restart=on-failure
RestartSec=10
KillMode=process
WorkingDirectory=/home/pi/google-home-notifier

[Install]
WantedBy=multi-user.target

After adding the above, run daemon-reload to make `googlehomenotifier.service` recognized.

pi$ sudo systemctl daemon-reload

Now let’s start google-home-notifiler

pi$ sudo systemctl start google-home-notifiler

Let’s try making it say hello ♪

pi$ curl -X POST -d "text=hello" https://127.0.0.1:8091/google-home-notifier

Setting up the BlueButton

pi$ sudo gem install bluebutton

Installing the dishwasher Notify script

I originally wrote it in python, but shell turned out to be faster, so it's in shell.

pi$ cd ~
pi$ git clone https://github.com/kenzo0107/dishwasher
  • Change the following part of dishwasher.sh to the value you generated earlier.
readonly LINENOTIFY_TOKEN="<please change yours>"

Configuring & running the startup script

pi$ sudo cp bluebutton.service /etc/systemd/system/
pi$ sudo systemctl daemon-reload
pi$ sudo systemctl start bluebutton.service

Let’s run it

It works ♪

Just a small note about the BlueButton

The BlueButton has the following button trigger types,

  • key down: press the button
  • key up: release the pressed button
  • long key down: long-press the button
  • long key up: release the long-pressed button

When you do a long key down (long press), a key down event fires first, and then the long key down event fires.

So if you have a handler assigned to the key down event,
you can't run only the handler assigned to the long key down event,
so be careful about that.

Wrap-up

Thanks to the dishwasher start button, the squabbles disappeared from our home,
and even our son, who was going through the terrible twos, seems to have become more cheerful.

I'd be glad if this helps anyone dealing with a child in the terrible twos and the dishwasher problem.

That's all.

*1:Since I can hit it with curl, I figured later on I could notify wherever the whole family looks, like Slack or anything else.

*2:Google Home is really just a stand-in for a speaker.

Solving the "Did the Dishwasher Finish?" Problem with RaspberryPI + BlueButton + LINE Notify + Google Home

https://kenzo0107.github.io/en/2018/08/20/raspberrypi-bluebutton-line-notify-google-home/

Author

Kenzo Tanaka

Posted on

2018-08-20

Licensed under