Sending data to Influxdb

Hi all,

I’ve seen many threads/apps dealing with sending some metrics (temp and humidity sensors) to different backends.
I’m an Influxdb user and would like to create a smartapp to send data into a remote influxdb.

I’m actualy trying to push the data using a plain URL call but I’m not sure it’s really efficient. Also, I’m new to Groovy (while I’m good at python or Go).

IS there any Groovy binding to Influxdb ? Or is it possible to use the Java client within smartthings ?

The ST groovy environment is limited in what libaries it can use. You’re not going to be able to import any external libraries. If you can do it with an HTTP/REST call, that’s going to be the way to go. That’s what I’m using to get my data into Logstash and Graphite.

Thanks @btk
Do you have any smartapp example to show ?
Thanks.

Sure. Both are linked below. It should be noted that the “Log to Graphite” SmartApp is actually sending its data to a Backstop instance, which then sends it along to Graphite.


Your code is really clear. I’ll use it to create an Influxdb shipper.
Many thanks !

@prune998 did you ever make an Influxdb shipper? I’d like to get my hands on it if so.

Yes.
I did rework it just 2 days ago… it’s not the best code and may be improved to track any sensor type, but it’s what I have for the moment.

What is the best solution to share the smartapp ?

I just pusblished the smartApp. Will let you know if/when ST accept to publish it…

Would you be able to ‘publish’ the influxdb shipper here - via Github similar to @btk above - so that we can try earlier than waiting for ST to go through its process - many thanks

There you go guys. Don’t hesitate to do some pull requests :slight_smile:
git@github.com:prune998/st2influx.git
https://github.com/prune998/st2influx.git

Many thanks - looking forward to exploring further and some new insights!

I added a little bit more details and a picture of the result in the github repo.
I also added my Grafana Dashboard to ease the setup if you are using this dashboard…

@prune998 Were you able to get HTTPS working with influxdb and write from SmartThings SmartApp? I’m getting the following error in the SmartThings logs while using your smartapp. I confirmed I can write to influxdb from remote with curl although I need to pass a -k flag to ignore self signed cert issues.

something went wrong: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

EDIT: Doing some more digging. Looks like this is a SmartThings issue… It can’t accept self signed certificates. I wonder if it will take a Let’s Encrypt cert…

Well, let us know if you are able to use your cert. I’m using a valid cert so i never had this issue. But that’s a good catch.

At least switch to plain http for testing… And let me know if it is working for you. Did you set up Grafana too ?

Got it working after turning off HTTPS.

I did setup Grafana and your dashboard json is working thanks!

Thanks for the work on this - set it up this past weekend, and looks great so far!
I as well, ran into the SSL issue with SmartThings. I disabled https, and successfully had it populating influxdb.
I went as far as getting a valid cert issued from GoDaddy and installing, however, am still receiving the errors other have posted.

I have been searching which certs SmartThings will accept, with little success so far. Major browsers seem to be happy with the certificate. Will keep plugging away.

Thanks for the work!

EDIT: found the solution to my problem. Apparently with GoDaddy switching over from SHA-1 to SHA-2, not all java installations are updated. So I had to insert the crossover cert into the chain… now smartthings can connect without any problems. For reference, anyone hitting the same issue with GoDaddy certs: http://tozny.com/blog/godaddys-ssl-certs-dont-work-in-java-the-right-solution/

I got InfluxDB up on my server, does it need to be exposed to the Internet or does the hub talk locally in the network to the DB?

Sadly, It’s not the hub that connects to Influxdb.
The SmartApp is running in the SmartThings and no the hub. (as far as I know of)

So, yes, you need to expose Influxdb to the internet… That’s why I recommand using httpS and login/pass. You may also add a firewall rule to limit the IP range that can connect, but I don’t know if this is possible.
If anybody have knowledge of the IP range used by ST servers, you’re welcome to comment.

Thanks for the update, that’s what i figured… sure would be nice to have that local processing that was sold to us…

yep… local processing seems pretty limited right now, with almost “no way” to extend it… sounds like it wasn’t designed to work this way at the begining and developers are not able to deliver the marketing promises…