An API for the home

I live in a smart home. That should be known by now. But I also have a lot of information to play with.. Here's how!

· 2 min read
An API for the home
Photo by Douglas Lopes / Unsplash

I live in a smart home. That should be known by now. But it also gives me access to a lot of data coming from sensors and such.

I've always wanted to play with GraphQL in my home lab (I have a lot to do with it professionally...) and so I came up with the idea of writing an API for use at home.

This API should provide the following things:

  • Information about temperature and humidity
  • My current Spotify track
  • More gimmicks

Other gimmicks include things like the current game on my PS5 or whether I'm standing or sitting at my desk.

The search for a framework

I came across Apollo pretty quickly.
With Apollo, a GraphQL server can be set up and put into operation very quickly.

So I could (and had to) improve my knowledge of JavaScript, since Apollo's implementation is based on Nodejs.

Home Assistant + Apollo = ❤

With Axios, all the necessary information from the sensors can be pulled from Home Assistant thanks to the included REST API from HA. This data is then adapted to the previously defined schema for GraphQL using a resolver and you're ready to go!

Everything in one really super easy and quick to implement..

Basic Query for some sensor data

But I also wanted to implement other gimmicks like the Spotify track I’m currently listening to:

Or the status of my desk:

These are just a few of the little gimmicks I've implemented so far. I'm sure I'll have more ideas in the future.

What do you think? Would you want to build an API for your own home? If so: Why and what do you want to implement?