GB
  
You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
11 MIN READ TIME

HOME ASSISTANT

Build a smart-home data application

Matt Holder investigates how to take data from an API and display it in a GUI for fun and possibly profit!

Credit: www.home-assistant.io

Part three!

Don’t miss previous issues, order on page 64!

OUR EXPERT

Matt Holder is an IT professional of 15 years, Linux user for over 20 years, user of plenty of home automation gear and selfprofessed geek.

QUICK TIP

The complete code listing can be downloaded from https://github.com/mattmole/LXF308-309API-GUI.

We’re putting the finishing touches to our smart-home data application. Our aim is to pull data from the Home Assistant API and then render it on screen in a GUI. We’ve split the program into two and in the first article we wrote the library that interacts with the API. Last month, we started writing the GUI application and we covered the entity selection window. This month, we will write the rest of the app, which consists of the configuration and main windows. As part of this article, we will be calling the API communication library, which will perform the actual data requests from the API.

Before we start coding again, let’s have a look at Home Assistant. It is one of the most popular open source projects on GitHub and provides a way of linking together home automation equipment from different manufacturers, which potentially all use different protocols. Home Assistant’s aim is to keep as much data as possible within the internal network, but it can interact with many cloud services as well. Data gathered by Home Assistant is collected in what are called entities, and a history of entities is automatically kept and can be viewed from the web interface. Home Assistant provides an API that can be used to extract a list of entities within the system as well as the state of any entity. This app will enable you to select a number of entities to display and if possible a trend line will be displayed. The API is also capable of more functionality, but this is largely outside of the scope of this article.

Let’s make a start by considering the configuration window. The code samples shown are only partial so that we can cover as many concepts as possible. The screenshot (opposite page) shows the configuration window, which will enable you to extrapolate the code shown with what is on the window itself.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
January 2024
VIEW IN STORE

Other Articles in this Issue


WELCOME
MEET THE TEAM
We’re trying to entice people to learn to
Fresh start
As we dive into 2024 and a whole
REGULARS AT A GLANCE
Newsdesk
THIS ISSUE: Valve console Steams ahead Foundations laid for HPSF Canonical cloud creation
High Performance Software Foundation announced
The HPSF is to inspire HPC innovation and “make life easier for high performance software developers”.
Canonical launches MicroCloud
The Ubuntu publisher releases new cloud software.
WHAT’S IN A NAME?
Italo Vignoli is one of the founders of
CLOSING THE DOOR
Joe Brockmeier is head of community, Percona. Another
Blender 4.0 released
Latest stable version has overhauled UI and improved support for OneAPI.
Foundation gets €1 million from Germany
Gnome recognised as public interest infrastructure.
Itanium heading for scrapheap
The end of an era: Will the Linux kernel drop support for ia64 architecture?
Distro watch
What’s behind the free software sofa?
DRIVER’S TEST
Faith Ekstrand is an engineering fellow at Collabora.
GETTING TOGETHER
Jon Masters is a kernel hacker who’s been
Kernel Watch
Jon Masters keeps up with all the latest happenings in the Linux kernel, so you don’t have to.
ONGOING DE VELOPMENT
There continue to be significant developments on the
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
WRITE TO US Do you have a burning
HotPicks
THE BEST NEW OPEN SOURCE SOFT WARE ON THE PL ANET
REVIEWS
Intel Core i9 14900K
Fast, powerful and a bit boring is not how to describe Jacob Ridley…
OSGeoLive 16.0
Uncharted no more – Nate Drake maps out the array of geospatial tools on offer in the specialist distro OSGeoLive.
GhostBSD 23.10.1
Roll over Slimer. Nate Drake explores the latest GhostBSD and finds that, like Casper, it’s extremely friendly and easy to manage.
Kubuntu 23.10
Nate Drake explores the lavish new Plasma desktop in the latest Kubuntu. Is this the greatest KDE-based distro to date?
Counter-Strike 2
It’s CS:GO Jim, but not as we know it, says Rich Stanton, as he takes the long-standing esport stalwart’s successor for a spin.
ROUNDUP
Live distributions
Michael Reed checks out five distros that you could carry around on your keychain to give you Linux goodness at a moment’s notice.
LEARN LINUX!
Finally had enough of your Windows PC? Nick Peers reveals how to fully road-test – then switch to – a user-friendly Linux distro.
Pi USER
Arm buys a slice of Pi
The deal effectively cements the Raspberry Pi to the Arm ISA for an undisclosed sum.
Pi OS Bookworm
Les Pounder has a Raspberry Pi 5 and isn’t afraid to use it, now that he has the latest Raspberry Pi OS.
Creality K1 Max
A big fan of fancy, Denise Bertacchi has taken to the K1’s bigger brother.
Take your Pi 5 to the next level!
Les Pounder has got his hands on a Raspberry Pi 5 and wants to show you how to get the best from it.
IN DEPTH
Tall Tails
Nate Drake explores how to configure the latest version of Tails for maximum security and convenience.
TUTORIALS
Safeguard your secrets
Shashank Sharma gets a taste for 007’s life by reading fiction and occasionally sending encrypted messages to his unsuspecting brother.
Dump your paper docs with perfect OCR
Nick Peers reveals how to extract editable text from images and printed materials with the help of optical character recognition software.
WordPress security, events and users
Michael Reed concludes his overview of setting up and maintaining a WordPress site with some finishing touches and a look at plugins.
Relive your BBC Basic days!
Turn your home system into a BBC Micro by following David Bolton’s advice to download BBC Basic and write programs just like it’s 1982.
Make your own pointand-click adventure
Nate Drake invites you to relive the glory days of Scumm-style point-and-click adventure games by creating your very own.
ADMINISTERIA
Massively improve your SSH login security
Passwords are so last century proclaims Stuart Burns! Using public keys and a couple of tweaks makes for a far more secure login.
Learning the way of the Docker
Docker is designed for an easy sysadmin life. Here are some top tips for using it.
Oxylabs
Mayank Sharma finds this proxy service to be a breath of fresh air.
Private Internet Access
A high-value VPN with a pile of interesting features that’s keeping the nefarious Mike Williams out of trouble.
No Ethernet, I expect you to die!
More stubborn than an anachronistic spy stereotype and just as reliable, Darien GrahamSmith uncrosses the network twisted pair.
CODING ACADEMY
Write a Linux shell from scratch
Never one to shy away from the difficult, Ferenc Deak takes us by the hand and helps us code a shell – from scratch.
Chat
X
Pocketmags Support