Hubitat + InfluxDB + Grafana Howto [Ubuntu Linux]

I think that the polling is a problem with this setup, specially for energy monitoring.

Last evening i noticed that even though my air conditioner was off for a few minutes, grafana was showing consumption. So this is not as accurate as it should be. You have pooling from Shelly to Hubitat, then pooling from InfluxDB Logger to Grafana, so you have a minimum delay of 2 minutes.

I will try Node-Red because it has some benefits, and from Hubitat perspective, MakerAPI is as easy to use as InfluxDB Logger. I did not understant how it creates the values in the database and if you have to set that up manually, or just choose what you need from Grafana.

At that point why not just do a Linux VM? I have a DietPi (lite debian) VM running Homebridge, NR, Influx, Grafana, etc... Unless you just have no Linux / command line experience then it might be daunting. I learned linux while in college, it was the cool thing to do at the time. Then I started admining a dedicated redhat linux server that hosted web sites and game servers.

Another question: is Raspberry Pi 3B+ 1GB of RAM + SSD enough for this setup, or for Node-Red alternative?

I really doubt polling caused a problem with that. The reason polling is there is for records to get into Influxdb at set intervals for devices that don't generate traffic. It isn't going to make your device report late. You record is queued when it is received in HE and then loaded on the next batch load. It is more likely a problem with your polling of the shelly delaying it device.

What do you have setup for "Soft-Polling Interval" and "How Often to write to DB" in InfluxDB Logger. Personally I would suggest setting the "Soft-Polling interval to something fairly large, and then set the "How Often to write to DB" value to 1 min to keep the queue low

1 Like

That would probably work, not sure how well, but I do think it will work. It probably wouldn't be a bad place to start, but you may see performance issue as the database grows.

I created a Pi Image that already has Influxdb, Grafana in it. You may want to try that just to get something built and working.

1 Like

@lcw731 and @rlithgow1
So as not to totally derail this thread I made a new one: [Guide] InfluxDB / Grafana on Windows

5 Likes

I had done that with both Ubuntu and Mint (i preferred Mint). My nephew was trying to convert my laptop and that where it went wonky. It wasn't even anything he did, just an unrelated situation that occured while he was doing it and i needed to finish up . I couldn't get it to work. So I just went back to windows. Eventually i'll experiment with Linux again, just dont have the patience or attention span to do it now.

1 Like

You are right.

I have tested with a virtual temperature sensor. I have set values from 1-10, then incremented by 5 up to 50.

The values all showed up in Grafana but with delays. Values from 0 to 30 where shown first then the rest. I think the events are sent to InfluxDB at the polling rate which in this case is 1 minute. Am I right?

Lets be clear there are two settings.

One is soft polling. That is how often InfluxDB will ask HE what the value is for given attributes for devices it tracks and write to InfluxDB. This can be important under certain circumstances to make sure you have something in the db at given intervals. This has nothing to do though with getting event driven changes into InfluxDB from HE.

The second value is how often to write to the DB. This value basically just tells influxdb logger how long to wait before posting events to the database unless the queue gets full. This doesn't effect the time of the event as that is part of the data that is queued. If a device changed 3 times in one minute all 3 events would be posted when that 1 min was up. It may take 1 min for new data to appear, but the values will reflect what happened in that interval and when in that interval.

Technically you could set the polling interval to 0 and just turn polling off completely. Depending on what and how you graph that may be fine.

The default code allows the queue to get to 100 before it forces a write to the Influxdb server. You can easily change that to a different number, or just 1 if you like. That number is there though to help reduce overall load. I have tweaked that number a few times to see if i could improve load. What i found worked best was setting the write to db value to 1 minute.

1 Like

To anyone needing help making this work on InfluxDB 2.X+, I edited the original app to include an API token section. Leave the username/password blank, but add an API token from your InfluxDB (create a token, then it should begin working.

Here is the updated Github link:
https://raw.githubusercontent.com/jaondayko/InfluxDB-Logger/master/influxdb-logger.groovy

1 Like

This is what i have achieved so far. Setup is working pretty good.

1 Like

Nice dashboard! What UPS do you have? I run a backups pro 1500 with a external 12v battery but it's a pain pulling stats from it.

Thank you,
APC RT1000 with network management card.
Use kahn-hubitat's app. It works like a charm. I have previously used a Raspberry Pi to get data from the UPS but this is way easier.

2 Likes

I have a small problem with InfluxDB Logger. When i add any device or modify a setting and hit done it loads forever. It does the job, but i don't like that i have to force the exit from the app's page. Does anyone have the same issue? I think it is related to the hub but triggered by this app.

Also, added some features to the dashboard.

I am still not convinced about the refresh rate sync between the devices and the database. At some point UPS Output was higher than UPS Input. The gauges should show values in real time, but if the refresh rate is not equal you might get wrong values.
Example:
The APC app has a refresh rate of 2 minutes. It is not recommended tot set it lower.
The Smartthings Outlet has a refresh rate based on power change of 10 watts, so it is faster if the value changes with more than 10 watts.

Opera Snapshot_2022-09-18_081957_192.168.1.12

Graph looks ok.

v 1.2 - changed from *mean to *last . Hope this solves some of the issues.

Hi @jaondayko1 I tried your modification, and I cannot get this to work with an InfluxDB2 Bucket. I suspect that it is because the Organisation is not defined?

I found Konnichy (GitHub - Konnichy/SmartThings-codersaur: Samsung SmartThings SmartApps and Device Handlers) modified the original SmartThings version to work with v2, and his version calls the Organisation. Sadly, I'm not clever enough to convert his version to work on Hubitat, or diff/merge any differences from his to yours.

Have you got this working on an InfluxDB2 setup? The error I get in Hubitat logs is:

postToInfluxDB(): Something went wrong! Response from InfluxDB: Status: 404, Headers: [X-Influxdb-Build:OSS, X-Platform-Error-Code:not found, X-Influxdb-Version:2.1.1, Content-Length:54, Date:Sat, 15 Oct 2022 15:07:28 GMT, Content-Type:application/json; charset=utf-8], Data: null

That looks like it cannot find the database to write to (Hence I think missing the Org)?

Edit - worked it out. The code is now using Async, so around line 811 in the code you need to make sure the writedb code is update to read

uri: "http://${state.databaseHost}:${state.databasePort**}/api/v2/write?org=${state.databaseOrg}&bucket=${state.databaseName}",**

1 Like

Glad you got it to work. I'm currently trying to figure it out as well.

A detail question -- is "Database" in the HE app synonymous with "Bucket" in InfluxDB? I'm not sure what to enter for Database in the logger app within HE. Any help is appreciated!

Yes, database is bucket.

1 Like

I'm using InfluxDB 2 also, so I applied @jason12's async change to the version posted a few posts above by @jaondayko1. But I still get the below error in the HE log from Influx. Anyone have any ideas?

postToInfluxDB(): Something went wrong! Response from InfluxDB: Status: 404, Headers: [X-Influxdb-Build:OSS, X-Platform-Error-Code:not found, X-Influxdb-Version:v2.4.0, Content-Length:69, Date:Tue, 18 Oct 2022 18:50:33 GMT, Content-Type:application/json; charset=utf-8], Data: null

That suggests it can't find your bucket. Have you put in the right organisation?