SmartThings Data Visualisation using InfluxDB and Grafana

You might try displaying the data in InfluxDB itself via the command line when you know the event has happened but Grafana isn’t displaying it. It the data is in the DB then you know it’s in the visualization stage where things aren’t keeping up. It might require some luck trying to catch the situation.

The timing of this pipeline can be tricky with data flowing through multiple steps and each step having intervals that don’t always sync up.

Is there an update to this write up? I’m trying to make this work on a pi w, but I can’t connect via /localhost:8086 or :3000 after installing each server.

It looks like @zcapr17 may not be active anymore? I’m hoping someone in here can guide me.
I’ve grabbed a free subscription to http://corlysis.com who hosts influxDB and Grafana and very reasonable.
I have installed the Influx datalogger and adjusted the section of the code at “def postToInfluxDB(data)” for sending to WAN hosts.
I see in Groovy that it’s trying to send data but it’s getting an error that I can’t track down:

7bb21d1c-769d-42a7-b567-XXXXXXX 10:15:20 PM: error postToInfluxDB(): Something went wrong when posting: groovyx.net.http.ResponseParseException:

7bb21d1c-769d-42a7-b567-XXXXXXX 10:15:20 PM: debug postToInfluxDB(): Posting data to InfluxDB: Host: corlysis.com, Port: 8087, Database: CabinHUB, Data: [humidity,deviceId=bf1412bf-47ae-45a5-96ae-XXXXXXX,deviceName=Weather\ Station,groupId=null,groupName=Home,hubId=null,hubName=null,locationId=a451ffb7-037f-4952-9068-XXXXXXX,locationName=Cabin,unit=% value=81]

Does that error mean anything to anyone?
Thanks,
Phil

The example code in postToInfluxDB() for WAN hosts doesn’t seem to use state.headers, which means it isn’t passing the username/password. I think that’s the reason for the failure.

You should be able to change the code to this to get it to work (untested):

// For reference, code that could be used for WAN hosts:
def url = "http://${state.databaseHost}:${state.databasePort}/write?db=${state.databaseName}"
try {
    def params = [
        uri: $url,
        body: data,
        headers: state.headers
    ]
    httpPost(params) { response ->
        if (response.status != 999 ) {

Also I think you can change the url string to have “https” and then you can use port 8086, which would encrypt the connection and avoid sending your username/password obfuscated by unencrypted.

Thanks John,
The error has changed. Here is the current error and for reference, the active part of the posttoinfluxDB section in question:

error postToInfluxDB(): Something went wrong when posting: java.lang.reflect.UndeclaredThrowableException

def url = "http://${state.databaseHost}:${state.databasePort}/write?db=${state.databaseName}" 
try {
	def params = [
    	uri: $url,
    	body: data,
    	headers: state.headers
				]
httpPost(params) { response ->

      if (response.status != 999 ) {
              log.debug "Response Status: ${response.status}"
              log.debug "Response data: ${response.data}"
              log.debug "Response contentType: ${response.contentType}"
            }
      }

  } catch (e) {	
      logger("postToInfluxDB(): Something went wrong when posting: ${e}","error")
  }

}

Yikes…I have no idea on that.

I have the same delay issue with binary switches. I’m using the v3 hub.