The brains behind my home automation is a tool called Home Assistant, which runs off a single Raspberry Pi in my cupboard. Home Assistant is an open source home automation platform, that acts as a hub between all your intelligent devices. I started with Home Assistant roughly a year ago, and can honestly say it has progressed in leaps and bounds. Things that would take hours to code a year ago, are one-liners now, which tells you that it is popular and being constantly updated (this is a good thing, although sometimes frustrating).

Hass.io

Hass.io is Home Assistant’s self-contained installation, that really takes all of the guess-work (and leg-work) out of installing Home Assistant. It is a great place to get started, with all sorts of add-ons available at the click of a button. I used Hass.io to familiarise myself with the platform, but found it a little lacking in that it was fairly restricted and if something broke, I could not easily go in and find the cause. The breaking point for me on Hass.io, was that I could not install a certificate for SSL, which meant I would not be opening up this gateway to the internet – which takes away a lot of the convenience of a Home Automation platform.

Enter Hassbian

Hassbian is Home Assistant’s software built on top of a pre-made Raspbian operating system. This gives you control over the operating system, as well as complete control over Home Assistant. This has taken a little more Linux know-how to get going, but it really has been a breeze. When you have complete control, it’s much easier to diagnose and fix errors – such as battling to install a certificate.

How does Home Assistant communicate?

There are many different ways, but one of the primary methods is a protocol called Mosquitto, MQTT for short. MQTT is a machine-to-machine communication protocol, designed to be incredibly lightweight and work on IoT devices. It relies on a broker – a server such as Hassbian – to wait for messages to be published to it. Each message gets published to what is known as a topic, and other devices or services can subscribe to these topics.

As an example, my living room light switch when flipped to “on” will publish the same status to the broker’s “livingroomlight” topic. Home Assistant, which is subscribed to all the topics in the house – including the living room light – would suddenly see that the living room light is now on, and would update itself accordingly or trigger some sort of rule.

But what is the point of this all?

My cousin recently asked me exactly this. Sure, I can see the status of all sorts of things, and that’s cool, but really, what is the point? The point comes in with the Automation side of Home Assistant. Remember, Home Assistant is a hub, a central control point linking all sorts of devices to each other. That MQTT protocol is completely device agnostic, and ultimately links all sorts of previously disconnected devices together, with a complete workflow engine of conditions, triggers, and actions. THIS is where the power comes in.

My alarm system is able to communicate on MQTT, as are my light switches. With Home Assistant, I can turn my lights into motion detection lights and save on electricity. It all works on triggers, conditions, and actions. Basically, I would write a rule stating that:

  • IF (condition)
    • the alarm is currently disarmed
  • AND (condition)
    • it is after sundown and before sunrise
  • AND (trigger)
    • motion is detected in the lounge
  • THEN (action)
    • turn on the lounge lights
  • THEN (action)
    • wait 5 minutes
  • IF (condition)
    • there is no motion for 5 minutes
  • THEN (action)
    • turn off the lounge lights

So now, two completely separate systems in my house are now talking to each other as though they are one. Think of the possibilities! One of the best automations we have is detecting when our mobile phones are in range of the Wifi, and then turning on the house lights in sequence when we arrive home after dark.

That, and I can now control all my lights, alarm system, home theatre and a bunch of other devices directly from my mobile phone.

How do I start?

Head down to any number of electronics stores and pick yourself up a Raspberry Pi, power supply, and SD Card. I’m based in South Africa, so I use Micro Robotics and Communica for most of my purchases. Those further afield would likely have better luck with RS Electronics. Once you have your Pi, head on over to Home Assistant and get yourself Hass.io. If you’re familiar with Linux, perhaps jump straight into Hassbian. Load this on to your SD card following their instructions, and you’re on your way!

Once installed, I’d suggest you follow their “Configuring Home Assistant” guides. Hass.io is definitely easier for someone just venturing into the world of Linux and Home Automation. Home Assistant is configured using YAML files, a “human friendly” format for entering data for all programming languages. Brace yourself though, it is incredibly sticky on the formatting you use! Over the coming weeks and months, I’ll publish quick (and not so quick) tutorials for configuring your Home Assistant server in various scenarios and use cases.

I look forward to helping you on your way!

Share This

Share this post with your friends!