codersaur/SmartThings

InfluxDB 2.0

Opened this issue · 4 comments

InfluxDB 2.0 is now available. Has anyone thought about refining this app to work with it? I may start looking at tweaking the code to that end but I fear I may be out of my depth.

It might just work.... https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/

Might be as simple as using the auth token for the password.

I've read the InfluxDB documentation describing how to use the V1 compatible write endpoint offered by V2 and, having looked at the code for the SmarApp it looked like substituting the authentication token for the password would work, but it doesn't seem to be working for me. I did use the Influx CLI to establish a DBRP mapping so that a reference for the relevant database in the call would get mapped to the V2 data bucket. It doesn't look like it should be too hard to get this to work, but I'm not accustomed to Groovy coding nor do I have any experience working with the sendHubCommand which is used by this app to pass the relevant call to the API.

I continue to work on this one and have not made much progress. I'm not sure if there's an encoding problem that causes issues with the auth token. I have tried a number of different approaches, including the one suggest by @BGodding above as well as adding an input variable to specify that I'm using InfluxDB-2 and then tweaking the code here and there to use the new V2 write endpoint with Token authorization. I'd be happy to share what I've done with someone who is a bit more savvy to sort through all of this.

al8 commented

I don't know if you're still working on this, but all I did in this code was to add a Token config and added it to the request header, and generate a token that has access to the bucket.

On influxdb2 itself I had to associate a bucketID with a v1 database name via the "dbrps" api, something like.

curl --request POST http://192.168.1.1:8082/api/v2/dbrps --header "Authorization: Token token" --header 'Content-type: application/json' --data '{ "bucketID": "f2fe5057fxxxx", "database": "SmartThings", "default": true, "orgID": "4e610d1xxxxx", "retention_policy": "year" }'

You can see my changes in this commit: let me know if you need more help.