Author Topic: DataYours: InfluxDB as an AltUI Data Storage Provider  (Read 773 times)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5344
  • Karma: +231/-68
  • "Less is more"
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #15 on: September 22, 2017, 04:05:41 pm »
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: https://docs.influxdata.com/influxdb/v1.3/guides/writing_data/

Great stuff!

Quote
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? 

Yes, _G is the global environment.  Whether you need to use it or not may depend on the context of your code and how it's referenced.  There are, in fact, not really ANY true globals in Lua.  If the 'global' name is in a module, it's global to that module, but the name may be referenced within the external module name.  Depends to some extent on how it was written and how it was loaded.  If this works, you may as well keep it.

Quote
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.

Oh, yes.  It's used all over the place in openLuup, try:

Code: [Select]
local json = require "openLuup.json"

The openLuup installation does pull down a copy of dkjson.lua, simply because that's what UI7 uses (UI5 had no standard one) and some plugins may expect it.  The openLuup one is nicer for debugging since it pretty-prints the encoded JSON, so you can actually read it if you take a look at it.

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

<iframe src="http://192.168.1.205:3000/dashboard-solo/db/chelan-dashboard?orgId=1&panelId=2&from=1505445867042&to=1506050667042" width="450" height="200" frameborder="0"></iframe>

No need for all this, I think, since AltUI already does it for you in the variable's push data page.  What you need is to include the information in the graphic_url parameter when you register as a Data Storage Provider.

Quote
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

Oh, excellent - I didn't know that (did I miss some documentation?)  Now we can definitely get rid of DataYours for doing this entirely within the openLuup (+Grafana) environment.  I will give this a go!

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

...you do now?
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5344
  • Karma: +231/-68
  • "Less is more"
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #16 on: September 22, 2017, 04:13:11 pm »
Quote
Oh, excellent - I didn't know that (did I miss some documentation?)

...ah, got it, I think...

http://docs.grafana.org/reference/sharing/
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #17 on: September 22, 2017, 07:35:50 pm »
http://docs.grafana.org/reference/sharing/
That's the one.  The links from the "share" button will be fine for local use, but if remote, I think I'll need to hide this behind a request similar to lr_render?

Thanks for the answers on the InfluxDB relay code - I'll update it.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5344
  • Karma: +231/-68
  • "Less is more"
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #18 on: September 23, 2017, 06:31:51 am »
The links from the "share" button will be fine for local use, ...

...hmm, doesn't work for me, but I have it installed on a BeagleBone Black, not a RPi, so maybe need the extra library they mention.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #19 on: September 23, 2017, 10:32:02 am »
So far I can only get the full panel link to work.  If I try the 'render' or 'dashboard-solo' I get nothing or just the header but no graph.  I've attached a picture of what does work.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5344
  • Karma: +231/-68
  • "Less is more"
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #20 on: September 23, 2017, 10:49:50 am »
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...
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline jokkling

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #21 on: January 01, 2018, 02:38:19 pm »
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: https://docs.influxdata.com/influxdb/v1.3/guides/writing_data/

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:

<iframe src="http://192.168.1.205:3000/dashboard-solo/db/chelan-dashboard?orgId=1&panelId=2&from=1505445867042&to=1506050667042" width="450" height="200" frameborder="0"></iframe>

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

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?

Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #22 on: January 04, 2018, 01:03:58 pm »
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: https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing/13761).  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.

Offline sle118

  • Sr. Newbie
  • *
  • Posts: 39
  • Karma: +3/-0
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #23 on: January 11, 2018, 12:21:00 pm »
I am trying to register InfluxDB as a tada storage provider and so far I have done the following
  • An active InfluxDB dtabase is running on my local network
  • Data is being pushed to the InfluxDB from an Arduino HVAC CFM sensor
  • User and password was created for alt ui data push
  • Grafana is running and tapping into InfluxDb
  • File was copied to the cmh-ludl folder and edited to point to the InfluxDB server with default credentials

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

thanks

Offline jswim788

  • Hero Member
  • *****
  • Posts: 550
  • Karma: +30/-2
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #24 on: January 11, 2018, 02:57:04 pm »
How to I get the InfluxDBRelay.lua file to "load" when openluup starts so "startInfluxDBRelay()" gets called? 
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.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5344
  • Karma: +231/-68
  • "Less is more"
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #25 on: January 11, 2018, 03:25:51 pm »
Code: [Select]
require "InfluxDBRelay"

placed in Lua Startup, should do it.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline sle118

  • Sr. Newbie
  • *
  • Posts: 39
  • Karma: +3/-0
Re: DataYours: InfluxDB as an AltUI Data Storage Provider
« Reply #26 on: January 11, 2018, 04:37:28 pm »
Code: [Select]
require "InfluxDBRelay"

placed in Lua Startup, should do it.

[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!