SmartThings
SmartThings copied to clipboard
Add support for InfluxDB v2.x and Token authentication
Hello,
I just switched to InfluxDB v2.3 and thought I'll provide you with the required modifications.
While at it, I just realize I also made modifications years ago to support multi-byte characters.
I have just tried these modifications, and they don't seem to work. Is the problem that the Organisation is not passed in the PostToInfluxDB? I get a 'not found' log response.
Hello,
Are you sure you provided these 3 parameters in the SmartApp configuration?
- bucket
- organization
- token
The Organization and Bucket are sent via URL, while only the Token is sent via header.
Hi Konnichy - yes I have provided all parameters. I guess if you have this working, then it must be an error my end - I'll keep digging/playing! Thanks for your quick reply.
I confirm it does work for me.
All the required request info is passed to PostToInfluxDB()
via the state
variable.
Also, it's not visually obvious, but you can click on the first line in the SmartApp configuration panel to change the logging level. Setting it to "trace" could provide more information.
Also, with Groovy being phased out, don't get your hopes too high. This SmartApp is expected to stop working before the end of the year in any case.
With Groovy being phased out soon, does anyone know an alternative solution for data logging?
Have a look here: https://github.com/eargollo/smartthings-influx This is the "InfluxDB topic" on SmartThings: https://community.smartthings.com/t/smartthings-data-visualisation-using-influxdb-and-grafana/44946/141.
I recently experimented with SmartApp development (and NodeJS, and Javascript) and I may try something on my side too. The downside of the app linked above is that it only polls. I'll use event subscriptions if I write it myself.
@Konnichy, looking forward to your solution - it will likely be more simple and perform better than what I’ve seen so far. NodeJS type solutions seem too complex, require server setup, and as you stated only polls.
Unfortunately, with SmartThings abandoning Groovy, they also stop running services on their cloud. Device drivers now run on the hub, but it is now left to us where SmartApps are hosted. They provide guidelines for hosting on Amazon AWS or our own servers. So it doesn't simplify the hosting process at all. Also, although the SmartThings API could be used from any development language, libraries provided by SmartThings are based on Node.js. So, any SmartApp development will likely be Node.js code.