Control home automation hardware with Home Assistant
Group Dynamics
To keep track of your own sensors, lamps, and other devices, it is a good idea to sort them into groups. The group structure will add convenience to the web interface. Aspiring automation engineers will want to extend the configuration.yaml
file; add the lines in Listing 2 and then restart Home Assistant.
Listing 2
configuration.yaml
The names of your own devices (e.g., sensor.temperature_bedroom
in Listing 2) appear in the States view below Developer Tools. The first part of the name indicates the device type, the second part defines a configurable, individual identifier for the device.
Let There Be Light!
For the first few attempts with Home Assistant, you'll be content to control individual devices with the browser. But in the long run, you won't want to search for your tablet PC (Figure 3) just to switch the light on.
Home Assistant come with useful automation features for hands-off operation. In the simplest scenario, a sensor can detect an event that triggers an action. For example, the default configuration provides a sensor that measures the presence of sunlight. On this basis, the automation rule in Listing 3 regulates the lighting depending on the external brightness.
Listing 3
Brightness Sensor
The trigger
attribute indicates which event this rule should trigger. Optionally, the condition
attribute lets the developer specify which other conditions must be met for the rule to apply. The action
attribute describes one or more actions that Home Assistant will implement.
If you don't want to wait until the sun goes down, click on the name to activate automation rules in the browser. Manual activation is useful in the testing phase, when you're checking to see whether the action is working properly. A built-in logbook tracks when and why Home Assistant performs actions. The Home Assistant user interface lets you temporarily disable individual rules. For instance, you could disable a rule that started the furnace on a day when no one is home (Figure 4).
On request, Home Assistant combines different actions to create scenes – for example, to control several lights at once. Scenes are especially helpful with automation, because automation rules can only hold a single action.
Location-Based Automation Rules
Another central feature of Home Assistant is the ability to define geographic zones (e.g., home
, work
). The software triggers events as soon as particular users enter or leave these zones. The administrator defines the zones using latitude and longitude, as well as a radius (Listing 4).
Listing 4
Defining Geographic Zones
Home Assistant accesses localization services such as Find my iPhone [5] and GPS Logger [6] to recognize users who enter the defined zone. Admins can trigger actions based on the leave
and enter
events when someone exits or enters the space. The example in Listing 5 shows how to switch off the lighting automatically when a specific device – in this example, a mobile phone – leaves the home
zone. On the summary page, the administrator can keep track of whether someone is in a specific zone in OpenStreetMap (Figure 5). The log will reveal when Home Assistant detects transitions between the individual zones.
Listing 5
Zone Alarm
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.