Home Assistant, InfluxDB & Grafana


For some time now I’ve been using Home Assistant, there is some really great designs and inspiration in the community, mine though… It’s just thrown on one of my many pi’s in the rack at the back of my office.

Within here I’m using a range of integrations, it all started with a simple dashboard to control my Philips hue / IKEA Tradfri bulbs around the house, from there it’s grown a lot, but kept the basic theme.

Home Assistant Dashboard

Now though, one my main usages for home assistant is to track the temperature around the house with 7 temperature nodes scattered around each room now hosted on Grafana, shown below:

House enviroment grafana dashboard

Basic overview

I tried going down the DIY route to start with and looked into using esp8266 mode mcu’s and a DHT22/AM2302 module, then I priced it all up with a battery to make it “mobile” but… When you compare the price of these xiomi all in one units it was a no brainer to go with these.

My first sensors were the lLYWSDCGQ temperature and humidity sensors but with these now mostly discontinued throughout most online retail stores like aliexpress and banggood, I had to upgrade them to the latest LYWSD03MMC sensors… These are talking back to a esp32 module board, flashed with esphome. Now flashed and talking to the LYWSD03MMC sensors these report back through my MQTTbroker which is hosted within home assistant it self as one of my components / integrations.

There are many tutorials online on how to get these flashed and added into home assistant like here.

This isn’t going to a step by step article, but some quick notes on how to get it added into Grafana, more for myself to re-deploy later if needed or to help you if needed at all.

But firstly, what is time series data?

Before we get started not sure what time series data is? There is a great article here that explains it really well. but below are its main advantages and why I am using it here:

  • Incredibly small memory and CPU requirements compared to Elastic Search. Also I think its good to point out that InfluxDB runs great on a low power cheap and robust Raspberry Pi.
  • It works great with dashboard suites like Grafana, using Grafana you can create great dashboards and monitoring platforms.
  • InfluxDB can work with their native Telegraf agent, Telegraf is capable of pulling in data with over 200+ plugins.

Setting up the InfluxDB back end

We need somewhere to put the data first before grafana can see this, for this I’m using an InfluxDB docker hosted on my Unraid “Nas” stack. Influxdb is great with time series data with a huge range of different kinds of inputs injected into it through the use of the telegraf plugin (more on that in a later post).

I span up a InfluxDB docker container on my Unraid box.

Once that’s up and running, go to the terminal and run the below:

docker exec -it Influxdb bash

After youv’e dropped into the influx terminal, simply use


Next we will need to create a database

CREATE DATABASE "envirologs"

Once you have created your database you can see that it’s been created correctly by using:


All being well you should be able to see your new database.

Setting up Grafana

Im no expert in this, but this is the brief notes on setting up grafana…

Setting up Grafana in unraid is pretty straight forward, as simple choosing your host port for the webUI and change your admin password to the container settings.

Once it’s span up and logged in, within the home screen click on Add data source and select InfluxDB. Give your datasource a name, here I used “enviromental data”. add the URL to you InfluxDB instance then enter the database to use (envirolog). click test and save and your done.

Sending data to InfluxDB with Node-Red

As previsouly mentioned my MQTT broker sits within my homeassistant instance. So I thought it would be easier to ship my data out from here as a “centeral point” using Node-Red.

Node-RED is a flow-based development tool for visual programming which can be added to home assistant as a integration / add-on.

Within Node-Red I only needed 3 nodes, a Big timer, Current State and a InfluxDB Out node. This could not of been easier as shown below:

Node-Red configuration

Each of these nodes are configured as shown below:

Big Timer node configuration

The big timer is very straight forward and I havn’t changed this default configuration at all, just dropped it in for the node selection window and then connected it up.

Current State Node Configuration

Current state node needs a little configuration, set its’s name, then in the default state you will need to select your Home Assistant server for data collection. Then add in your sensors with it’s entity ID. In the next section that needs to change is “if state” leave the “is” but next to this click the dropdown and select 09 then state type of “number” this will stop sending “unavailable” states to your database when the batteries die within the sensors after some time.

Influxdb Out Node Configuration

Next up, we will need to configure the InfluxDB Out Node, set the name of which node this is, then we need to set up the Server properties, this will be the connection information for your InfluxDB stack, my configuration of this can be seen below, but we need to set the name, the version of the influxdb you are using, the URL (IP) of your InfluxDB instance along with it’s port number, then if you are using any credentials, if so then you will need to input the Username and Password for this.

InfluxDB server connection information

Verifying configuration

After we have set the connection information we will need to input the database to use, if you recall from earlier when creating my database within my docker container, I called this “envirologs” so this is used here, next up we need to set the “measurements”. Measurements are used in order to segregate your datasets and define what each input source relates to. As you can see here I just referenced this to where my node was going to be used (“front room temp”)

Once this is set, you can now save and deploy that to your Node-Red flow.
This will now be pushing the temperature of the Front Room node through Node-Red then on to the InfluxDB. we can now check the measurements that have been sent over to InfluxDB as shown below:

Listing available databases

Before we can see our measurements, we have to use the required database, Using the “show databases” command we can see what databases are available within InfluxDB. Within here we can see the “envirologs” database setup earlier amongst some others that I shall try get a blog post on soon. Now we can see the databases next up we need “use envirologs” to switch to use that database. Then “show measurements” which will give you the below:

List of available measurements within envirologs

Configuring Grafana

As you can see, I have this spread over the whole house and there is already quite a few measurements within the envirologs database. All you have to do here is just replicate the above steps within Node-Red for your other sensors and connect to the same big timer node.

Within Grafana, create a new dashboard and then within here, click “add a new row” then “add an empty panel” this will bring up a new panel. First you will want to select the datasource configured earlier, for me it’s “envirologs” then select a measurement from within this datasource and finally choose your interval, for mine it was using a 1 minute interval, this can be seen below:

Grafana panel configuration

All being well you should then have a great looking line chart like below:

Average house temperature graph

You can chain these queries together to make a single pane of glass with multiple different measurements from InfluxDB as shown below:

Multiple measurements within one pane of glass

That’s pretty much it, if you need any further help or questions, be sure to reach out to me on twitter and i’ll try help as good as I can, if I can’t then I might know someone who could.

Thanks for reading, hope you enjoyed it, if you have any feedback, let me know!

When im using a Pi, I always use them headless (without a monitor attached) there is a range uses I do this for, as they are mainly running as servers for some sort of services I need at the time.

With the new PI 4 out now and a one landing on my desk this morning (Day after launch 25/6/19), I thought I would update a guide for refrence later. Not only for my self but also anyone else that would need it.

The new Raspberry pi 4 along with the Pi 3 and Zero boards comes with an on board wifi chip. because of that, you are able to use it without plugging it in to a Ethernet cable making you only needing one cable (Power) in this case 1 x USB C.

Please note, this guide is using the Raspbian Buster lite image, some parts of this guide may work on other image varieties but I have not tested them.


  • Rasberry pi 4 or 3 / Zero W
  • Power Source, for the Pi 4 thats a USB C or Pi 3 and Zero W thats a Micro USB
  • Compatible Micro SD card – at least 4GB but I have a 32GB in use
  • A WIFI access point to connect to

Getting things ready

First off you will need to flash the Micro card with Buster. Download that image here Raspbain Buster image Once downloaded unzip that with your favourite zipping tool of your choice… You should now have an .img file.

Connect your micro SD card to your computer and use Etcher to flash the Buster .img-file to the card.

Setting up WIFI

Once your pi has been imaged, the drive has been ejected. Disconnect and connect the SD card so it gets detected by your machine again. A boot partition should appear.

Create a blank file called wpa_supplicant.conf within the boot partition of your pi, within here place the below in this new file:

country=UK # Your 2-digit country code
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Enabling SSH on your PI of choice

By default, a clean Raspbian image will have it’s ssh disabled. You would need to boot the system, connect a keyboard and display to the Pi and then enable ssh. This step will enable ssh at first boot.

In the boot partition, create a new file called ssh. An empty file with exactly that name and no file types following the SSH.

After completing those two optional steps, your PI will automatically connect to your WIFI and have SSH enabled by default.

Once you have imaged and configured the micro-SD card, you can then insert it to your PI or choice and power it up!

powering up and beyond

You will be able to find the IP address of your PI from within your WIFI access points DHCP section. with IP this you can then connect to your new shiny newly configured Pi 4/3/Zero W with putty.

The Default username and password for the Raspberry pi is

Username: pi
Password: raspberry

Updating your PI

Taking it further you are then able to update your Pi for this simply run the below:

sudo apt-get update
sudo apt-get upgrade

its always good to reboot a PI after any new updates have been installed to make sure it’s ran afresh with the latest updates, this can be achieved with

sudo reboot -n

After the reboot, your pi should be ready to go!


Been a while since I had a blog, but saying that… It’s also been a while since I had time to do anything.

I recently finished university and now have a fair bit of time on my hands before I start my new grad role (More on that in another post).

Currently just writing this to get some content up. Have been playing with some ESXI on a box sat right next to me, so will most probs write about that soon. Also been tinkering with my Unraid setup, more on that too…

Posts on here will most likely be around techy related things, but probs also some stuff on everyday life.

That’s all for now,

Till the next one…