DataYours: InfluxDB as an AltUI Data Storage Provider

Yes, once I worked out how to get the URL from the Sharing tab in Grafana, it all worked much better!

Snapshots are a bit slow. The interactive one allows too much control over the whole Grafana interface. But we are one step further forward…

[quote=“jswim788, post:15, topic:197151”]I’ve attached a working example of the InfluxDB relay. It doesn’t have much checking, but it does work for me. Anybody trying this should look at the InfluxDB page on writing data: Writing Data with the HTTP API | InfluxDB OSS 1.3 Documentation

Couple of questions: I retained the “_G.” for the luup.register_handler function, but since I’ve put this code in the startup lua, I don’t think it is needed. True? I’m not 100% sure what the “_G” is, but I’m guessing it is the global environment? Also, I’ve pulled in dkjson, but isn’t there an openLuup json? I thought I saw that somewhere but I’m not sure if that replaces dkjson or not.

As to displaying this in AltUI, I know we can get an embed link such as this via the “share” button:

And you can get a rendered image:

http://192.168.1.205:3000/render/dashboard-solo/db/chelan-dashboard?orgId=1&panelId=2&from=1505445867042&to=1506050667042&width=1000&height=500&tz=UTC-07%3A00

But I don’t know how to get these into AltUI.

EDIT: Added entry for InfluxDB server IP and port with default as 127.0.0.1:8086, switched to openLuup.json[/quote]

This seems cool. I’d like to use influxdb/Grafana for all visualisation. Unfortunately I’m not a programmer or anything. What the heck am I supposed to do with this file? Is it possible for someone to write a few lines to guide me to through the process?

The file that I attached should go in /etc/cmh-ludl. Are you running on openLuup or on a Vera? I’ve only tried this with openLuup, but I think it should work fine with a Vera (hmm - might need to switch to dkjson library if on Vera). My suggestion is to try the instructions here: http://forum.micasaverde.com/index.php?topic=35966.0 and get it working as the first step with the local whisper database.

Then set up your InfluxDB (I found this openHAB tutorial helpful: InfluxDB+Grafana persistence and graphing - Tutorials & Examples - openHAB Community). Make sure it is alive and also install Grafana and make sure it can connect and you can plot what you want.

Now you are at the point where the file I attached is useful. You can go into AltUI and select InfluxDB as the storage provider for the device variable of interest. Ignore any local plots for the moment - just make sure that after you do that that you see values getting pumped into InfluxDB when your data changes. You should then be able to see them in Grafana.

There are a lot of details in this but the documentation is pretty good. Just ask questions as needed.

I am trying to register InfluxDB as a tada storage provider and so far I have done the following

[ul][li]An active InfluxDB dtabase is running on my local network[/li]
[li]Data is being pushed to the InfluxDB from an Arduino HVAC CFM sensor[/li]
[li]User and password was created for alt ui data push[/li]
[li]Grafana is running and tapping into InfluxDb[/li]
[li]File was copied to the cmh-ludl folder and edited to point to the InfluxDB server with default credentials[/li][/ul]

How to I get the InfluxDBRelay.lua file to “load” when openluup starts so “startInfluxDBRelay()” gets called?

thanks

That’s a good question. I realize now that I didn’t use this file; I just put the contents of it in my startup lua. Which you can do too. But it would be nice to “source” this lua file in the startup. Sorry for misleading you on this. I think you could try the lua “dofile()”, but I haven’t tried it.

require "InfluxDBRelay"

placed in Lua Startup, should do it.

[quote=“akbooer, post:26, topic:197151”] require "InfluxDBRelay"

placed in Lua Startup, should do it.[/quote]

[facepalm] I had tried require “InfluxDBRelay.lua” and that failed…

so I added the following line in the startup
require “InfluxDBRelay”

I’ll try to get some measurements in.

thank you!

I’m just about to take a look at providing native openLuup support for InfluxDB (no need for extra code in startup, UDP protocol, …) How’s it going these days?

Actually, I’m also having problems installing it directly on an RPI, mostly since ‘influxdb’ not recognised by apt-get. How did you do it?

Also, did you ever make further progress on embedding Grafana graphics into the AltUI Device Variable pages?

TIA

It’s been so long since I installed InfluxDB on the RPI that I’ve forgotten exactly what I did (should have written it down). But I’m pretty sure I followed these instructions to get it enabled for the apt-get: Installing InfluxDB | InfluxDB OSS 1.4 Documentation

Influx has been running very well for me. No issues. It does take a little time to get used to the tags concept and the continuous queries for reducing the data. I doubt I have the optimum setup but it works well enough for me.

No, didn’t look further at trying to get the Grafana graphics into the AltUI display. I’ve gotten very comfortable looking at the Grafana pages directly.

OK, I have InfluxDB working now, and have implemented a version of your Startup code (itself copied from mine!) natively within openLuup.

I’m using the UDP protocol for several reasons:

[ul][li]very low memory and cpu resource usage[/li]
[li]no possibility of deadlock or timeout[/li]
[li]most configuration done in InfluxDB initialization (eg. associating the database with the port number)[/li]
[li]only requires measurement name (and optional comma-separated tags) as an AltUI parameter[/li][/ul]

This functionality will be enabled by Lua Startup setting an openLuup attribute (the IP and port for the receiving UDP socket) and once I’ve finished testing it’ll be in the next openLuup release.

This means that a local DataYours installation will not be required (although you will, of course, have to go through the exercise of setting up InfluxDB, and Grafana, somewhere on your network.)

Vera-users will have to stick to your implementation, though!

Could you guys make a guide for dummies, like myself, on how to set this up?

@jswim788 and I have rather different approaches, albeit using the same underlying mechanism.

My choice is for simplicity of use, which means configuring the UDP port of InfluxDB. Once installed, the InfluxDB configuration file is at [tt]/etc/influxdb/influxdb.conf[/tt] In that file, I have:

[[udp]]
enabled = true
bind-address = ":8089"
database = "openLuup"
retention-policy = ""

It’s then a matter of configuring the Influx database (here called “openLuup”) the way you want it. Note that the UDP port access can have its own default retention policy.

Finally, you need to arrange AltUI to give you InfluxDB as an option. It’s a small bit of code to run in Lua Startup. Are you running this on Vera or openLuup? Under openLuup I’ve built this in to the system, so it’s just a matter of defining a system parameter to point to the UDP port…

luup.attr_set ("openLuup.Databases.Influx", "172.16.42.129:8089")

On Vera, you’d have a little bit more work to do.