Update NotifyIfLeftUnlocked.groovy
[smartapps.git] / official / gideon-smart-home.groovy
index a198d726d29844eea1a219aad2f1cef06f949cda..49600350c47b14afdcaca9f83f9d140ff593d403 100755 (executable)
@@ -78,26 +78,6 @@ preferences {
     }
 }
 
-def installed() {
-       log.debug "Installed with settings: ${settings}"
-
-       initialize()
-}
-
-def updated() {
-       log.debug "Updated with settings: ${settings}"
-
-       unsubscribe()
-       initialize()
-}
-
-def initialize() {
-}
-
-private device(it, type) {
-       it ? [id: it.id, label: it.label, type: type] : null
-}
-
 //API Mapping
 mappings {
    path("/getalldevices") {
@@ -284,6 +264,27 @@ mappings {
   }
 }
 
+def installed() {
+       log.debug "Installed with settings: ${settings}"
+
+       initialize()
+}
+
+def updated() {
+       log.debug "Updated with settings: ${settings}"
+
+       unsubscribe()
+       initialize()
+}
+
+def initialize() {
+}
+
+private device(it, type) {
+       it ? [id: it.id, label: it.label, type: type] : null
+}
+
+
 //API Methods
 def getAllDevices() {
     def locks_list = locks.collect{device(it,"Lock")}
@@ -306,74 +307,6 @@ def getAllDevices() {
     return outlets_list + kelvin_list + colors_list + switchlevels_list + smokes_list + contact_list + water_sensors_list + shades_list + garage_list + locks_list + presences_list + motions_list + switches_list + temp_list + meters_list + battery_list
 }
 
-//thermostat
-/*
-def setCoolTemp() {
-       def device = thermostats.find { it.id == params.id }
-        if (!device) {
-            httpError(404, "Device not found")
-        } else {
-            if(device.hasCommand("setCoolingSetpoint")) {
-               device.setCoolingSetpoint(params.temp.toInteger());
-                return [result_action: "200"]
-            }
-            else {
-               httpError(510, "Not supported!")
-            }
-       }
-}
-def setHeatTemp() {
-       def device = thermostats.find { it.id == params.id }
-        if (!device) {
-            httpError(404, "Device not found")
-        } else {
-            if(device.hasCommand("setHeatingSetpoint")) {
-               device.setHeatingSetpoint(params.temp.toInteger());
-                return [result_action: "200"]
-            }
-            else {
-               httpError(510, "Not supported!")
-            }
-       }
-}
-def setFanMode() {
-       def device = thermostats.find { it.id == params.id }
-        if (!device) {
-            httpError(404, "Device not found")
-        } else {
-        if(device.hasCommand("setThermostatFanMode")) {
-               device.setThermostatFanMode(params.mode);
-                return [result_action: "200"]
-            }
-            else {
-               httpError(510, "Not supported!")
-            }
-       }
-}
-def setThermostatMode() {
-       def device = thermostats.find { it.id == params.id }
-        if (!device) {
-            httpError(404, "Device not found")
-        } else {
-        if(device.hasCommand("setThermostatMode")) {
-               device.setThermostatMode(params.mode);
-                return [result_action: "200"]
-            }
-            else {
-               httpError(510, "Not supported!")
-            }
-       }
-}
-def getThermostatStatus() {
-       def device = thermostats.find{ it.id == params.id }
-    if (!device) {
-            httpError(404, "Device not found")
-        } else {
-               return [ThermostatOperatingState: device.currentValue('thermostatOperatingState'), ThermostatSetpoint: device.currentValue('thermostatSetpoint'), 
-                               ThermostatFanMode: device.currentValue('thermostatFanMode'), ThermostatMode: device.currentValue('thermostatMode')]
-               }
-}
-*/
 //light
 def turnOnLight() {
     def device = switches.find { it.id == params.id }
@@ -453,15 +386,6 @@ def getKelvinStatus(id) {
 }
 
 //switch level
-def getLevelStatus() {
-       def device = switchlevels.find { it.id == params.id }
-    if (!device) {
-            [Level: "No dimmer"]
-        } else {
-               return [Level: device.currentValue('level')]
-        }
-}
-
 def getLevelStatus(id) {
        def device = switchlevels.find { it.id == id }
     if (!device) {
@@ -596,15 +520,6 @@ def getWaterSensorStatus() {
         }
 }
 //batteries
-def getBatteryStatus() {
-       def device = batteries.find { it.id == params.id }
-    if (!device) {
-            httpError(404, "Device not found")
-        } else {
-               return [Device_state: device.latestValue("battery")]
-        }
-}
-
 def getBatteryStatus(id) {
        def device = batteries.find { it.id == id }
     if (!device) {
@@ -687,16 +602,6 @@ def getOutletStatus() {
      return [Device_state: device.currentValue('switch')] + watt
 }
 
-def getMeterStatus() {
-
-    def device = meters.find { it.id == params.id }
-       if (!device) {
-            httpError(404, "Device not found")
-        } else {
-               return [Device_id: device.id, Device_type: device.type, Current_watt: device.currentValue("power")]
-  }
-}
-
 def getMeterStatus(id) {
 
     def device = meters.find { it.id == id }
@@ -772,17 +677,6 @@ def turnOffSwitch() {
 
 
 //TEMPERATURE
-def getTempSensorsStatus() {
-    def device = temperature_sensors.find { it.id == params.id }
-    if (!device) {
-            httpError(404, "Device not found")
-        } else {
-               def bat = getBatteryStatus(device.id)
-            def scale = [Scale: location.temperatureScale]
-               return [Device_state: device.currentValue('temperature')] + scale + bat
-   }
-}
-
 def getTempSensorsStatus(id) { 
     def device = temperature_sensors.find { it.id == id }
     if (!device) {
@@ -791,4 +685,4 @@ def getTempSensorsStatus(id) {
                def bat = getBatteryStatus(device.id)
                return [temperature: device.currentValue('temperature')] + bat
                }
-   }
\ No newline at end of file
+   }