Blog

Project Bindicator: Software

Welcome to the final post in my series on building my bindicator: the software. If you haven’t already read about the hardware I put together then that’s probably worth a read before you go too much futher.

The primary goal of the bindicator is fairly simple: on the evening when the garbage needs to go out, the bindicator should light up in the relevant colours. For the way I plan to use it, I have some additional requirements: I want the people in my household to have a way to dismiss the indication once it’s been dealt with, and I want the notification to time out after a certain amount of time even if nobody has dismissed it. I’d also love for the notification not to fire at all if we’re on vacation.

There’s probably any number of different ways we could go about achieving this with a combination of hardware and software, but in our house we already have Home Assistant installed and hooked in to any number of household devices and functions, running automations to control them and get them working together. As a result, my approach will be to keep all the logic in home assistant and make the bindicator device itself fairly dumb – all I want it to do is show up in home assistant as a light (actually three lights) that home assistant can control.

Enter ESPHome!

ESPHome is a sister project to home assistant intended to be installed on devices with a microcontroller (either commercial or home-made devices) to control the hardware. As you’d imagine, it integrates with home assistant really nicely and I believe there are a few different ways of doing that integration. I use MQTT.

You use a YAML configuration to specify what hardware components your device has and how they’re connected to the microcontroller. It then generates the firmware, and you upload it to the device. Simple!

I published my configuration in my git repository. It defines three lights – one that represents the entire bindicator (both halves), and one each that’s specific to the top and bottom segment of the bindicator. For each of those it adds a custom lighting effect that pulses the light on and off periodically, and then it makes the whole thing available to home assistant over the MQTT and provides some additional options that let me do things like OTA firmware updates.

On the home assistant side, I’m using a couple of key integrations. Recollect Waste and the HomeAssistant mobile app. I then built an automation that runs every day at 6pm and checks if there’s a garbage collection scheduled for the following morning. If there is it additionally checks if there’s one type of garabge being collected or two, and lights up either the whole bindicator in a single colour or each of the two segments independently as appropriate.

It also sends a notification to each of our phones telling us there’s garbage to go out, and watches for one of those notifications to be dismissed with a four hour timeout. When one of us dismisses a notification it then removes the notification for everyone else and turns the bindicator off.

Home assistant uses a nice friendly GUI to create and edit automations and they’re saved in YAML format behind the scenes. I’ve published my automation in YAML format.

What’s Next?

I don’t have many plans to evolve what I’ve built because it’s working pretty well. We already use a “home mode” selector in Home Assistant to change some of our home’s settings if we have houseguests or are on vacation, so the automation I’ve linked above already leverages that and skips taking any action if we’re not home to deal with it.

I have an idea of using our security cameras and computer vision (probaly leveraging frigate) to detect when we put the garbage out and react appropriately so we don’t need to manually acknowledge that it’s done (and also alert us if we accidentally put the wrong colour cart out, or perhaps even alert us once they’ve been emptied and we can take them back in).

Watch this space to see if I actually do any of that!

Blog

Making My Own Bindicator

Somewhere around five years ago I saw a semi-viral tweet, and was immediately inspired.

In some ways I’ve been thinking about the ever since. I’ve always loved electronics projects but I didn’t have the capabilities to make a bindicator of my own back then, so I started with the software: the City of Calgary makes their garbage schedule available in iCal format through an API and I’d been subscribed to it via Google Calendar for some time. It wasn’t a difficult task to write a little bit of code to create a sensor in @[email protected] that tells me which carts need to go out that day, and from there it’s even more trivial to craft an automation that sends us each a notification at 7pm the evening before the garbage needs to go out.

This is nice and all, but the idea of a bindacator of my own never really went away, and now that I can do my own , now’s the time!

There are plenty of articles online about how to make this and the original creator has two-part YouTube series that walks us all through it, so I think it might be the perfect first project for combining my new 3D printing capabilities with my aforementioned affinity for little electronics projects.

I don’t 100% know where to start because the microcontroller that I’ve ordered isn’t the exact same one used in the original build, and rather than four individual LEDs my plan is to simply use four LEDs from the end of a spare light strip I have lying around and I’m not certain whether these will fit nicely into the existing 3D model or whether it’ll need some modification to make everything fit (and if it needs modifying – I don’t know yet how to do that).

So in the absence of a solid plan I’ve opted to get started by getting started. As I write this the 3D model is printing in the other room and @[email protected] tells me it has an hour to go. I don’t know that this will be a quick project because I expect to learn a lot as I go, but I will keep you all up to date on how I get on!

Blog

How to Create a Custom Google Now Command for Anything on Android

While I was waiting for the electronic components to arrive for my DIY Smart Home project, I had the idea of adding some voice control to our house.

Plenty of people have done this with the Amazon Echo, but thatā€™s not available in Canada yet. Google Home has now been announced of course I want one, but I donā€™t know when theyā€™re going to be available in Canada either.

After a quick google search I found the article Iā€™ve linked above about adding a custom google now command using Tasker on Android

ā€“ an app I already know and love. I set it up to trigger a call to the HomeAssistant API.

[youtube https://www.youtube.com/watch?v=HxMXYcE2Rzo?feature=oembed&enablejsapi=1&origin=https://safe.txmblr.com&wmode=opaque&w=540&h=405]

Boom.

How to Create a Custom Google Now Command for Anything on Android

Blog

NodeMCU, MQTT, IoT & Other Letters I Find Exciting

If youā€™ve been keeping up with my #SmartHomeĀ series (and if you havenā€™t, why not?) youā€™ll already know that I have plans to make more of my home ā€œsmartā€ using Home
Assistant
as the software that ties everything together, and some DIY NodeMCU-based hardware that Iā€™m going to build myself as a learning opportunity.

Another important piece of the puzzle, but one that I havenā€™t previously mentioned, is MQTT.

MQTT is ā€œa publish-subscribe-based lightweight messaging protocol for use on top of the TCP/IP protocol,ā€ at least according the slightly suspect grammar of the person that wrote the Wikipedia article about it.

image

I learned about MQTT at the same time I learned about Home Assistant, although I didnā€™t initially appreciate its power. Iā€™ve been using it from the start to enable Home Assistant to know where we are: our phones run an app called OwnTracks which publishes
location data to an MQTT ā€œbrokerā€ (server). Home Assistant subscribes to these updates, which means it immediately knows about it when our location changes.

I love this whole solution, not least because itā€™s very easy to run my own MQTT broker (Iā€™m running MosquittoĀ in a Docker container on my home server) and Iā€™m therefore entirely in control of our location data ā€“ itā€™s not being shared with the developer of some app or service I have no insight into.

This publish/subscribe model and the lightweight nature of MQTT makes it perfect for ā€œInternet of Thingsā€ (IoT) devices to communicate with each other, and when you add Home Assistant into the mix it gives me all the tools I need for any sensors I build
to feed their data into my smart home ecosystem, and for my smart home controller to feed commands to any devices.

Indeed, Iā€™ve already built my first little NodeMCU app that leverages the technology.

Iā€™ve ordered almost all the components I need for my upcoming hardware projects from China, and theyā€™re only just starting to arrive. Happily the NodeMCUs themselves were amongst the first shipments to land on my doorstep, so even though the only thing I can really do with them right now is programmatically turn their internal LED on and off, I have still been able to use this to start learning: Iā€™ve made it an internet controlled
LED.

[youtube https://www.youtube.com/watch?v=JLETpLMicYs?feature=oembed&enablejsapi=1&origin=https://safe.txmblr.com&wmode=opaque&w=540&h=304]

As promised, Iā€™m going to be sharing both the hardware and the software as I take this DIY Smart Home journey. There is no DIY hardware here, just the NodeMCU itself, but Iā€™ve published both the Arduino sketch and Home Assistant configuration Iā€™ve used for the video.

Enjoy!

Blog

Smart Home Adventures

Ever since I bought my own home nearly a year ago, Iā€™ve
become increasingly interested in making it smart.

Right off the bat, I feel like I should clarify what that
means to me. The ability to turn some lights on or off with an app is not
smart, in my opinion ā€“ the smart way of controlling lights is by flicking a
switch conveniently located in the room you wish to illuminate.

A smart home needs to be much more intelligent. Itā€™s about
automation. Itā€™s about the home being able to notify me if something is
happening that I need to know about. Itā€™s about being able to accomplish things
with minimal difficulty, not adding complexity and more steps.

Thatā€™s where off the shelf ā€œsmart homeā€ solutions really
started to fall down for me. I could spend hundreds or maybe even thousands of
dollars, for what? The ability to turn on my living room lights while Iā€™m still
at the office? Why would I ever need to do that?

Nevertheless, the lack (in my opinion) of a pre-packaged,
useful, holistic solution that accomplished my vision of what a ā€œsmart homeā€
should be didnā€™t deter me from tackling things bit by bit. It started with our
burglar alarm. It has internet connectivity which sends me alerts in the event
that something unexpected is happening, and lets me arm or disarm the system
from my phone ā€“ which I actually do find useful.

Next up was our thermostat. The one that was installed when
we bought the house was an old-fashioned one with a simple mercury switch
inside. You set the temperature, and that was it. We replaced that about a
month ago with something programmable (it doesnā€™t need to be as warm in here at
night as it does during the day; it doesnā€™t need to be as warm if nobodyā€™s
home), and I took the opportunity to get one with WiFi so I can set the
temperature remotely. Thatā€™s not useful in and of itself, but if you take that
functionality and look at it in the context of my wider vision then the
thermostat is certainly something Iā€™d like to be able to programmatically
control.

It was around this same time that I discovered home assistant, and now my dream is
starting to come alive.

image

Home Assistant is an open-source project that runs on a
variety of hardware (I was originally running it on a Raspberry Pi, and Iā€™ve
since switched to running it in a Docker
container on our home
server
). It has a ton of plugins
(ā€œcomponentsā€) that enable it to support a variety of products ā€“ including our
existing alarm, thermostat, streaming media players, and others (including,
somewhat ironically, the colour-changing lightbulbs we have in our family
room). It includes the ability to create scripts and automations, it uses our
cellphones to know our locations, and can send us push notifications.

My initial setup was all about notifications. If we both
leave the house but the burglar alarm isnā€™t set then it tells us (and provides
an easy way to fix the issue). If we leave one of the exterior doors open for
more than five minutes, it notifies us (or just one of us, if the other is
out). I also created a dashboard (that you may have seen in my last post) to display some of this stuff on a monitor in my office.

Since installing the thermostat Iā€™ve added more automation.
The time we go to bed isnā€™t always predictable, but when we do go to bed we set
the alarm. So, if itā€™s after 7pm and the alarm goes from disarmed to armed, the
thermostat gets put into night mode. If nobody is home then the temperature
gets gradually turned down based on how far away we are.

If nobody is home at dusk then it turns on some lights and
streams talk radio through the family room speakers to give the impression that
someone is.

This stuff meets my definition of smart, and Iā€™m barely
scratching the surface. The open nature of the platform not only means that Iā€™m
not tied to a particular vendor or technology, but also means that I can add on
to the system in a DIY way.

Which is exactly what Iā€™m going to do. Iā€™ve bought some NodeMCU microcontrollers which are
WiFi enabled, Arduino IDE-compatible
development boards designed to the basis for DIY electronics projects.

Watch this space, because over the coming months Iā€™ll be
connecting our doorbell, garage door and laundry appliances to Home Assistant.
Iā€™ll be learning as I go, and Iā€™ll share the hardware and software.

Blog

Smart Home Dashboard

[youtube https://www.youtube.com/watch?v=8N087dKoKno?feature=oembed&enablejsapi=1&origin=https://safe.txmblr.com&wmode=opaque&w=540&h=304]

Recently, I have been all about turning our home into a smart home. Thatā€™s mostly because Iā€™ve discovered Home Assistant: a little piece of software that runs (in my case) on a Raspberry Pi and pulls together data from all the sensors and smart devices you own.

Apart from a new WiFi thermostat that I was going to buy anyway I havenā€™t yet spent any money at all in my quest for this – Iā€™ve merely connected together the devices we already owned (Chromecasts; family room lights; our burglar alarm), added in some data available through various APIs (weather; internet speed; server status) and pulled location information from our phones using an app that publishes the information to my own server.

Anyway, now that I have all this information in one place I wanted an attractive way to display it in my office. Happily Iā€™d already bought a monitor with a built-in powered USB hub from a surplus equipment sale a while back, with this kind of project in mind.

So, my Friday afternoon project today became hooking up another Raspberry Pi to this monitor and crafting a HTML dashboard for it to display. Not everything works yet, but I think itā€™s pretty good for an afternoonā€™s work.

(Since I didnā€™t remove the clock from the frame when I shot the video, I canā€™t pretend this thing is quick to boot. I may have manipulated the video speed at a couple of points. But anyway).

Oh, and watch this space for some home-brew smart home devices, coming soon!