Hubitat + InfluxDB + Grafana Howto [Ubuntu Linux]

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?

Hmm, is there a place in Influx where you assign a bucket to the org? I can see from the Influx web interface that I'm logged on my org. And my org has a bucket in it called hubitat_events that I have put into the Database field of the HE app. The host IP and port are correct--I've triple checked that. I've left the Username and Password blank, per instructions above in the thread, and then pasted in the API Token (not the Bucket ID) under "Database Auth Token". Then I picked a handful of HE devices that are definitely generating events.

Anything jump out as wrong?

Edit: also, just to be sure, I deleted and recreated the logger app in HE. When I did, I saw a new error message in the HE log: errorjava.lang.RuntimeException: java.sql.SQLException: Values of types "BOOLEAN" and "INTEGER" are not comparable; SQL statement: SELECT COUNT() FROM EVENT_SUBSCRIPTION WHERE FILTER = ? AND HANDLER = ? AND INSTALLED_APP_ID = ? AND SUBSCRIBED_INST_APP_ID = ? [90110-214] Query: SELECT COUNT() FROM EVENT_SUBSCRIPTION WHERE FILTER = ? AND HANDLER = ? AND INSTALLED_APP_ID = ? AND SUBSCRIBED_INST_APP_ID = ? Parameters: [0, handleAppTouch, 1924, 1924] on line 881 (method updated).

Does your hubitat logger have an option to define the Org? If not, then that is the problem - the org needs to be defined in Hubitat. I must have added it in. If you aren't defining the org in the app code you need to add it in.

You could try merging these commits into your version:
InfluxDB2.x support by Mavrrick ยท Pull Request #21 ยท HubitatCommunity/InfluxDB-Logger ยท GitHub

But make sure the change in the // Hubitat Async http Post section (around line 812) I said is also made. Clearly I went round in circles and ended up making changes I hadn't remembered I needed to do to make it work!

1 Like

That did the trick. You are my hero. Thank you thank you thank you.

@andutgv Are you still running this from a Pi ? And if so. Are you using the local SD card storage or connected a proper drive to the pi for the influxdb data ?

Yes. But i mounted an SSD as a drive. Works flawless since 3 months ago.

1 Like

Just anycase anyone watching this thead isn't aware the InfluxDB Logger just got updated and includes support for Influx DB instances using both v1 and v2 versions of the database. It also supports TLS which means you can use this with a Free Influx Cloud account. There are also further updates coming that will improve performance like adjusting the Write Queue Limit and adjustments to a few methods that improve performance considerably when creating the batch to post to InfluxDB.

2 Likes

is there any clean walkthrough of setting up HE with InfluxDB and Grafana using docker on a SynologyNAS? I spent like an hour on it today and couldn't get it working... Not sure what I'm missing - i get 400 errors (unauthed) in my HE logs.

It would help to know exactly what version of the app you are using, what version of influx DB, and possibly what kind of data are you trying to load.

Also what kind of auth are you using?

I believe a error code 400 is actually indicating you are sending bad data and is not a auth issue.

that was brilliant advise! - I looked more carefully - logs said:

DB: http://http://synologyNAS1:3003/api/v2/write?org=Amity&buck

and there it is - redundant protocol. Off to test.

jshimota,

If you do get this running, maybe you can publish the guide you were originally looking for (setting up on Synology NAS with Docker). I'd be interested but am someone with zero Docker experience.

@oktoko I toyed with this a little but didn't succeed yet - hadn't put much effort into it. as past posters have expressed - there is scads of info on the subject, but its all high level talk with experienced users discussing finer points, no simple step by step. I don't mind, but I haven't had time to unwind and parse and learn.
I'll be stepping through this this week and weekend - if I succeed I'll whip up a step by step walkthrough for Synology NAS with Docker in generic environment. I think my stumbles so far have to do with redirected ports on the InfluxDB, incorrect paths, and possible version specific issues.