Sending data to Influxdb

Any idea what I’m doing wrong here?

I created InfluxDB database “smartthings” with user “smartthings” with ALL privileges…

11:14:15 AM: debug Calling [uri:HTTP://XXX.XXX.XXX:8086/write?db=smartthings&u=smartthings&p=XXXX, body:energy,sensor=Home\ Energy\ Meter value=1440.73 
power,sensor=Home\ Energy\ Meter value=1024 

but all I see is

response data: null

and nothing added to DB.

this is beyond the scope of this discussion, but :

  • connect to influxdb using the cli (influx)
  • ‘use database smartthings’
  • ‘show databases’
  • ‘SHOW GRANTS FOR smartthings’
  • ‘show series’

I think that influx return a 204 HTTP code with no data when you write something…

Hi all,

looks like I missed this thread when I was setting up my own database and visualisation solution for SmartThings.

I decided to go with InfluxDB and Grafana after some assistance from @btk. I wrote a SmartApp to get the data from SmartThings to InfluxDB which uses the hubAction command, which means it will support the InfluxDB server being on the same private LAN as the SmartThings Hub, so there is no need to make the database server accessible from the internet.

I just posted a write-up here…

It covers only basic graphs for now, but I aim to follow it up with details of the more-advanced graphs I’ve managed to put together soon. I also want to take a look at configuring retention policies and down-sampling in InfluxDB - @prune998 - can you offer any guidance in this respect?

Thanks,

z.

very nice!

is it possible to get finer grain then every 5 minutes since it’s running locally? with @prune998 's smartapp it was set for every 5 minutes.

My SmartApp is subscribing to device attributes. If you have a device attribute that is changing every 10 or 30 seconds, then the app will already forward each change in value to InfluxDB.

Soft-polling is only there to fill in the gaps for device attributes that change infrequently (relative to your charting periods), as you need two data points on a chart before Grafana will draw a line between them.

But yes, you could change the soft-polling interval down to once per minute if you really wanted. The only reason I can think of to do this would be if you are producing charts showing short periods of time (i.e. less than 10 mins) and you are plotting device attributes that are changing less frequently than this.

Note, I’ve started a new thread here to consolidate discussion about my InfluxDB Logger SmartApp: SmartThings Data Visualisation using InfluxDB and Grafana

HTH

z.

Hi,

That’s a good news many people end with the same idea :slight_smile:
I’m reviewing your smartapp right now and will come back to you with comments soon.

I’m not sure the ST ecosystem of a user will send so much metrics that influxdb have to “expire” some data using retention policies. At least not before a year or so.
But there is nothing special about them.
Down sampling is done using continuous queries, which is easy too for simple reductions, like a “one hour” or “one day” down sampling.
But again, even if you grab metrics of 50 sensors every 10 seconds, it’s NOTHING for influxdb, except if your influx is running on a RaspberryPi.
I’m sending almost 6k metrics/s in my production single instance server right now and I can confirm that Influxdb release 12 is really stable and cheap on ressources (for now)

As Influx is able to aggregate your metrics depending on the bucket size and time span (which is automaticaly managed in grafana), you really need to aggregate ONLY if you are exhausting your server ressources, like RAM or disk space.

I hope this insight will help you to concentrate your energy where it is needed :slight_smile:
I’m reviewing your code (specificaly the usage of hubaction, which I don’t know of) and will comment back.

Regards,

1 Like

What I understand is that the HubAction does NOT support https ?
It also seem you don’t handle a login/password ?

But you did a far better work than me to support many devices. Fact is, I have a very limited list of devices to test with :slight_smile:

Also, if I understand well, things work this way :

device update it’s metrics -> hub – internet --> ST server SmartApp executor – internet --> hub --> HubAction – http --> influxdb server.

While this enables a local call to Influxdb, there is a round trip added (and again, loss of https).
Maybe an improvement would be to offer (from the config file) the choice to go local (http) or remote (https + auth) ?

You really seem to be a better dev than I am (i’m more ops/architect)

I also like the “groupname” you add, but having to define it in the smartapp itself is a pain !
Have you consider asking ST support about that ? Or ask here in the forum within an explicit post ?

Let me know.

Good question! I’ve not looked at this as my InfluxDB instance in on my local LAN and I’ve not needed to lock down writing data to the HTTP API by using logins or HTTPS. I’ll mark this as something to look at in the future though, I suspect HubAction should be able to use basic authentication, but perhaps not OAUTH or SSL (?)

Very good point. I haven’t noticed any performance issues due to the round trip, but having the options for both methods is a good idea. You can see in the code I left the httpPost method in the comments.

Even better would be if SmartThings pulled their finger out and enabled local execution on the hub for SmartApps! :disappointed:

Yes, already discussed here: Accessing group within a SmartApp

Z.