Update laundry-monitor.groovy
[smartapps.git] / third-party / influxdb-logger.groovy
index 3cba6e31e2b15650727af527747bec9f3b50c66e..90603c9837ab5a688a2695b24f85c717255dfa64 100755 (executable)
@@ -598,7 +598,7 @@ def logSystemProperties() {
 def postToInfluxDB(data) {
     logger("postToInfluxDB(): Posting data to InfluxDB: Host: ${state.databaseHost}, Port: ${state.databasePort}, Database: ${state.databaseName}, Data: [${data}]","debug")
     
-    try {
+   /* try {
         def hubAction = new physicalgraph.device.HubAction(
                [
                 method: "POST",
@@ -614,7 +614,7 @@ def postToInfluxDB(data) {
     }
     catch (Exception e) {
                logger("postToInfluxDB(): Exception ${e} on ${hubAction}","error")
-    }
+    }*/
 
     // For reference, code that could be used for WAN hosts:
     // def url = "http://${state.databaseHost}:${state.databasePort}/write?db=${state.databaseName}" 
@@ -636,11 +636,11 @@ def postToInfluxDB(data) {
  *
  *  Handles response from post made in postToInfluxDB().
  **/
-def handleInfluxResponse(physicalgraph.device.HubResponse hubResponse) {
+/*def handleInfluxResponse(physicalgraph.device.HubResponse hubResponse) {
     if(hubResponse.status >= 400) {
                logger("postToInfluxDB(): Something went wrong! Response from InfluxDB: Headers: ${hubResponse.headers}, Body: ${hubResponse.body}","error")
     }
-}
+}*/
 
 
 /*****************************************************************************************************************
@@ -693,18 +693,67 @@ private manageSubscriptions() {
     // Subscribe to mode events:
     if (prefLogModeEvents) subscribe(location, "mode", handleModeEvent)
     
-    // Subscribe to device attributes (iterate over each attribute for each device collection in state.deviceAttributes):
-    def devs // dynamic variable holding device collection.
-    state.deviceAttributes.each { da ->
-        devs = settings."${da.devices}"
-        if (devs && (da.attributes)) {
-            da.attributes.each { attr ->
-                logger("manageSubscriptions(): Subscribing to attribute: ${attr}, for devices: ${da.devices}","info")
-                // There is no need to check if all devices in the collection have the attribute.
-                subscribe(devs, attr, handleEvent)
-            }
-        }
-    }
+    subscribe(accelerometers, "accelerometers", handleEvent)
+    subscribe(alarms, "alarms", handleEvent)
+    subscribe(batteries, "batteries", handleEvent)
+    subscribe(beacons, "beacons", handleEvent)
+    subscribe(buttons, "buttons", handleEvent)
+    subscribe(cos, "carbonMonoxide", handleEvent)
+    subscribe(cos, "carbonDioxide", handleEvent)
+    subscribe(colors, "hue", handleEvent)
+    subscribe(colors, "saturation", handleEvent)
+    subscribe(colors, "color", handleEvent)
+    subscribe(consumables, "consumableStatus", handleEvent)
+    subscribe(contacts, "contact", handleEvent)
+    subscribe(doorsControllers, "door", handleEvent)
+    subscribe(energyMeters, "energy", handleEvent)
+    subscribe(humidities, "humidity", handleEvent)
+    subscribe(illuminances, "illuminance", handleEvent)
+    subscribe(locks, "lock", handleEvent)
+    subscribe(motions, "motion", handleEvent)
+    subscribe(musicPlayers, "status", handleEvent)
+    subscribe(musicPlayers, "level", handleEvent)
+    subscribe(musicPlayers, "trackDescription", handleEvent)
+    subscribe(musicPlayers, "trackData", handleEvent)
+    subscribe(musicPlayers, "mute", handleEvent)
+    subscribe(peds, "steps", handleEvent)
+    subscribe(peds, "goal", handleEvent)
+    subscribe(phMeters, "pH", handleEvent)
+    subscribe(powerMeters, "power", handleEvent)
+    subscribe(powerMeters, "voltage", handleEvent)
+    subscribe(powerMeters, "current", handleEvent)
+    subscribe(powerMeters, "powerFactor", handleEvent)
+    subscribe(presences, "presence", handleEvent)
+    subscribe(pressures, "pressure", handleEvent)
+    subscribe(shockSensors, "shock", handleEvent)
+    subscribe(signalStrengthMeters, "lqi", handleEvent)
+    subscribe(signalStrengthMeters, "rssi", handleEvent)
+    subscribe(sleepSensors, "sleeping", handleEvent)
+    subscribe(smokeDetectors, "smoke", handleEvent)
+    subscribe(soundSensors, "sound", handleEvent)
+    subscribe(spls, "soundPressureLevel", handleEvent)
+    subscribe(switches, "switch", handleEvent)
+    subscribe(switchLevels, "level", handleEvent)
+    subscribe(tamperAlerts, "tamper", handleEvent)
+    subscribe(temperatures, "temperature", handleEvent)
+    subscribe(thermostats, "temperature", handleEvent)
+    subscribe(thermostats, "heatingSetpoint", handleEvent)
+    subscribe(thermostats, "coolingSetpoint", handleEvent)
+    subscribe(thermostats, "thermostatSetpoint", handleEvent)
+    subscribe(thermostats, "thermostatMode", handleEvent)
+    subscribe(thermostats, "thermostatFanMode", handleEvent)
+    subscribe(thermostats, "thermostatOperatingState", handleEvent)
+    subscribe(thermostats, "thermostatSetpointMode", handleEvent)
+    subscribe(thermostats, "scheduledSetpoint", handleEvent)
+    subscribe(thermostats, "optimisation", handleEvent)
+    subscribe(thermostats, "windowFunction", handleEvent)
+    subscribe(threeAxis, "threeAxis", handleEvent)
+    subscribe(touchs, "touch", handleEvent)
+    subscribe(uvs, "ultravioletIndex", handleEvent)
+    subscribe(valves, "contact", handleEvent)
+    subscribe(volts, "voltage", handleEvent)
+    subscribe(waterSensors, "water", handleEvent)
+    subscribe(windowShades, "windowShade", handleEvent)
 }
 
 /**