First contact

Man, this weekend. My smarthome got about 10 times cooler.

Web push notifications

Someone smart thought, hey, there’s this cool thing called push notifications and it’s not on the web, let’s fix that. And now we have web push notifications. In short, a website can send notifications to devices. It’s pretty awesome.

It took me the night from friday to saturday to get all that stuff set up. The clientside isn’t hard – I already added a serviceworker back when I implemented the progressive web app requirements. For everything else, the tutorial from Google is pretty detailed. The backend though, that didn’t go as well.

You see, to get your notification delivered from your server to a device, you have to send your notification to an endpoint using a standard called VAPID. Yeah, I also haven’t heard about that one yet. There’s a single PHP library on Github for that, and it requires a ton of things. I had to install composer in order to pull all the required libraries – and then the libraries required by that libraries and so on. In total I ended up with >560 files for a single library that’s only supposed to send a request to some endpoint (my whole system grew by 275%). Anyways, after all that fun, I had to guess around why things didn’t work. The lack of error messages was pretty brutal, and as it turns out, I missed something I had to install on my server. Did I mention that I had to develop this on live? Serviceworkers require SSL and I didn’t have that set up on my dev environment.

Once I got it working though, it’s pretty damn awesome. I mean, being able to send notifications to devices is pretty awesome in context of a smarthome. Some kind of alarm is triggered? Send a notification with a snapshot of a security camera. You want to remotely unlock the door for a friend once he rings your doorbell? Get a notification with a button that allows you to directly unlock the door directly from the notification itself. And so on.

Voice commands

TL;DR I said something to my smarthome and it answered.

This wasn’t that bad to setup actually. I started by researching about a ton of speech recognition programs – most of them are pretty old and discontinued or plain not working. My best guess was Simon, I tried to set it up on a Raspberry Pi with Ubuntu, but not even the standard controls seemed to work.

I then recalled that I once played around with a pretty awesome Android app called Tasker. In short, it lets me automate a ton of stuff on my Android phone. A plugin called AutoVoicer uses Google voice recognition voodoo to listen for commands and notifies Tasker about recognized ones.

To be specific, I configured Tasker to wait for a “Turn on the lights” and then do a request to my smarthome which in turn writes the command into its block. My event management then notices that said block was written to and triggers – the result is a call to my text-to-speech functionality which then said “Lights enabled”.

Pretty cool, huh?