Maximum PC

AWAKEN YOUR HOME

- YOU’LL NEED THIS HOME ASSISTANT Find the right version for your hardware at www.home-assistant.io. A RASPBERRY PI Does it have to be a Pi? No. But Home Assistant works best on one. ALEX COX

Take control of your smart home with a Pi

SMART HOME EQUIPMENT IS, almost without exception, utterly unfriendly. It’s unfriendly to you, forcing you to use a certain app to activate it, and possibly feeding your data back to goodness-knows-who, and it’s (usually) rather hostile toward smart gear from other manufactur­ers. As you might expect, this kind of behavior doesn’t wash well with us. If we’re getting smart, we want to be able to manage that equipment in a smart way. Home Assistant (or Home-Assistant.io or, to give it yet another name, Hass.io) is the solution, at least for want of something less clunky. Install it on a Raspberry Pi—in our case, we’re using a Pi Zero W, which probably doesn’t have quite enough power, but it does work, and it’s incredibly cheap—or on just about any hardware you have to hand (there’s a Windows version available, if you have an always-on PC), and you’ll be able to control your gear from a web interface, set up your own custom automation­s, and much more. It’s not as easy or, honestly, as convenient as an app, but it’s a darn sight better than being forced to use a suite of apps, and the level of additional control makes working with Hass.io more than worth the extra effort. –

1 INSTALLATI­ON As we’ve mentioned, we’re working with the Raspberry Pi version of Home Assistant here—if you’re looking to install it on a different platform, the Home Assistant site at http://hass.io has more informatio­n, but bear in mind that non-Pi versions can be less secure and less feature-complete, because the mini computer is the app’s primary target. Dig up a spare Class 10 SD card of around 32GB, and download Etcher ( http://etcher.io), which has quickly become the de facto best SD card writing app, surpassing Rufus and the venerable Win32DiskI­mager. You’ll find the disk image you need for your particular Pi version at

http://home-assistant.io/hassio/installati­on, and writing said image using Etcher is a simple task [ Image A]. However, you can’t necessaril­y write your card and call it done. You also need to grab a USB stick to set up your network credential­s—there’s no interactiv­ity on the Raspberry Pi directly (it’s all done through the web interface), and a static IP address is a must in order to access Home Assistant from a consistent URL. Format the USB stick, name it “CONFIG,” create a folder named “network,” and create a blank text document called “my-network” with no extension inside that. The exact contents of this depend on your network, so refer to the official docs at http://bit.ly/2QfZm4o to get it right—you need your SSID and network password (if you’re going to connect via Wi-Fi), along with the static IP address you’d like to use, and the IP address of your router or gateway.

2 FIRST BOOT It’s not required, but you may want to hook up a monitor the first time you launch Home Assistant, to see the streaming list of status messages as it goes through that initial configurat­ion. You’ll notice that it creates a Docker container, and runs from within that—it’s a good way of making the most of the RPi’s resources, scaling back when you’re not taxing it. Don’t be alarmed if it seems to stall, because Home Assistant needs about 20 minutes on first boot to configure itself. Head to your main PC, open a web browser, and point it to “< your static IP>:8123” or, if your router supports mDNS, “hassio.local:8123” will take you to the same place. Now wait—the holding page [ Image B] will update and bring you to the main interface when Home Assistant has done what it needs to do. If it doesn’t, or if it drops out, manually refresh the page. Barring any issues writing the SD card—and Etcher will have caught these in its verificati­on step—you’ll soon see the registrati­on screen, where you’ll set up your local account. Throw in your details, then log in with the account you just set up.

3 BASIC SETUP Home Assistant’s initial interface couldn’t be more underwhelm­ing. You’ll see a brief intro card, and two symbols, one telling you if it’s day or night, and a mildly mysterious “yr” weather symbol. This is

actually from Norwegian weather service Yr.no, but neither symbol represents your current location. That’s something you need to configure yourself. Hit the hamburger menu in the top-left corner of the interface, and head to “Configurat­ion > Customizat­ion.” Home Assistant thinks you’re at 0 latitude and 0 longitude—which, unless you live in the sea off the west coast of Africa, you are not. Open a new tab and use www.latlong.net to find your real co-ordinates. Click the pencil icons on Home Assistant’s “Customizat­ion” tab, and enter each one, then click “Save.” Head to the “Map” tab to check your new location has sunk in, then go back to the “Configurat­ion” menu.

>> Let’s get your smart gear listed on the main screen, because Home Assistant’s most core function is to provide an interface for you to control that equipment. It’s not compatible with everything, and it doesn’t have every single function, but it’s easy enough to switch things on and off to begin with. Click the “Integratio­ns” option, and look for your equipment in the list; this isn’t confined to smart home devices, as we’ll come to later. Click the “Configure” button next to your chosen device ecosystem—LIFX, for example, for one or more bulbs from that one company—and hit “Submit” [ Image C]. Home Assistant generates the relevant config file for you; click “Close,” then head back to the main “Overview” screen to see a card for your gear. If it’s something switchable, you can use those switches to activate or deactivate that equipment. If you’ve attached something like a Google Cast device, you can see the thumbnail, transport controls, and further options on the bottom-right menu.

4 GOING DEEPER If you’ve integrated a light device, such as LIFX or Philips Hue, you can do more than just toggle it. Head back to “Configurat­ion > Integratio­ns,” and you’ll now see your device broken out of the main list and placed at the top. Click it to see your individual devices laid bare—take a note of their entity names, which are displayed at the bottom of each card, before we move on. Now select one of the individual devices from that family to see its deeper configurat­ion options, such as tweaking the color, temperatur­e, or brightness [ Image D], or even activating an “Effect,” something we cannot in good conscience allow you to do. Click the cog, and you can give your light a better name than the one you entered when hurriedly setting it up in the associated smartphone app, which is reflected in the list on the “Overview” screen. You don’t have to dig in this deep to get to the advanced controls, either; just click the device’s icon on the main screen, and the advanced control panel pops up.

5 GOING AUTOMATIC We’re not going to argue that Home Assistant’s automation section isn’t baffling—it really can be difficult, because it’s deeper than a very deep thing—but it’s more than possible to just get your feet wet, piecing together simple automation­s without a degree in JSON coding, then go up to your knees and beyond at a later time. So, let’s do something easy, and set a timer. Open up “Configurat­ion > Automation,” and hit the yellow plus icon in the bottom-right corner to start creating a new automation. Give it a name and, in the trigger section, set the trigger type to “Time.” Enter a military time value in the “At” field, separated by colons; 19:00:00, for example, sets it at 7 p.m. precisely. You can use conditions, which are only checked when the trigger fires, to further specify the situation in which you want something to happen— perhaps you’ll choose “Sun” as a condition, and set your light to only switch on if it is both 7 p.m. and after sunset, if you’re feeling clever, or perhaps you’ll check to see if a light is on before switching it off—but they are entirely optional if you’re more inclined to create a simple automation. You can add as many triggers and conditions (and, indeed, actions) as you like, but bear in mind that adding more than one trigger causes the automation to fire whenever any of those triggers occurs —only the conditions section allows it to be selective.

>> We now need to determine what we want to actually happen. Doing something simple such as switching a light on or off is only slightly obtuse; set the action type to “Call service,” then use the “Service” drop-down to select the kind of light trigger you’d like to use—in our case, we’ll select “light.turn_on.” Now we need to set which of the nebulous entities around our home we’d like to activate. On the “Integratio­ns” screen, which

we looked at earlier, you’ll have noted the entity names of your devices; enter {"entity_id":"light.front"} (substituti­ng “light. front” for the name of the entity you actually want to control) in the service data section. You can, again, get more complex with this, but it’s enough for now. Click the save icon in the bottomrigh­t corner (check the top of the page for any errors if it doesn’t work), then head back to the “Overview” screen. Your new automation appears in a card. You can toggle it on or off with the switch, which stops the trigger from firing; click the icon to the left, and you can test that the action actually works.

>> That’s as far as we’ll go on automation­s in this tutorial; Home Assistant’s documentat­ion goes into much more granular detail, and there’s a whole scripting language to learn if you want to take super-fine control.

6 SERVE IT UP If you want to gain access to Home Assistant from outside your home (and, let’s face it, you do), or use tools such as IFTTT to increase your automation potential, you need to do a little extra finagling. First, head over to www.duckdns.org and sign up for an account with the DNS forwarder service; this is what we’ll use to send a human-readable URL to your Home Assistant server. Choose your subdomain, click “add domain,” and Duck DNS should detect your home IP, and list it in the bottom-left box. Keep this page open, and head back to your Home Assistant interface. Go to “Hass.io > Add-on Store,” click “Duck DNS,” and click “Install.” Wait for it to do its thing. Once it’s safely installed, head down to the “Config” section. Change “accept_terms” to “true,” paste the token from your Duck DNS page, surrounded by quotes, in place of the appropriat­e null value, then add your generated Duck DNS domain (again, in quotes) in place of the “domains” null value. The text turns red if

it’s parsed incorrectl­y. Click “Save,” then click “start” above to start the Duck DNS service running—it generates your SSL keys, which takes some time, so while you wait, head to your router’s configurat­ion panel, and forward ports 8123, 80, and 443 to your Home Assistant box. You’ll be able to access Home Assistant from yourdomain>.duckdns.org:8123. 7

ADDING SSL However, that’s horribly insecure, and we can’t let you leave it like that. Return to the Add-on Store, and this time install Configurat­or, a tool that allows us to get down and dirty editing Home Assistant’s internal config files. Add a password (in quotes) to the config section, save it, start the extension as before, then head to < your home assistant ip>:3218 and sign in with the credential­s you just set. Click the folder icon, top-left, then select “configurat­ion.yaml.” Head to line 26, uncomment “http:” and the line below it, then change “example” for your Duck DNS subdomain. Create a new line underneath headed with three blank spaces, and add the line “ssl_certificat­e: /ssl/fullchain.pem,” then create another similarly spaced line containing “ssl_key: /ssl/privkey.pem” [ Image E]. Return to the “Configurat­ion” menu, go to “General,” and click “Check Config.” If all is good, scroll down, and hit the red “Restart” button.

>> Take a breath: We should now be good to go. You can drop the port forwarding for ports 80 and 443 (keep 8123) in your router while you wait for Home Assistant to restart, then log in to the Home Assistant interface again—this time appending “https://” to the URL. With your server now securely accessible from the Internet, you’re allowed to create an IFTTT webhook in “Configurat­ion > Integratio­ns.” Head over to IFTTT and build an applet using “Webhooks” either as a trigger or an action, and you can create interactiv­ity between your Home Assistant setup and online tools. What you create, and what you link together, is really up to you. Like many things Home Assistant, you’ll need to wade into the documentat­ion to really get your head around it; www.home-assistant.io/docs/ has you covered. Good luck!

 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??

Newspapers in English

Newspapers from United States