<article-heading title="Offline-first home automation" is-published="true" /> <p> This is a write-up of an presentation I gave at an internal <a href="https://thoughtworks.com">ThoughtWorks</a> event in 2019, about why and how to set up an offline-first home automation system. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-1.svg" class="slide" alt="" /> </figure> </section> <p class="article-description"> In this presentation, we will look at a typical home automation solution using popular smart home products, and compare it to a more privacy-centric approach using cheap offline-first solutions. </p> <h2>The simple approach</h2> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-2.svg" class="slide" alt="" /> </figure> </section> <p> Let’s start with a typical home network. Your devices live inside this network, and some sort of modem and router separates your network from the internet. You’re using WiFi on the inside to connect your devices. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-3.svg" class="slide" alt="" /> </figure> </section> <p> You’ll want a device that acts as your Smart Home hub, like a Google Home or Amazon Echo Dot. </p><p> Most off-the-shelf Smart Home hubs also double as voice assistants. Google Home has Google Assistant and Amazon Echo has Alexa. Choose one or more from your favourite mega-corporation. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-4.svg" class="slide" alt="" /> </figure> </section> <p> Every time you use this hub, your voice will be recorded and sent off into the cloud for speech recognition and natural language processing to understand your intent. The cloud will respond with an action or set of actions for your hub to perform, as well as spoken speech to confirm the action. </p><p> With the smart home hub in place, you’re ready to hook up some IoT smart home devices to your local network. There are different ways to get some devices online. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-7.svg" class="slide" alt="" /> </figure> </section> <p> This is a good opportunity to talk about different wireless hardware protocols for IoT. </p> <p> Here is how protocols like Zigbee and Z-Wave operate as alternative wireless hardware communication protocols to WiFi and Bluetooth. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-8.svg" class="slide" alt="" /> </figure> </section> <p> Let’s add some smart lighting. </p> <p> Sengled provide a starter kit that comes with two Zigbee bulbs and a Zigbee hub. The bulbs can work directly with a Zigbee hub if you have one, or the hub helps you get started to interact with the bulbs online. Smart Lights don’t need to be Zigbee or Z-Wave. For example, LIFX lights use WiFi. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-9.svg" class="slide" alt="" /> </figure> </section> <p> The gotcha with this hub is that even if you interact with the light bulbs using a local connection, the hub will still call home to report their state to a remote server when you use their app. </p> <h2>The twist</h2> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-10.svg" class="slide" alt="" /> </figure> </section> <p> Here’s an article from 2018 where Gizmodo reporter Kashmir Hill and Surya Mattu experimented with listening to device chatter on Kashmir's home network. </p> <ul> <li>They set up a device to get a copy of all of the IoT traffic that would be sent out to the cloud</li> <li>Thousands of packets of data per day, sometimes up to 12,000.</li> <li>Metadata from Smart TVs even identifies what is being watched. Even encrypted traffic still identifies which servers are involved.</li> <li>Devices still communicate with the cloud when the house is empty. One day, the coffee machine made 4,500 calls to its manufacturer's remote server. The server was down that day, so it just kept trying.</li> </ul> <p> If you’d like to find out more, <a href="https://www.ted.com/talks/kashmir_hill_and_surya_mattu_what_your_smart_devices_know_and_share_about_you">their talk is on TED.com</a>. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-11.svg" class="slide" alt="" /> </figure> </section> <p> </p> <h2>The alternative</h2> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-12.svg" class="slide" alt="" /> </figure> </section> <p> Let’s go back to the start. </p><p> This time around, you’ll want to start with your own smart home hub, something that runs on your own hardware on your own premises. </p><p> There are a few solutions around. Home Assistant, Open HAB and Domoticz are some popular ones. I’m going to focus on Home Assistant for now, running on a Raspberry Pi 3. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-13.svg" class="slide" alt="" /> </figure> </section> <p> Home Assistant is a smart home service that includes a web UI dashboard, providing the controls and readouts to control IoT devices in one place. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-14.svg" class="slide" alt="" /> </figure> </section> <p> Alright. So we put the Raspberry Pi on the network, now we can access the Home Assistant dashboard locally. If we set up port forwarding properly, we can access the dashboard from outside of the network. This time, it’s on our own terms. Nothing gets stored on the cloud. </p><p> Next, we want to integrate with the Zigbee light bulbs without using a custom hub. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-15.svg" class="slide" alt="" /> </figure> </section> <p> This beastie will help with that. This is a Zigbee CC2530 dongle, it can be programmed to act as a Zigbee hub and relay messages back and forth to Home Assistant. </p><p> This puts control back into our hands, preventing 3rd party hubs from phoning home every time our devices changes their state. For example, now you can run a Zigbee network inside a warehouse and direct all of the activity towards a Home Assistant instance. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-16.svg" class="slide" alt="" /> </figure> </section> <p> Now we can interact with the Home Assistant dashboard to control IoT devices over Zigbee. But we’re not finished yet, we still want to add a voice assistant to help us control devices without diving for our phone. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-17.svg" class="slide" alt="" /> </figure> </section> <p> Mycroft is an offline-first voice-controlled assistant that can be deployed on a variety of hardware. While a Mycroft agent must have its skills trained through the Mycroft website, it can be downloaded and then run completely offline on the device. </p><p> We can hook up a USB microphone to the Raspberry Pi and be good to go. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-18.svg" class="slide" alt="" /> </figure> </section> <p> So here’s where we end up. Interact with the dashboard locally or remotely to interact with devices, or use the voice assistant to act on commands that it understands. </p><p> All the while, none of the devices need to communicate with the internet to operate. You can add extra firewall rules to your router to prevent devices from contacting the cloud without your permission, or even disconnect your router from the internet, without stopping the smart home from operating. </p> <section class="hero"> <figure> <img src="/content/articles/offline-first-home-automation/slide-19.svg" class="slide" alt="" /> </figure> </section> <p> In summary, the items on the left are easy to set up, but you end up leaking information to whoever knows how to get it. The items on the right take more time to set up, but it makes you think more critically about what you set up in your “smart home” and why. If you take the time to learn more about offline-first home automation solutions, you will learn more about how to protect your and your family's privacy. </p> <p> This article is based on a presentation I gave at an internal <a href="https://thoughtworks.com">ThoughtWorks</a> event in 2019. If you have any feedback or questions related to this article, please reply to <a href="https://twitter.com/TassSinclair/status/1282852025890336768">my post on Twitter</a>. </p>