Hubitat + InfluxDB + Grafana Howto [Ubuntu Linux]

I was searching for a decent howto on graphing sensor data captured by Hubitat, but found a variety of old and outdated and partial conversations on the topic, but nothing that shows you how to get from nothing to a graph in one place. Here's my attempt to do that for others in the same boat. Note I'm not an expert on these things as I just got them working myself, but that also means that this process does work as of today.

This will be based on my configuration, but it should be similar for other OS choices to run InfluxDB/Grafana. I'm using Ubuntu to run these. I know a lot might choose to use a Raspberry Pi. I didn't have an extra laying around for this now, so Ubuntu running in a VM it is.

Also note that I am not setting up any logins, so this is technically insecure and should only be used on a LAN.

Here's that to do:
1
Add the InfluxDB Logger App under Developer tools. This can be imported using this link:
https://raw.githubusercontent.com/HubitatCommunity/InfluxDB-Logger/master/influxdb-logger.groovy

2
Install InfluxDB. The install instructions are pretty straightforward and mostly copy/paste commands from this page:

I kept with the latest 1.x install since I saw another forum post about 2.x not working with the App. I can verify 1.8 works, but no clue if the latest does with the App as it's currently written.

3
Missing from the InfluxDB instructions, you need to install the client to access the database and create the database. Do that with:
sudo apt install influxdb-client

Then connect to the database:
influx -precision rfc3339

You should now be logged into the database server. At the prompt, create the database "Hubitat", which is where the App will log the data:
create database Hubitat

4
Now within Hubitat, add and configure the App to send data to InfluxDB. If you configured it as instructed above, you only need to fill out the Host IP (whatever the IP is of the server running InfluxDB), set the polling interval and write interval to what you want, and select the devices to monitor. Leave Username and Password blank.
After that you can go back to your server console and check that Hubitat wrote some data to your database:

use Hubitat
show measurements

In my case, I am logging pressure and temperature from one sensor, so I see tables with these labels:
image

To see the logged data (in this case the temperature), you can use this command:
select * from temperature
If it's logging, you will see results like this:

5
Now that you have a database with data, you can install and configure Grafana. This has a similar page with installation based on what OS you want to use:

6
Once Grafana is installed, go to serverip:3000 and login. The default is admin/admin. From there, you should be in a dashboard where there is a button labelled "Add your first data source". Click on that (mine says complete, yours won't yet).


The only thing I needed to do here was enter the HTTP URL. Even though the field appears to have "http://localhost:8086" entered, it's not really there. Enter that same text in there then press "Save & test" at the bottom. It should be successful.

7
Now that you have the database available in Grafana, you can display it however you want by creating your first dashboard. Create a new dashboard, then click "Add a new panel".

Here you must build up a database query to select the appropriate data. Here is a simple example that graphs the last 24hrs of temperature data. I indicate the three settings I changed to get this result.

From here you can modify the table with the other options on the screen, save and apply them, create more graphs, etc. I'm not an expert on Grafana, so here's where the extent of my knowledge ends.

Hopefully this is helpful. Feel free to discuss, suggest improvements, alternatives, etc.

7 Likes

Now what about displaying it on a dash in Hubitat?

1 Like

I use an iFrame tile device driver for that. I wrote my own (https://raw.githubusercontent.com/thebearmay/hubitat/main/tileIframe.groovy) but bptworld and others have their own versions too.

2 Likes

I'm fairly database stupid so even with step by step instructions like above, it may take me a bit. (I never could wrap my head around them) Looking to export my data from Iotawatt. If they would just allow syslog export :slight_smile:

You may want Bryan's simpler charting option, including data storage.

Not sure if that will work with iotawatt... I will certainly check it out though

1 Like

This was easy to setup following these steps:

  1. Install RaspiOS Lite Bullseye 32-bit
  2. Install InfluxDB from OS repository with command "sudo apt install influxdb"
  3. Install InfluxDB Client from OS repository with command "sudo apt install influxdb-client"
  4. Connect to the database with command "influx -precision rfc3339"
  5. Create database with command "create database Hubitat"
  6. Config InfluxDB Logger
  7. Install Grafana Server with commands:
    sudo apt-get install -y adduser libfontconfig1
    wget https://dl.grafana.com/enterprise/release/grafana-enterprise_9.1.2_armhf.deb
    sudo dpkg -i grafana-enterprise_9.1.2_armhf.deb
  8. Run the commands specified after install, ex: enable grafana-server
  9. Set Grafana source and create a panel

Result:

This was setup on a Raspberry Pi 3B+.

But the question is if it is worth it to use a Raspberry at all, and if this setup is enough. For example i want to add energy meters from Shelly, which are not available on Hubitat. Should i use a setup with NodeRed instead?

1 Like

If you want to use an external USB Drive you need to add the following steps before step 4:

Properly add an external USB HDD using the following tutorial:

Note: It won't work if you format it with NTFS in Windows, even though you are able to create a directory. The influxd service will fail.

cd ~/mnt/pidrive1
mkdir influxdb
sudo chown -R influxdb:influxdb influxdb
sudo chmod -R 777 influxdb
cd ~

#edit the config file to use the data folder
sudo nano /etc/influxdb/influxdb.conf

###Change these values
#[meta]
# dir = "/var/lib/influxdb/meta"
#to 
# dir = "/mnt/pidrive1/influxdb/meta"

#[data]
#dir = "/var/lib/influxdb/data"
#to
#dir = "/mnt/pidrive1/influxdb/data"

#wal-dir = "/var/lib/influxdb/wal"
#to
#wal-dir = "/mnt/pidrive1/influxdb/wal"

#test
influxd

###IN A NEW SEPERATE TERMINAL
influx
#if you get the shell (not quick), close by:
exit
#close terminal

After creating the directory on the external drive and granting permissions you can proceed to create the database.

@andutgv Thanx for the instructions. Can you add ones for a windows based install as well? Maybe note using iframe to put it on a dash?

2 Likes

You can send data from Node-Red to Influx. So if you can get the shelly info in Node-Red just set it up to send to Influx from there. When I set mine up I sort of wanted to try out Node-Red anyway so I send the events to Node-Red with Maker API and have NR save them in Influx, instead of using the Influx Logger app.

I am still trying to figure it out, because even though you can find all the information you need, most of the time, the instructions are missing some steps, especially if you try to combine multiple threads. For example this tutorial is working but only if you use the sd card for the database. Also, you can install influxdb without hassle because it is in the repository. No need to download it with the commands mentioned in the first post.

So as i go to the process, i will try to document each step.

1 Like

Have you used any instructions or did it by yourself? I think in the long term Node-Red is better and more scalable, but InfluxDB Logger is easier to use for those who have all the devices available in Hubitat.

There is a massive older thread about it with some example nodes from (I think) dan.t

I decided however to use Influx 2.x, so I had to adapt to that, so I ended up with two custom function nodes, one to simply filter out events I did not want (using logic to only include what I want). Then another function that transforms the data into a format the influx node will take. I did use the examples I found as a starting point.

Here is the node-red import file for my setup

Thank you for sharing. I know the longer thread you are talking about, but i saw there were a lot of issues down the road and the code is still beta.

After i get used to this setup and find a more suitable hardware (at least RPi 4 with external SSD) i will try Node-Red.

Also i think MakerAPI is a better long-term solution for getting the data in Node-Red. What have you used? MarkerAPI or WebSockets?

Seems that there is no need for Node-Red to get energy values. I managed to integrate them into Hubitat, Altough i had some high load alerts, so Node-Red is not yet off the table.

The key with Influx db logger is that you will see spikes depending on how many devices you are tracking. It queues the devices up and then sends them at set intervals. It will also perform a poll of decices at set intervals if setup to do so.

If you want to reduce the load Influxdb logger generates have it send the updates more frequently for updates and have it do polling as little as possible if not needed.

The advantage of node red is that everything happens when it happens. So you dont have any build up of transactions to do at one time. The polling is particularly impactful when comparing the two.

That said i use tbe influxdb logger and have so for a long time. It tracks a ton of stuff in my setup and no issues with load at all.

If you can figure out how to set this up with windows, that would be awesome!

Have you tried to install Influx or Grafana on Windows? I haven't... just trying to understand where the issues may lie...

No. The issue lies in me. I can usually follow instructions pretty well in this area. But trying to start from scratch on my own, i stall out quickly. I've done a couple webinars on influx DB, but retained almost nothing because it quickly went over my head.

Il'l admit with plenty of Linux options around me.... apart from a laptop.... I don't have a lot of motivation to look at a Windows option, as much as it is my preferred platform...

Download the Hubitat app