Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
authoramiraj <amiraj.95@uci.edu>
Wed, 29 Jan 2020 19:07:47 +0000 (11:07 -0800)
committeramiraj <amiraj.95@uci.edu>
Wed, 29 Jan 2020 19:07:47 +0000 (11:07 -0800)
85 files changed:
AccelerationSensor/AccelerationSensor.groovy
AccelerationSensor/AccelerationSensors.groovy
AeonKeyFob/AeonKeyFob.groovy
AeonKeyFob/AeonKeyFobs.groovy
Alarm/Alarm.groovy
Alarm/Alarms.groovy
Battery/Batteries.groovy
Battery/Battery.groovy
BeaconSensor/BeaconSensor.groovy
BeaconSensor/BeaconSensors.groovy
Button/Button.groovy
Button/Buttons.groovy
CarbonMonoxideDetector/CarbonMonoxideDetector.groovy
CarbonMonoxideDetector/CarbonMonoxideDetectors.groovy
ColorControl/ColorControl.groovy
ColorControl/ColorControls.groovy
ColorTemperature/ColorTemperature.groovy
ColorTemperature/ColorTemperatures.groovy
ContactSensor/ContactSensor.groovy
ContactSensor/ContactSensors.groovy
DoorControl/DoorControl.groovy
DoorControl/DoorControls.groovy
EnergyMeter/EnergyMeter.groovy
EnergyMeter/EnergyMeters.groovy
IlluminanceMeasurement/IlluminanceMeasurement.groovy
IlluminanceMeasurement/IlluminanceMeasurements.groovy
ImageCapture/ImageCapture.groovy
ImageCapture/ImageCaptures.groovy
Location/LocationVar.groovy
Lock/Lock.groovy
Lock/Locks.groovy
Methods/setLocationMode.groovy
Methods/subscribe.groovy
MobilePresence/MobilePresence.groovy
MobilePresence/MobilePresences.groovy
Momentary/Momentaries.groovy
Momentary/Momentary.groovy
MotionSensor/MotionSensor.groovy
MotionSensor/MotionSensors.groovy
MusicPlayer/MusicPlayer.groovy
MusicPlayer/MusicPlayers.groovy
MutableInteger/MutableInteger.groovy [deleted file]
NfcTouch/NfcTouch.groovy
PowerMeter/PowerMeter.groovy
PowerMeter/PowerMeters.groovy
PresenceSensor/PresenceSensor.groovy
PresenceSensor/PresenceSensors.groovy
RelativeHumidityMeasurement/RelativeHumidityMeasurement.groovy
RelativeHumidityMeasurement/RelativeHumidityMeasurements.groovy
RelaySwitch/RelaySwitch.groovy
RelaySwitch/RelaySwitches.groovy
SleepSensor/SleepSensor.groovy
SleepSensor/SleepSensors.groovy
SmartThing/SmartThing.groovy
SmartThing/SmartThings.groovy
SmokeDetector/SmokeDetector.groovy
SmokeDetector/SmokeDetectors.groovy
SpeechSynthesis/SpeechSynthesis.groovy
SpeechSynthesis/SpeechSynthesises.groovy
StepSensor/StepSensor.groovy
StepSensor/StepSensors.groovy
Switch/Switch.groovy
Switch/Switches.groovy
SwitchLevel/SwitchLevel.groovy
SwitchLevel/SwitchLevels.groovy
TemperatureMeasurement/TemperatureMeasurement.groovy
TemperatureMeasurement/TemperatureMeasurements.groovy
Thermostat/Thermostat.groovy
Thermostat/Thermostats.groovy
ThreeAxis/ThreeAxis.groovy
ThreeAxis/ThreeAxises.groovy
Valve/Valve.groovy
Valve/Valves.groovy
WaterSensor/WaterSensor.groovy
WaterSensor/WaterSensors.groovy
appTouch/Touched.groovy
eventSimulator/doorClosedEvent.groovy
eventSimulator/doorOpenEvent.groovy
eventSimulator/locationAwayEvent.groovy
eventSimulator/locationHomeEvent.groovy
eventSimulator/locationNightEvent.groovy
eventSimulator/modeHomeEvent.groovy
eventSimulator/motionActiveEvent.groovy
eventSimulator/nfcTouchEvent.groovy
eventSimulator/unlockEvent.groovy

index 3352e7d..66cae29 100644 (file)
@@ -4,38 +4,29 @@ import SmartThing.SmartThing
 
 public class AccelerationSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentAcceleration = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
 
-       AccelerationSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentAcceleration) {
-               deviceValuesMap = deviceValueSmartThing
-               deviceIntValuesMap = deviceIntValueSmartThing
+       AccelerationSensor(Closure sendEvent, String id, String label, String displayName, String currentAcceleration) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
-               sendEventSmartThings = sendEvent
                possibleValuesSmartThings = possibleValues
+               sendEventSmartThings = sendEvent
 
                // Initialization
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentAcceleration = currentAcceleration
                possibleValues.add("active")
                possibleValues.add("inactive")
 
                deviceValuesMap.put("acceleration", currentAcceleration)
        }
-
-       // Methods to return values
-       def getCurrentAcceleration() {
-               return currentAcceleration.toString()
-       }
 }
index 5827622..c218c2f 100644 (file)
@@ -9,24 +9,17 @@ public class AccelerationSensors extends SmartThings {
                accelerationSensors = smartThings
 
                // Initialize
-               StringBuilder id = new StringBuilder("accelerationID0")
-               StringBuilder label = new StringBuilder("acceleration")
-               StringBuilder displayName = new StringBuilder("acceleration0")
-               StringBuilder acceleration = new StringBuilder()
+               String id = "accelerationID0"
+               String label = "acceleration"
+               String displayName = "accelerationSensor"
+               String acceleration
 
                // Initialization
                if (init)
-                       acceleration.append("inactive")
+                       acceleration = "inactive"
                else
-                       acceleration.append("active")
+                       acceleration = "active"
 
                accelerationSensors.add(new AccelerationSensor(sendEvent, id, label, displayName, acceleration))
        }
-
-       // Methods to return values
-       def getCurrentAcceleration() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(accelerationSensors[0].getCurrentAcceleration())
-               return tmpValues
-       }
 }
index 6fcdb78..f08cd07 100644 (file)
@@ -4,18 +4,18 @@ import SmartThing.SmartThing
 
 public class AeonKeyFob extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>()
 
-       AeonKeyFob(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName) {
+       AeonKeyFob(Closure sendEvent, String id, String label, String displayName) {
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
-               sendEventSmartThings = sendEvent
                possibleValuesSmartThings = possibleValues
+               sendEventSmartThings = sendEvent
 
                // Initialization
                this.id = id
index bbb45b3..c3dd087 100644 (file)
@@ -9,9 +9,9 @@ public class AeonKeyFobs extends SmartThings {
                aeonKeyFobs = smartThings
                
                // Initialization
-               StringBuilder id = new StringBuilder("aeonKeyFobID0")
-               StringBuilder label = new StringBuilder("button")
-               StringBuilder displayName = new StringBuilder("aeonKeyFob0")
+               String id = "aeonKeyFobID0"
+               String label = "button"
+               String displayName = "aeonKeyFob"
 
                aeonKeyFobs.add(new AeonKeyFob(sendEvent, id, label, displayName))
        }
index f03f5d6..a5cd6f0 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class Alarm extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentAlarm = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       Alarm(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentAlarm) {
-               deviceValuesMap = deviceValueSmartThing
+       Alarm(Closure sendEvent, String id, String label, String displayName, String currentAlarm) {
+               deviceValueSmartThing = deviceValuesMap 
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,44 +21,28 @@ public class Alarm extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentAlarm = currentAlarm
 
                deviceValuesMap.put("alarm", currentAlarm)
        }
 
        // Methods to set values
        def both() {
-               action("both")
+               action("both", "alarm")
        }
 
        def on() {
-               action("both")
+               action("both", "alarm")
        }
 
        def off() {
-               action("off")
+               action("off", "alarm")
        }
 
        def siren() {
-               action("siren")
+               action("siren", "alarm")
        }
 
        def strobe() {
-               action("strobe")
-       }
-
-       def action(String newValue) {
-               if (!currentAlarm.equals(newValue)) {
-                       String tmpID = id.toString()
-                       currentAlarm.replace(0, currentAlarm.length(), newValue)
-                       println("the alarm with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: "alarm", value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentAlarm() {
-               return currentAlarm.toString()
+               action("strobe", "alarm")
        }
 }
index ac37de6..580e65c 100644 (file)
@@ -9,15 +9,15 @@ public class Alarms extends SmartThings {
                alarms = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("alarmID0")
-               StringBuilder label = new StringBuilder("alarm")
-               StringBuilder displayName = new StringBuilder("alarm0")
-               StringBuilder alarm = new StringBuilder()
+               String id = "alarmID0"
+               String label = "alarm"
+               String displayName = "alarmSensor"
+               String alarm
        
                if (init)
-                       alarm.append("off")
+                       alarm = "off"
                else
-                       alarm.append("on")
+                       alarm = "on"
                
                alarms.add(new Alarm(sendEvent, id, label, displayName, alarm))
        }
@@ -42,11 +42,4 @@ public class Alarms extends SmartThings {
        def strobe() {
                alarms[0].strobe()
        }
-
-       // Methods to return values
-       def getCurrentAlarm() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(alarms[0].getCurrentAlarm())
-               return tmpValues
-       }
 }
index 20f213a..636a69c 100644 (file)
@@ -2,33 +2,23 @@
 package Battery
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class Batteries extends SmartThings {
        List batteries = new ArrayList()
 
        Batteries(Closure sendEvent, boolean init) {
                batteries = smartThings
 
-               StringBuilder id = new StringBuilder("batteryID0")
-               StringBuilder label = new StringBuilder("battery")
-               StringBuilder displayName = new StringBuilder("battery0")
-               MutableInteger battery = new MutableInteger()
-
                // Initialization
+               String id = "batteryID0"
+               String label = "battery"
+               String displayName = "batteryDevice"
+               Integer battery
+
                if (init)
-                       battery.setValue(50)
+                       battery = 50
                else
-                       battery.setValue(0)
+                       battery = 0
 
                batteries.add(new Battery(sendEvent, id, label, displayName, battery))
        }
-
-       // Methods to return values
-       def getCurrentBattery() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(batteries[0].getCurrentBattery())
-               return tmpValues
-       }
 }
index 3e4e511..7162d68 100644 (file)
@@ -2,21 +2,16 @@
 package Battery
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class Battery extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentBattery = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       Battery(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentBattery) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       Battery(Closure sendEvent, String id, String label, String displayName, Integer currentBattery) {
+               deviceIntValueSmartThing = deviceIntValuesMap 
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,13 +21,7 @@ public class Battery extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentBattery = currentBattery
 
                deviceIntValuesMap.put("battery", currentBattery)
        }
-
-       // Methods to return values
-       def getCurrentBattery() {
-               return currentBattery.toString()
-       }
 }
index be77c04..6ea78f1 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class BeaconSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentPresence = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       BeaconSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentPresence) {
-               deviceValuesMap = deviceValueSmartThing
+       BeaconSensor(Closure sendEvent, String id, String label, String displayName, String currentPresence) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,13 +21,7 @@ public class BeaconSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentPresence = currentPresence
                
-               deviceValuesMap.put("beacon", currentPresence)
-       }
-
-       // Methods to return values
-       def getCurrentPresence() {
-               return currentPresence.toString()
+               deviceValuesMap.put("presence", currentPresence)
        }
 }
index c5b4cf6..6bc3310 100644 (file)
@@ -9,23 +9,16 @@ public class BeaconSensors extends SmartThings {
                beaconSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("beaconID0")
-               StringBuilder label = new StringBuilder("beacon")
-               StringBuilder displayName = new StringBuilder("beacon0")
-               StringBuilder presence = new StringBuilder()
+               String id = "beaconID0"
+               String label = "beacon"
+               String displayName = "beaconSensor"
+               String presence
 
                if (init)
-                       presence.append("not present")
+                       presence = "not present"
                else
-                       presence.append("present")
+                       presence = "present"
 
                beaconSensors.add(new BeaconSensor(sendEvent, id, label, displayName, presence))
        }
-
-       // Methods to return values
-       def getCurrentPresence() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(beaconSensors[0].getCurrentPresence())
-               return tmpValues
-       }
 }
index bb0399e..37a09cf 100644 (file)
@@ -4,13 +4,13 @@ import SmartThing.SmartThing
 
 public class Button extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
 
-       Button(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName) {
+       Button(Closure sendEvent, String id, String label, String displayName) {
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
index 2b94073..8b9d417 100644 (file)
@@ -9,9 +9,9 @@ public class Buttons extends SmartThings {
                buttons = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("buttonID0")
-               StringBuilder label = new StringBuilder("button")
-               StringBuilder displayName = new StringBuilder("button0")
+               String id = "buttonID0"
+               String label = "button"
+               String displayName = "buttonController"
 
                buttons.add(new Button(sendEvent, id, label, displayName))
        }
index 65f1ce0..045a415 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class CarbonMonoxideDetector extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentCarbonMonoxideValue = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       CarbonMonoxideDetector(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentCarbonMonoxideValue) {
-               deviceValuesMap = deviceValueSmartThing
+       CarbonMonoxideDetector(Closure sendEvent, String id, String label, String displayName, String currentCarbonMonoxideValue) {
+               deviceValueSmartThing = deviceValuesMap 
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,13 +21,7 @@ public class CarbonMonoxideDetector extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentCarbonMonoxideValue = currentCarbonMonoxideValue
 
                deviceValuesMap.put("carbonMonoxide", currentCarbonMonoxideValue)
        }
-
-       // Methods to return values
-       def getCurrentCarbonMonoxideValue() {
-               return currentCarbonMonoxideValue.toString()
-       }
 }
index 162ca8d..1b63600 100644 (file)
@@ -9,23 +9,16 @@ public class CarbonMonoxideDetectors extends SmartThings {
                carbonMonoxideDetectors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("carbonMonoxideID0")
-               StringBuilder label = new StringBuilder("carbonMonoxide")
-               StringBuilder displayName = new StringBuilder("carbonMonoxide0")
-               StringBuilder carbonMonoxide = new StringBuilder()
+               String id = "carbonMonoxideID0"
+               String label = "carbonMonoxide"
+               String displayName = "carbonMonoxideDetector"
+               String carbonMonoxide
 
                if (init)
-                       carbonMonoxide.append("clear")
+                       carbonMonoxide = "clear"
                else
-                       carbonMonoxide.append("detected")
+                       carbonMonoxide = "detected"
 
                carbonMonoxideDetectors.add(new CarbonMonoxideDetector(sendEvent, id, label, displayName, carbonMonoxide))
        }
-
-       // Methods to return values
-       def getCurrentCarbonMonoxideValue() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(carbonMonoxideDetectors[0].getCurrentCarbonMonoxideValue())
-               return tmpValues
-       }
 }
index c278f4a..4380f24 100644 (file)
@@ -2,26 +2,18 @@
 package ColorControl
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class ColorControl extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentHue = new MutableInteger()
-       MutableInteger currentSaturation = new MutableInteger()
-       // Features with string values
-       StringBuilder currentColor = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       ColorControl(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentColor, MutableInteger currentHue, MutableInteger currentSaturation) {
-               deviceValuesMap = deviceValueSmartThing
-               deviceIntValuesMap = deviceIntValueSmartThing
+       ColorControl(Closure sendEvent, String id, String label, String displayName, String currentColor, Integer currentHue, Integer currentSaturation) {
+               deviceValueSmartThing = deviceValuesMap
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -31,9 +23,6 @@ public class ColorControl extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentHue = currentHue
-               this.currentSaturation = currentSaturation
-               this.currentColor = currentColor
 
                deviceValuesMap.put("color", currentColor)
                deviceIntValuesMap.put("hue", currentHue)
@@ -74,11 +63,11 @@ public class ColorControl extends SmartThing {
 
        // Methods to set values
        def setColor(String newValue) {
-               action(currentColor, newValue, "color")
+               action(newValue, "color")
        }
 
        def setHue(int newValue) {
-               action(currentHue, newValue, "hue")
+               action(newValue, "hue")
        }
        
        def setHue(double newValue) {
@@ -86,43 +75,10 @@ public class ColorControl extends SmartThing {
        }
 
        def setSaturation(int newValue) {
-               action(currentSaturation, newValue, "saturation")
+               action(newValue, "saturation")
        }
        
        def setSaturation(double newValue) {
                setSaturation((int) newValue)
        }
-
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the light with id:$id is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       def action(MutableInteger variable, int newValue, String feature) {
-               if (!variable.getValue().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.setValue(newValue)
-                       println("$feature of the light with id:$id is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentHue() {
-               return currentHue.getValue()
-       }
-
-       def getCurrentSaturation() {
-               return currentSaturation.getValue()
-       }
-       
-       def getCurrentColor() {
-               return currentColor.toString()
-       }
 }
index c74f99b..68fd6f0 100644 (file)
@@ -13,21 +13,21 @@ public class ColorControls extends SmartThings {
                colorControls = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("colorControlID0")
-               StringBuilder label = new StringBuilder("colorControl")
-               StringBuilder displayName = new StringBuilder("colorControl0")
-               StringBuilder color = new StringBuilder()
-               MutableInteger hue = new MutableInteger()
-               MutableInteger saturation = new MutableInteger()
+               String id = "colorControlID0"
+               String label = "colorControl"
+               String displayName = "light"
+               String color
+               Integer hue
+               Integer saturation
 
                if (init) {
-                       color.append("Red")
-                       hue.setValue(30)
-                       saturation.setValue(40)
+                       color = "Red"
+                       hue = 30
+                       saturation = 40
                } else {                
-                       color.append("Blue")
-                       hue.setValue(50)
-                       saturation.setValue(50)
+                       color = "Blue"
+                       hue = 50
+                       saturation = 50
                }
 
                colorControls.add(new ColorControl(sendEvent, id, label, displayName, color, hue,
@@ -66,23 +66,4 @@ public class ColorControls extends SmartThings {
        def off() {
                colorControls[0].off()
        }
-
-       // Methods to return values
-       def getCurrentHue() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(colorControls[0].getCurrentHue())
-               return tmpValues
-       }
-
-       def getCurrentSaturation() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(colorControls[0].getCurrentSaturation())
-               return tmpValues
-       }
-       
-       def getCurrentColor() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(colorControls[0].getCurrentColor())
-               return tmpValues
-       }
 }
index 6cb9b39..08f91be 100644 (file)
@@ -2,21 +2,16 @@
 package ColorTemperature
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class ColorTemperature extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentColorTemperature = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       ColorTemperature(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger colorTemperature) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       ColorTemperature(Closure sendEvent, String id, String label, String displayName, Integer colorTemperature) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,24 +21,12 @@ public class ColorTemperature extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentColorTemperature = currentColorTemperature
 
                deviceIntValuesMap.put("colorTemperature", currentColorTemperature)
        }
 
        // Methods to set values
        def setColorTemperature(int newValue) {
-               if (!currentColorTemperature.getValue().equals(newValue)) {
-                       String tmpID = id.toString()
-                       currentColorTemperature.setValue(newValue)
-                       println("The color temperature of the light with id $tmpID is changed to $newValue!")
-                       sendEvent([name: "colorTemperature", value: "$newValue", deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentColorTemperature() {
-               return currentColorTemperature.getValue()
+               action(newValue, "colorTemperature")
        }
 }
index 5e70db6..1cc0aaa 100644 (file)
@@ -2,9 +2,6 @@
 package ColorTemperature
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class ColorTemperatures extends SmartThings {
        List colorTemperatues = new ArrayList()
 
@@ -13,10 +10,10 @@ public class ColorTemperatures extends SmartThings {
                colorTemperatues = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("colorTemperatureID0")
-               StringBuilder label = new StringBuilder("colorTemperature")
-               StringBuilder displayName = new StringBuilder("colorTemperature0")
-               MutableInteger colorTemperatue = new MutableInteger()
+               String id = "colorTemperatureID0"
+               String label = "colorTemperature"
+               String displayName = "light"
+               Integer colorTemperatue
 
                if (init)
                        colorTemperature = 10000
@@ -30,11 +27,4 @@ public class ColorTemperatures extends SmartThings {
        def setColorTemperature(int newValue) {
                colorTemperatues[0].setColorTemperature(newValue)
        }
-
-       // Methods to return values
-       def getCurrentColorTemperature() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(colorTemperatues[0].getCurrentColorTemperature())
-               return tmpValues
-       }
 }
index 91fdfd1..e93ce58 100644 (file)
@@ -4,18 +4,16 @@ import SmartThing.SmartThing
 
 public class ContactSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentContact = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
 
-       ContactSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentContact) {
-               deviceValuesMap = deviceValueSmartThing
+       ContactSensor(Closure sendEvent, String id, String label, String displayName, String currentContact) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,15 +24,9 @@ public class ContactSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentContact = currentContact
                possibleValues.add("closed")
                possibleValues.add("open")
 
                deviceValuesMap.put("contact", currentContact)
        }
-
-       // Methods to return values
-       def getCurrentContact() {
-               return currentContact.toString()
-       }
 }
index 9889793..0e4130e 100644 (file)
@@ -10,23 +10,16 @@ public class ContactSensors extends SmartThings {
                contacts = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("contactID0")
-               StringBuilder label = new StringBuilder("contact")
-               StringBuilder displayName = new StringBuilder("contact0")
-               StringBuilder currentContact = new StringBuilder()
+               String id = "contactID0"
+               String label = "contact"
+               String displayName = "contactSensor"
+               String currentContact
                
                if (init)
-                       currentContact.append("closed")
+                       currentContact = "closed"
                else
-                       currentContact.append("open")
+                       currentContact = "open"
 
                contacts.add(new ContactSensor(sendEvent, id, label, displayName, currentContact))
        }
-
-       // Methods to return values
-       def getCurrentContact() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(contacts[0].getCurrentContact())
-               return tmpValues
-       }
 }
index d002727..a72e5f7 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class DoorControl extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentDoorState = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       DoorControl(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentDoorState) {
-               deviceValuesMap = deviceValueSmartThing
+       DoorControl(Closure sendEvent, String id, String label, String displayName, String currentDoor) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,14 +21,13 @@ public class DoorControl extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentDoorState = currentDoorState
 
-               deviceValuesMap.put("status", currentDoorState)
+               deviceValuesMap.put("door", currentDoor)
        }
 
        // Methods to set values
        def open() {
-               action(currentDoorState, "open", "status")
+               action("open", "door")
        }
 
        def open(LinkedHashMap metaData) {
@@ -38,25 +35,10 @@ public class DoorControl extends SmartThing {
        }
 
        def close() {
-               action(currentDoorState, "closed", "status")
+               action("closed", "door")
        }
 
        def close(LinkedHashMap metaData) {
                close()
        }
-
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the door with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentDoorState() {
-               return currentDoorState.toString()
-       }
 }
index 069a161..c9630d8 100644 (file)
@@ -10,17 +10,17 @@ public class DoorControls extends SmartThings {
                doorControls = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("doorControlID0")
-               StringBuilder label = new StringBuilder("doorControl")
-               StringBuilder displayName = new StringBuilder("doorControl0")
-               StringBuilder doorState = new StringBuilder()
+               String id = "doorControlID0"
+               String label = "doorControl"
+               String displayName = "doorController"
+               String door
 
                if (init)
-                       doorState.append("open")
+                       door = "open"
                else
-                       doorState.append("closed")
+                       door = "closed"
 
-               doorControls.add(new DoorControl(sendEvent, id, label, displayName, doorState))
+               doorControls.add(new DoorControl(sendEvent, id, label, displayName, door))
        }
 
        // Methods to set values
@@ -39,11 +39,4 @@ public class DoorControls extends SmartThings {
        def close(LinkedHashMap metaData) {
                close()
        }
-
-       // Methods to return values
-       def getCurrentDoorState() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(doorControls[0].getCurrentDoorState())
-               return tmpValues
-       }
 }
index 9324ca3..f41c741 100644 (file)
@@ -2,21 +2,16 @@
 package EnergyMeter
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class EnergyMeter extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentEnergy = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       EnergyMeter(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentEnergy) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       EnergyMeter(Closure sendEvent, String id, String label, String displayName, Integer currentEnergy) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,13 +21,7 @@ public class EnergyMeter extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentEnergy = currentEnergy
 
                deviceIntValuesMap.put("energy", currentEnergy)
        }
-
-       // Methods to return values
-       def getCurrentEnergy() {
-               return currentEnergy.getValue()
-       }
 }
index 3722a2b..1cb2839 100644 (file)
@@ -2,9 +2,6 @@
 package EnergyMeter
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class EnergyMeters extends SmartThings {
        List energyMeters = new ArrayList()
 
@@ -13,23 +10,16 @@ public class EnergyMeters extends SmartThings {
                energyMeters = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("energyID0")
-               StringBuilder label = new StringBuilder("energy")
-               StringBuilder displayName = new StringBuilder("energy0")
-               MutableInteger energy = new MutableInteger()
+               String id = "energyID0"
+               String label = "energy"
+               String displayName = "energyMeter"
+               Integer energy
 
                if (init)
-                       energy.setValue(50)
+                       energy = 50
                else
-                       energy.setValue(60)
+                       energy = 60
 
                energyMeters.add(new EnergyMeter(sendEvent, id, label, displayName, energy))
        }
-
-       // Methods to return values
-       def getCurrentEnergy() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(energyMeters[0].getCurrentEnergy())
-               return tmpValues
-       }
 }
index 85ae10a..c62d9d8 100644 (file)
@@ -2,21 +2,16 @@
 package IlluminanceMeasurement
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class IlluminanceMeasurement extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentIlluminance = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       IlluminanceMeasurement(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentIlluminance) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       IlluminanceMeasurement(Closure sendEvent, String id, String label, String displayName, Integer currentIlluminance) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,13 +21,7 @@ public class IlluminanceMeasurement extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentIlluminance = currentIlluminance
 
                deviceIntValuesMap.put("illuminance", currentIlluminance)
        }
-
-       // Methods to return values
-       def getCurrentIlluminance() {
-               return currentIlluminance.getValue()
-       }
 }
index 0944a02..5977e46 100644 (file)
@@ -2,34 +2,23 @@
 package IlluminanceMeasurement
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class IlluminanceMeasurements extends SmartThings {
        List illuminanceMeasurements = new ArrayList()
                
        IlluminanceMeasurements(Closure sendEvent, boolean init) {
-               // Only initialize one time since we only have one device for each capability
                illuminanceMeasurements = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("illuminanceID0")
-               StringBuilder label = new StringBuilder("illuminance")
-               StringBuilder displayName = new StringBuilder("illuminance0")
-               MutableInteger illuminance = new MutableInteger()
+               String id = "illuminanceID0"
+               String label = "illuminance"
+               String displayName = "illuminanceSensor"
+               Integer illuminance
 
                if (init)
-                       illuminance.setValue(20000)
+                       illuminance = 20000
                else
-                       illuminance.setValue(5)
+                       illuminance = 5
 
                illuminanceMeasurements.add(new IlluminanceMeasurement(sendEvent, id, label, displayName, illuminance))
        }
-
-       // Methods to return values
-       def getCurrentIlluminance() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(illuminanceMeasurements[0].getCurrentIlluminance())
-               return tmpValues
-       }
 }
index a8ab0ee..1ba517e 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class ImageCapture extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentImage = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       ImageCapture(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentImage) {
-               deviceValuesMap = deviceValueSmartThing
+       ImageCapture(Closure sendEvent, String id, String label, String displayName, String currentImage) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,22 +21,15 @@ public class ImageCapture extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentImage = currentImage
 
                deviceValuesMap.put("image", currentImage)
        }
 
        def take() {
-               String tmpID = id.toString()
-               println("The camera with id:$tmpID is taken a picture!")
+               println("The camera with id:$id is taken a picture!")
        }
 
        def take(LinkedHashMap metaData) {
                take()
        }
-
-       // Methods to return values
-       def getCurrentImage() {
-               return currentImage.toString()
-       }
 }
index 0b6c447..befb42b 100644 (file)
@@ -10,10 +10,10 @@ public class ImageCaptures extends SmartThings {
                imageCaptureSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("imageCaptureID0")
-               StringBuilder label = new StringBuilder("imageCapture")
-               StringBuilder displayName = new StringBuilder("imageCapture0")
-               StringBuilder image = new StringBuilder("image0")
+               String id = "imageCaptureID0"
+               String label = "imageCapture"
+               String displayName = "imageCapturer"
+               String image = "image0"
 
                imageCaptureSensors.add(new ImageCapture(sendEvent, id, label, displayName, image))
        }
@@ -25,11 +25,4 @@ public class ImageCaptures extends SmartThings {
        def take(LinkedHashMap metaData) {
                take()
        }
-       
-       // Methods to return values
-       def getCurrentImage() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(imageCaptureSensors[0].getCurrentImage())
-               return tmpValues
-       }
 }
index e7328c5..6a8e6d3 100755 (executable)
@@ -2,19 +2,14 @@
 package Location
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class LocationVar extends SmartThing {
-       // Features with numberical values
-       MutableInteger contactBookEnabled = new MutableInteger()
-       // Features with string values
-       StringBuilder mode = new StringBuilder()
-       StringBuilder locationMode = mode
-       StringBuilder name = new StringBuilder()
-       StringBuilder temperatureScale = new StringBuilder()
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
        // Other variables
        Phrase helloHome
        TimeZone timeZone
@@ -24,24 +19,20 @@ public class LocationVar extends SmartThing {
        List phoneNumbers
        
        LocationVar(Closure sendEvent, boolean init) {
-                       deviceValuesMap = deviceValueSmartThing
+                       deviceValueSmartThing = deviceValuesMap
+                       deviceIntValueSmartThing = deviceIntValuesMap
+                       idSmartThing = id
+                       labelSmartThing = label
+                       displayNameSmartThing = displayName
                        sendEventSmartThings = sendEvent
 
                        // Initialization
-                       StringBuilder sunset = new StringBuilder("sunset")
-                       StringBuilder sunsetTime = sunset
-                       StringBuilder sunrise = new StringBuilder("sunrise")
-                       StringBuilder sunriseTime = sunrise
-                       hubs = [[id:0, localIP:"128.195.204.105"]]
-                       modes = [[name: "home"],[name: "away"],[name: "night"]]
                        helloHome = new Phrase()
-                       contactBookEnabled.setValue(1)
                        contacts = ['AJ']
                        phoneNumbers = [9495379373]
-                       name.append("hub0")
-                       temperatureScale.append("F")
+                       modes = [[name: "home"],[name: "away"],[name: "night"]]
                        timeZone = TimeZone.getTimeZone("America/New_York")
-                       
+                       hubs = [[id:0, localIP:"128.195.204.105"]]
 
                        if (init)
                                mode.append("away")     
@@ -49,27 +40,12 @@ public class LocationVar extends SmartThing {
                                mode.append("home")
 
                        deviceValuesMap.put("mode", mode)
-                       deviceValuesMap.put("Location", mode)
+                       deviceValuesMap.put("name", "hub0")
+                       deviceValuesMap.put("temperatureScale", "F")
+                       deviceValuesMap.put("sunset", "sunset")
+                       deviceValuesMap.put("sunrise", "sunrise")
+                       deviceValuesMap.put("sunsetTime", "sunsetTime")
+                       deviceValuesMap.put("sunriseTime", "sunriseTime")
+                       deviceIntValuesMap.put("contactBookEnabled", 1)
        }
-
-       // Methods to return values
-       def getMode() {
-               return mode.toString()
-       }
-
-       def getLocationMode() {
-               return locationMode.toString()
-       }
-
-       def getName() {
-               return name.toString()
-       }
-
-       def getTemperatureScale() {
-               return temperatureScale.toString()
-       }
-
-       def getContactBookEnabled() {
-               return contactBookEnabled.getValue()
-       }
 }
index 1ceac32..50b96e4 100644 (file)
@@ -4,17 +4,14 @@ import SmartThing.SmartThing
 
 public class Lock extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentLock = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-
-       Lock(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentLock) {
-               deviceValuesMap = deviceValueSmartThing
+       Lock(Closure sendEvent, String id, String label, String displayName, String currentLock) {
+               deviceValueSmartThing = deviceValuesMap 
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -24,14 +21,13 @@ public class Lock extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentLock = currentLock
 
                deviceValuesMap.put("lock", currentLock)
        }
 
        // Methods to set values
        def lock() {
-               action(currentLock, "locked")
+               action("locked", "lock")
        }
 
        def lock(LinkedHashMap metaData) {
@@ -39,26 +35,10 @@ public class Lock extends SmartThing {
        }
        
        def unlock() {
-               action(currentLock, "unlocked")
+               action("unlocked", "lock")
        }
 
        def unlock(LinkedHashMap metaData) {
                unlock()
        }
-
-       def action(StringBuilder variable, String newValue) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("Lock with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: "lock", value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentLock() {
-               return currentLock.toString()
-       }
-
 }
index 381bf2a..37deb0a 100644 (file)
@@ -10,17 +10,17 @@ public class Locks extends SmartThings {
                locks = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("lockID0")
-               StringBuilder label = new StringBuilder("lock")
-               StringBuilder displayName = new StringBuilder("lock0")
-               StringBuilder lock = new StringBuilder()
+               String id = "lockID0"
+               String label = "lock"
+               String displayName = "lock"
+               String lock
 
                if (init)
-                       lock.append("locked")
+                       lock = "locked"
                else
-                       lock.append("unlocked")
+                       lock = "unlocked"
 
-               locks.add(new Lock(sendEvent,id, label, displayName, lock))
+               locks.add(new Lock(sendEvent, id, label, displayName, lock))
        }
 
        // Methods to set values
@@ -40,12 +40,5 @@ public class Locks extends SmartThings {
        def unlock(LinkedHashMap metaData) {
                unlock()
        }
-
-       // Methods to return values
-       def getCurrentLock() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(locks[0].getCurrentLock())
-               return tmpValues
-       }
 }
 
index 12433ab..ece6c86 100644 (file)
@@ -1,8 +1,6 @@
 /////////////////////////////////////////////////////////////////////
 def setLocationMode(String mode) {
        log.debug "DEBUG: setLocationMode is called. Current mode is: ${location_mode} and new mode is: ${mode}"
-       location.setValue([name: "Location", value: "$mode", deviceId: "locationID0", descriptionText: "",
-                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        location.setValue([name: "mode", value: "$mode", deviceId: "locationID0", descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        location_mode = mode
index a387375..d77c88f 100644 (file)
@@ -8,7 +8,7 @@ def subscribe(Object obj, Closure FunctionToCall) {
                functionList.add(FunctionToCall)
        } else if (obj == location) {
                objectList.add(obj)
-               eventList.add("Location")
+               eventList.add("mode")
                 valueList.add("")
                functionList.add(FunctionToCall)
        }
@@ -18,11 +18,6 @@ def subscribe(Object obj, Closure FunctionToCall) {
 def subscribe(Object obj, String event, Closure FunctionToCall) {
     if (event == "tamper.tampered") {
        event = "contact"      //This really should be its own name
-    } else if ((event == "mode")||(event == "mode.away")||(event == "mode.home")||(event == "mode.night")) {
-       //This really should be fixed also...
-       event = "Location"
-    } else if (event == "unlocked") {
-      return
     }
     
     int dot = event.indexOf('.')
@@ -44,10 +39,6 @@ def subscribe(Object obj, String event, Closure FunctionToCall) {
 def subscribe(Object obj, String event, String FunctionToCall) {
     if (event == "tamper.tampered") {
        event = "contact"      //This really should be its own name
-    } else if ((event == "mode")||(event == "mode.away")||(event == "mode.home")||(event == "mode.night")) {
-       event = "Location"
-    } else if (event == "unlocked") {
-       return
     }
 
     int dot = event.indexOf('.')
index 7e6ff0a..ddc1ba4 100644 (file)
@@ -4,16 +4,13 @@ import SmartThing.SmartThing
 
 public class MobilePresence extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder deviceNetworkId = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
        
-
-       MobilePresence(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder deviceNetworkId) {
+       MobilePresence(Closure sendEvent, String id, String label, String displayName, String deviceNetworkId) {
                deviceValuesMap = deviceValueSmartThing
                idSmartThing = id
                labelSmartThing = label
@@ -24,13 +21,7 @@ public class MobilePresence extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.deviceNetworkId = deviceNetworkId
 
                deviceValuesMap.put("deviceNetworkId", deviceNetworkId)
        }
-
-       // Methods to return values
-       def getDeviceNetworkId() {
-               return deviceNetworkId.toString()
-       }
 }
index 2cea988..d619868 100644 (file)
@@ -10,18 +10,11 @@ public class MobilePresences extends SmartThings {
                mobilePresences = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("mobileDeviceID0")
-               StringBuilder label = new StringBuilder("mobileDevice")
-               StringBuilder displayName = new StringBuilder("mobileDevice0")
-               StringBuilder deviceNetworkId = new StringBuilder("mobile0")
+               String id = "mobileDeviceID0"
+               String label = "mobileDevice"
+               String displayName = "mobileDevice"
+               String deviceNetworkId
 
                mobilePresences.add(new MobilePresence(sendEvent, id, label, displayName, deviceNetworkId))
        }
-
-       // Methods to return values
-       def getDeviceNetworkId() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(mobilePresences[0].getDeviceNetworkId())
-               return tmpValues
-       }
 }
index f08ea09..0a6c2ac 100644 (file)
@@ -10,9 +10,9 @@ public class Momentaries extends SmartThings {
                momentaries = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("momentaryID0")
-               StringBuilder label = new StringBuilder("momentary")
-               StringBuilder displayName = new StringBuilder("momentary0")
+               String id = "momentaryID0"
+               String label = "momentary"
+               String displayName = "momentaryDevice"
 
                momentaries.add(new Momentary(sendEvent, id, label, displayName))
        }
index 4e72815..27e49c2 100644 (file)
@@ -4,11 +4,11 @@ import SmartThing.SmartThing
 
 public class Momentary extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
 
-       Momentary(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName) {
+       Momentary(Closure sendEvent, String id, String label, String displayName) {
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -22,8 +22,7 @@ public class Momentary extends SmartThing {
 
        // Methods to set values
        def push() {
-               println("the momentary switch with id:$id is pushed!")
-               sendEvent([name: "momentary", value: "pushed", deviceId: id, descriptionText: "",
-                          displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               setValue([name: "momentary", value: "pushed", deviceId: id, descriptionText: "",
+                         displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }       
 }
index 85b5618..5cb2bef 100644 (file)
@@ -4,18 +4,16 @@ import SmartThing.SmartThing
 
 public class MotionSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentMotion = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
 
-       MotionSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentMotion) {
-               deviceValuesMap = deviceValueSmartThing
+       MotionSensor(Closure sendEvent, String id, String label, String displayName, String currentMotion) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,15 +24,9 @@ public class MotionSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentMotion = currentMotion
                possibleValues.add("active")
                possibleValues.add("inactive")
 
                deviceValuesMap.put("motion", currentMotion)
        }
-
-       // Methods to return values
-       def getCurrentMotion() {
-               return currentMotion.toString()
-       }
 }
index 194fc3f..1638490 100644 (file)
@@ -10,23 +10,16 @@ public class MotionSensors extends SmartThings {
                motionSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("motionSensorID0")
-               StringBuilder label = new StringBuilder("motion")
-               StringBuilder displayName = new StringBuilder("motionSensor0")
-               StringBuilder motion = new StringBuilder()
+               String id = "motionSensorID0"
+               String label = "motion"
+               String displayName = "motionSensor"
+               String motion
 
                if (init)
-                       motion.append("inactive")
+                       motion = "inactive"
                else
-                       motion.append("active")
+                       motion = "active"
 
                motionSensors.add(new MotionSensor(sendEvent, id, label, displayName, motion))
        }
-
-       // Methods to return values
-       def getCurrentMotion() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(motionSensors[0].getCurrentMotion())
-               return tmpValues
-       }
 }
index 481c0ac..425b3ca 100644 (file)
@@ -2,31 +2,21 @@
 package MusicPlayer
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class MusicPlayer extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentLevel = new MutableInteger()
-       // Features with string values
-       StringBuilder currentMute = new StringBuilder()
-       StringBuilder currentStatus = new StringBuilder()
-       StringBuilder currentTrackData = new StringBuilder()
-       StringBuilder currentTrackDescription = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
        
-       MusicPlayer(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentLevel, 
-                   StringBuilder currentMute, StringBuilder currentStatus, StringBuilder currentTrackData, StringBuilder currentTrackDescription) {
-               deviceValuesMap = deviceValueSmartThing
-               deviceIntValuesMap = deviceIntValueSmartThing
+       MusicPlayer(Closure sendEvent, String id, String label, String displayName, Integer currentLevel, 
+                   String currentMute, String currentStatus, String currentTrackData, String currentTrackDescription) {
+               deviceValueSmartThing = deviceValuesMap
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -37,15 +27,10 @@ public class MusicPlayer extends SmartThing {
                this.id = id
                this.label = label
                this.currentLevel = currentLevel
-               this.currentMute = currentMute
-               this.currentStatus = currentStatus
-               this.currentTrackData = currentTrackData
-               this.currentTrackDescription = currentTrackDescription
                possibleValues.add("on")
                possibleValues.add("off")
 
                deviceValuesMap.put("status", currentStatus)
-               deviceValuesMap.put("playpause", currentStatus)
                deviceValuesMap.put("trackDescription", currentTrackDescription)
                deviceValuesMap.put("mute", currentMute)
                deviceValuesMap.put("trackData", currentTrackData)
@@ -58,7 +43,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def on() {
-               action(currentStatus, "on", "status")
+               action("on", "status")
        }
 
        def off(LinkedHashMap metaData) {
@@ -66,7 +51,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def off() {
-               action(currentStatus, "off", "status")
+               action("off", "status")
        }
 
        def mute(LinkedHashMap metaData) {
@@ -74,7 +59,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def mute() {
-               action(currentMute, "muted", "mute")
+               action("muted", "mute")
        }
 
        def unmute(LinkedHashMap metaData) {
@@ -82,7 +67,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def unmute() {
-               action(currentMute, "unmuted", "mute")
+               action("unmuted", "mute")
        }
 
        def nextTrack(LinkedHashMap metaData) {
@@ -99,7 +84,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def pause() {
-               action(currentStatus, "pause", "status")
+               action("pause", "status")
        }
 
        def play(LinkedHashMap metaData) {
@@ -107,7 +92,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def play() {
-               action(currentStatus, "play", "status")
+               action("play", "status")
        }
 
        def playTrack(LinkedHashMap metaData) {
@@ -150,7 +135,7 @@ public class MusicPlayer extends SmartThing {
        }
 
        def setLevel(int level) {
-               action(currentLevel, level, "level")
+               action(level, "level")
        }
 
        def setTrack(LinkedHashMap metaData) {
@@ -167,54 +152,13 @@ public class MusicPlayer extends SmartThing {
        }
 
        def stop() {
-               action(currentStatus, "stop", "status")
-       }
-
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the music player with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       def action(MutableInteger variable, int newValue, String feature) {
-               if (!variable.getValue().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.setValue(newValue)
-                       println("$feature for the thermostat with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
+               action("stop", "status")
        }
 
        def musicChangeEvents() {
-               sendEvent([name: "trackDescription", value: "someDescriptions", deviceId: id.toString(), descriptionText: "",
+               setValue([name: "trackDescription", value: "someDescriptions", deviceId: id.toString(), descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               sendEvent([name: "trackData", value: "someTrack", deviceId: id.toString(), descriptionText: "",
+               setValue([name: "trackData", value: "someTrack", deviceId: id.toString(), descriptionText: "",
                           displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
        }
-
-       // Methods to return values
-       def getCurrentLevel() {
-               return currentLevel.getValue()
-       }
-
-       def getCurrentMute() {
-               return currentMute.toString()
-       }
-       
-       def getCurrentStatus() {
-               return currentStatus.toString()
-       }
-
-       def getCurrentTrackData() {
-               return currentTrackData.toString()
-       }
-
-       def getCurrentTrackDescription() {
-               return currentTrackDescription.toString()
-       }
 }
index 0e88a88..c10978e 100644 (file)
@@ -2,9 +2,6 @@
 package MusicPlayer
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class MusicPlayers extends SmartThings {
        List musicPlayers = new ArrayList()
        
@@ -13,27 +10,27 @@ public class MusicPlayers extends SmartThings {
                musicPlayers = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("musicPlayerID0")
-               StringBuilder label = new StringBuilder("status")
-               StringBuilder displayName = new StringBuilder("musicPlayer0")
-               StringBuilder mute = new StringBuilder()
-               StringBuilder status = new StringBuilder()
-               StringBuilder trackData = new StringBuilder()
-               StringBuilder trackDescription = new StringBuilder()
-               MutableInteger level = new MutableInteger()
+               String id = "musicPlayerID0"
+               String label = "status"
+               String displayName = "musicPlayer"
+               String mute
+               String status
+               String trackData
+               String trackDescription
+               Integer level
 
                if (init) {
-                       level.setValue(20)
-                       mute.append("unmuted")
-                       status.append("paused")
-                       trackData.append("someTrack")
-                       trackDescription.append("someDescriptions")
+                       level = 20
+                       mute = "unmuted"
+                       status = "paused"
+                       trackData = "someTrack"
+                       trackDescription = "someDescriptions"
                } else {
-                       level.setValue(30)
-                       mute.append("muted")
-                       status.append("play")
-                       trackData.append("someTrack")
-                       trackDescription.append("someDescriptions")
+                       level = 30
+                       mute = "muted"
+                       status = "play"
+                       trackData = "someTrack"
+                       trackDescription = "someDescriptions"
                }
 
                musicPlayers.add(new MusicPlayer(sendEvent, id, label, displayName, level, mute, status, trackData, trackDescription))
@@ -151,35 +148,4 @@ public class MusicPlayers extends SmartThings {
        def stop() {
                musicPlayers[0].stop()
        }
-
-       // Methods to return values
-       def getCurrentLevel() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(musicPlayers[0].getCurrentLevel())
-               return tmpValues
-       }
-
-       def getCurrentMute() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(musicPlayers[0].getCurrentMute())
-               return tmpValues
-       }
-       
-       def getCurrentStatus() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(musicPlayers[0].getCurrentStatus())
-               return tmpValues
-       }
-
-       def getCurrentTrackData() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(musicPlayers[0].getCurrentTrackData())
-               return tmpValues
-       }
-
-       def getCurrentTrackDescription() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(musicPlayers[0].getCurrentTrackDescription())
-               return tmpValues
-       }
 }
diff --git a/MutableInteger/MutableInteger.groovy b/MutableInteger/MutableInteger.groovy
deleted file mode 100644 (file)
index 4eeb0c0..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Create a class for mutable integer
-package MutableInteger
-
-public class MutableInteger {
-       private int value;
-
-       public int getValue() {
-               return value;
-       }
-
-       public void setValue(int value) {
-               this.value = value;
-       }
-}
index 80ce59d..fe467e9 100644 (file)
@@ -4,9 +4,9 @@ import SmartThing.SmartThing
 
 public class NfcTouch extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
 
        NfcTouch(Closure sendEvent) {
                idSmartThing = id
@@ -15,8 +15,8 @@ public class NfcTouch extends SmartThing {
                sendEventSmartThings = sendEvent
 
                // Initialization
-               id.append("nfcSensorID0")
-               label.append("nfcSensor")
-               displayName.append("nfcSensor0")
+               id = "nfcSensorID0"
+               label = "nfcSensor"
+               displayName = "nfcSensor"
        }
 }
index d960a3a..479e2b9 100644 (file)
@@ -2,21 +2,16 @@
 package PowerMeter
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class PowerMeter extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentPower = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       PowerMeter(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentPower) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       PowerMeter(Closure sendEvent, String id, String label, String displayName, Integer currentPower) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,13 +21,7 @@ public class PowerMeter extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentPower = currentPower
 
                deviceIntValuesMap.put("power", currentPower)
        }
-
-       // Methods to return values
-       def getCurrentPower() {
-               return currentPower.getValue()
-       }
 }
index 330a4e3..e0600f6 100644 (file)
@@ -2,9 +2,6 @@
 package PowerMeter
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class PowerMeters extends SmartThings {
        List powerMeters = new ArrayList()
 
@@ -13,23 +10,16 @@ public class PowerMeters extends SmartThings {
                powerMeters = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("powerMeterID0")
-               StringBuilder label = new StringBuilder("powerMeter")
-               StringBuilder displayName = new StringBuilder("powerMeter0")
-               MutableInteger power = new MutableInteger()
+               String id = "powerMeterID0"
+               String label = "powerMeter"
+               String displayName = "powerMeter"
+               Integer power
 
                if (init)
-                       power.setValue(50)
+                       power = 50
                else
-                       power.setValue(60)
+                       power = 60
 
                powerMeters.add(new PowerMeter(sendEvent, id, label, displayName, power))
        }
-
-       // Methods to return values
-       def getCurrentPower() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(powerMeters[0].getCurrentPower())
-               return tmpValues
-       }
 }
index 9c52529..5ffc3fd 100644 (file)
@@ -4,17 +4,15 @@ import SmartThing.SmartThing
 
 public class PresenceSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentPresence = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
 
-       PresenceSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentPresence) {
+       PresenceSensor(Closure sendEvent, String id, String label, String displayName, String currentPresence) {
                deviceValuesMap = deviceValueSmartThing
                idSmartThing = id
                labelSmartThing = label
@@ -26,15 +24,9 @@ public class PresenceSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentPresence = currentPresence
                possibleValues.add("present")
                possibleValues.add("not present")
 
                deviceValuesMap.put("presence", currentPresence)
        }
-
-       // Methods to return values
-       def getCurrentPresence() {
-               return currentPresence.toString()
-       }
 }
index 942894a..3485eac 100644 (file)
@@ -9,23 +9,16 @@ public class PresenceSensors extends SmartThings {
                presenceSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("presenceSensorID0")
-               StringBuilder label = new StringBuilder("presence")
-               StringBuilder displayName = new StringBuilder("presenceSensor0")
-               StringBuilder presence = new StringBuilder()
+               String id = "presenceSensorID0"
+               String label = "presence"
+               String displayName = "presenceSensor"
+               String presence
 
                if (init)
-                       presence.append("not present")
+                       presence = "not present"
                else
-                       presence.append("present")
+                       presence = "present"
 
                presenceSensors.add(new PresenceSensor(sendEvent, id, label, displayName, presence))
        }
-
-       // Methods to return values
-       def getCurrentPresence() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(presenceSensors[0].getCurrentPresence())
-               return tmpValues
-       }
 }
index 8d7c4e0..9faad86 100644 (file)
@@ -2,21 +2,16 @@
 package RelativeHumidityMeasurement
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class RelativeHumidityMeasurement extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentHumidity = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       RelativeHumidityMeasurement(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentHumidity) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       RelativeHumidityMeasurement(Closure sendEvent, String id, String label, String displayName, Integer currentHumidity) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,13 +21,7 @@ public class RelativeHumidityMeasurement extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentHumidity = currentHumidity
 
                deviceIntValuesMap.put("humidity", currentHumidity)
        }
-
-       // Methods to return values
-       def getCurrentHumidity() {
-               return currentHumidity.getValue()
-       }
 }
index 3e18c42..084f7d9 100644 (file)
@@ -2,9 +2,6 @@
 package RelativeHumidityMeasurement
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class RelativeHumidityMeasurements extends SmartThings {
        List humidityMeasurements = new ArrayList()
        
@@ -13,23 +10,16 @@ public class RelativeHumidityMeasurements extends SmartThings {
                humidityMeasurements = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("humidityID0")
-               StringBuilder label = new StringBuilder("humidity")
-               StringBuilder displayName = new StringBuilder("humidity0")
-               MutableInteger humidity = new MutableInteger()
+               String id = "humidityID0"
+               String label = "humidity"
+               String displayName = "humiditySensor"
+               Integer humidity
 
                if (init)
-                       humidity.setValue(50)
+                       humidity = 50
                else
-                       humidity.setValue(60)
+                       humidity = 60
 
                humidityMeasurements.add(new RelativeHumidityMeasurement(sendEvent, id, label, displayName, humidity))
        }
-
-       // Methods to return values
-       def getCurrentHumidity() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(humidityMeasurements[0].getCurrentHumidity())
-               return tmpValues
-       }
 }
index 82fdc4c..059ebae 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class RelaySwitch extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentSwitch = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       RelaySwitch(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentSwitch) {
-               deviceValuesMap = deviceValueSmartThing
+       RelaySwitch(Closure sendEvent, String id, String label, String displayName, String currentSwitch) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,14 +21,13 @@ public class RelaySwitch extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentSwitch = currentSwitch
 
                deviceValuesMap.put("switch", currentSwitch)
        }
 
        // Methods to set values
        def on() {
-               action(currentSwitch, "on", "switch")
+               action("on", "switch")
        }
 
        def on(LinkedHashMap metaData) {
@@ -38,25 +35,10 @@ public class RelaySwitch extends SmartThing {
        }
 
        def off() {
-               action(currentSwitch, "off", "switch")
+               action("off", "switch")
        }
 
        def off(LinkedHashMap metaData) {
                off()
        }
-
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the relay switch with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentSwitch() {
-               return currentSwitch.toString()
-       }
 }
index 76420f3..bf89c23 100644 (file)
@@ -10,15 +10,15 @@ public class RelaySwitches extends SmartThings {
                relaySwitches = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("relaySwitchID0")
-               StringBuilder label = new StringBuilder("relaySwitch")
-               StringBuilder displayName = new StringBuilder("relaySwitch0")
-               StringBuilder currentSwitch = new StringBuilder()
+               String id = "relaySwitchID0"
+               String label = "switch"
+               String displayName = "relaySwitch"
+               String currentSwitch
 
                if (init)
-                       currentSwitch.append("off")
+                       currentSwitch = "off"
                else
-                       currentSwitch.append("on")
+                       currentSwitch = "on"
 
                relaySwitches.add(new RelaySwitch(sendEvent, id, label, displayName, currentSwitch))
        }
@@ -39,11 +39,4 @@ public class RelaySwitches extends SmartThings {
        def off(LinkedHashMap metaData) {
                off()
        }
-
-       // Methods to return values
-       def getCurrentSwitch() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(relaySwitches[0].getCurrentSwitch())
-               return tmpValues
-       }
 }
index a3da10b..4ae6f08 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class SleepSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentSleeping = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       SleepSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentSleeping) {
-               deviceValuesMap = deviceValueSmartThing
+       SleepSensor(Closure sendEvent, String id, String label, String displayName, String currentSleeping) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,13 +21,7 @@ public class SleepSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentSleeping = currentSleeping
 
                deviceValuesMap.put("sleeping", currentSleeping)
        }
-
-       // Methods to return values
-       def getCurrentSleeping() {
-               return currentSleeping.toString()
-       }
 }
index 7f8eb12..a9e28e0 100644 (file)
@@ -10,23 +10,16 @@ public class SleepSensors extends SmartThings {
                sleepSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("sleepSensorID0")
-               StringBuilder label = new StringBuilder("sleepSensor")
-               StringBuilder displayName = new StringBuilder("sleepSensor0")
-               StringBuilder sleeping = new StringBuilder()
+               String id = "sleepSensorID0"
+               String label = "sleeping"
+               String displayName = "sleepSensor"
+               String sleeping
 
                if (init)
-                       sleeping.append("sleeping")
+                       sleeping = "sleeping"
                else
-                       sleeping.append("not sleeping")
+                       sleeping = "not sleeping"
 
                sleepSensors.add(new SleepSensor(sendEvent, id, label, displayName, sleeping))
        }
-
-       // Methods to return values
-       def getCurrentSleeping() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(sleepSensors[0].getCurrentSleeping())
-               return tmpValues
-       }
 }
index a690760..1f46551 100644 (file)
@@ -4,57 +4,45 @@ package SmartThing
 //JPF's Verify API
 import gov.nasa.jpf.vm.Verify
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
-public class SmartThing {      
-       List nonStoredDevices = ["aeonKeyFob", "appTouch", "button", "momentary", "nfcTouch"] // Devices with no stored value
-       List locationTimeFeatures = ["sunset", "sunrise", "sunriseTime", "sunsetTime"]
+public class SmartThing {
        def sendEventSmartThings
-
-       StringBuilder idSmartThing = new StringBuilder()
-       StringBuilder labelSmartThing = new StringBuilder()
-       StringBuilder displayNameSmartThing = new StringBuilder()
-       HashMap<String, StringBuilder> deviceValueSmartThing = new HashMap<String, StringBuilder>()
-       HashMap<String, MutableInteger> deviceIntValueSmartThing = new HashMap<String, MutableInteger>()
-       List<StringBuilder> possibleValuesSmartThings = new ArrayList<StringBuilder>();
+       String idSmartThing
+       String labelSmartThing
+       String displayNameSmartThing
+       HashMap<String, String> deviceValueSmartThing = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValueSmartThing = new HashMap<String, Integer>()
+       List<String> possibleValuesSmartThings = new ArrayList<String>()
 
        // Method for handling events
-       def setValue(LinkedHashMap eventDataMap) {
-               def name = eventDataMap["name"]
-               def tmpID = eventDataMap["deviceId"]
-               def value = eventDataMap["value"]
+        def setValue(LinkedHashMap eventDataMap) {
+                def name = eventDataMap["name"]
+                def tmpID = eventDataMap["deviceId"]
+                def value = eventDataMap["value"]
 
-               if (deviceValueSmartThing.containsKey(name)) {
-                       StringBuilder tmpStr = deviceValueSmartThing.get(name)
-                       if (!value.equals(tmpStr.toString())) {
-                               tmpStr.replace(0, tmpStr.length(), value)
-                               println("the $name with id:$tmpID is triggered to $value!")
-                               sendEventSmartThings(eventDataMap)
-                       }
-               } else if (deviceIntValueSmartThing.containsKey(name)) {
-                       MutableInteger tmpInt = deviceIntValueSmartThing.get(name)
-                       if (!value.equals(tmpInt.getValue())) {
-                               tmpInt.setValue(value)
-                               println("the $name with id:$tmpID is triggered to $value!")
-                               sendEventSmartThings(eventDataMap)
-                       }
-               } else if (nonStoredDevices.contains(name)) {
-                       println("the $name with id:$tmpID is triggered to $value!")
-                       sendEventSmartThings(eventDataMap)
-               } else if (locationTimeFeatures.contains(name)) {
-                       return System.currentTimeMillis()
-                       println("This is $name!")
-                       sendEventSmartThings(eventDataMap)
-               }
-       }
+                if (deviceValueSmartThing.containsKey(name)) {
+                        if (!value.equals(deviceValueSmartThing.get(name))) {
+                                deviceValueSmartThing.put(name, value)
+                                println("the $name of the $displayNameSmartThing with id:$tmpID is triggered to $value!")
+                                sendEventSmartThings(eventDataMap)
+                        }
+                } else if (deviceIntValueSmartThing.containsKey(name)) {
+                        if (!value.equals(deviceIntValueSmartThing.get(name))) {
+                                deviceIntValueSmartThing.put(name, value)
+                                println("the $name of the $displayNameSmartThing with id:$tmpID is triggered to $value!")
+                                sendEventSmartThings(eventDataMap)
+                        }
+                } else {
+                        println("the $name of the $displayNameSmartThing with id:$tmpID is triggered to $value!")
+                        sendEventSmartThings(eventDataMap)
+                }
+        }
 
        def statesSince() {
                eventsSince()
        }
 
        def eventsSince() {
-               if (labelSmartThing.toString().equals("humidity") || labelSmartThing.toString().equals("temperature")) {
+               if (labelSmartThing.equals("humidity") || labelSmartThing.equals("temperature")) {
                        sendCurrentValue()
                } else {
                        sendPossibleValues()
@@ -62,8 +50,7 @@ public class SmartThing {
        }
 
        def sendCurrentValue() {
-               def label = labelSmartThing.toString()
-               def evtTemp = [[name: label, value: deviceIntValueSmartThing.get(label).getValue(), deviceId: idSmartThing.toString(), descriptionText: "",
+               def evtTemp = [[name: labelSmartThing, value: deviceIntValueSmartThing.get(labelSmartThing), deviceId: idSmartThing, descriptionText: "",
                                displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
                def init = Verify.getInt(0,1)
                def evtToSend = []
@@ -78,9 +65,9 @@ public class SmartThing {
        }
 
        def sendPossibleValues() {
-               def evtA = [[name: labelSmartThing.toString(), value: possibleValuesSmartThings[0].toString(), deviceId: idSmartThing.toString(), descriptionText: "",
+               def evtA = [[name: labelSmartThing, value: possibleValuesSmartThings[0], deviceId: idSmartThing, descriptionText: "",
                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
-               def evtB = [[name: labelSmartThing.toString(), value: possibleValuesSmartThings[1].toString(), deviceId: idSmartThing.toString(), descriptionText: "",
+               def evtB = [[name: labelSmartThing, value: possibleValuesSmartThings[1], deviceId: idSmartThing, descriptionText: "",
                                    displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}']]
                def init = Verify.getInt(0,4)
                def evtToSend = []
@@ -115,7 +102,40 @@ public class SmartThing {
                }
        }
 
+       // Methods to set values
+       def action(String newValue, String feature) {
+               if (!deviceValueSmartThing.get(feature).equals(newValue)) {
+                       deviceValueSmartThing.put(feature, newValue)
+                       println("$feature of the $displayNameSmartThing with id:$idSmartThing is changed to $newValue!")
+                       sendEventSmartThings([name: feature, value: newValue, deviceId: idSmartThing, descriptionText: "",
+                                             displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
+       def action(int newValue, String feature) {
+               if (!deviceIntValueSmartThing.get(feature).equals(newValue)) {
+                       deviceIntValueSmartThing.put(feature, newValue)
+                       println("$feature of the $displayNameSmartThing with id:$idSmartThing is changed to $newValue!")
+                       sendEventSmartThings([name: feature, value: newValue, deviceId: idSmartThing, descriptionText: "",
+                                             displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+               }
+       }
+
        // Methods to return values
+       def getProperty(String currentProperty) {
+               String property = currentProperty
+               if (property.contains("current")) // Check to see if we have currentXXX or xxx
+                       property = property.substring(7,8).toLowerCase()+property.substring(8);
+
+               if (deviceValueSmartThing.containsKey(property)) {
+                       return deviceValueSmartThing.get(property)
+               } else if (deviceIntValueSmartThing.containsKey(property)) {
+                       return deviceIntValueSmartThing.get(property)
+               } else {
+                       println("This capability does not support this property!")
+               }
+       }
+
        def currentState(String deviceFeature) {
                return [rawDateCreated: [time: System.currentTimeMillis()]]
        }
@@ -133,16 +153,4 @@ public class SmartThing {
        def latestValue(String deviceFeature) {
                currentValue(deviceFeature)
        }
-
-       def getId() {
-               return idSmartThing.toString()
-       }
-
-       def getLabel() {
-               return labelSmartThing.toString()
-       }
-       
-       def getDisplayName() {
-               return displayNameSmartThing.toString()
-       }
 }
index aa54b7e..4ac188d 100644 (file)
@@ -1,9 +1,6 @@
 //Create a class for SmartThings
 package SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 class SmartThings {
        List smartThings = new ArrayList()
 
@@ -42,6 +39,12 @@ class SmartThings {
        }
 
        // Methods to return states of the devices
+       def getProperty(String currentProperty) {
+               List tmpValues = new ArrayList()
+               tmpValues.add(smartThings[0].getProperty(currentProperty))
+               return tmpValues
+       }
+
        def currentState(String deviceFeature) {
                List tmpValues = new ArrayList()
                tmpValues.add(smartThings[0].currentState(deviceFeature))
index 9eb9e8a..b9ebece 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class SmokeDetector extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentSmoke = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       SmokeDetector(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentSmoke) {
-               deviceValuesMap = deviceValueSmartThing
+       SmokeDetector(Closure sendEvent, String id, String label, String displayName, String currentSmoke) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,13 +21,7 @@ public class SmokeDetector extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentSmoke = currentSmoke
 
                deviceValuesMap.put("smoke", currentSmoke)
        }
-
-       // Methods to return values
-       def getCurrentSmoke() {
-               return currentSmoke.toString()
-       }
 }
index 0c790a6..7bc455a 100644 (file)
@@ -10,23 +10,16 @@ public class SmokeDetectors extends SmartThings {
                smokeDetectors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("smokeDetectorID0")
-               StringBuilder label = new StringBuilder("smokeDetector")
-               StringBuilder displayName = new StringBuilder("smokeDetector0")
-               StringBuilder smoke = new StringBuilder()
+               String id = "smokeDetectorID0"
+               String label = "smoke"
+               String displayName = "smokeDetector"
+               String smoke
 
                if (init)
-                       smoke.append("clear")
+                       smoke = "clear"
                else
-                       smoke.append("detected")
+                       smoke = "detected"
 
                smokeDetectors.add(new SmokeDetector(sendEvent, id, label, displayName, smoke))
        }
-
-       // Methods to return values
-       def getCurrentSmoke() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(smokeDetectors[0].getCurrentSmoke())
-               return tmpValues
-       }
 }
index da60b36..cd57d0c 100644 (file)
@@ -2,21 +2,16 @@
 package SpeechSynthesis
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class SpeechSynthesis extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentLevel = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       SpeechSynthesis(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentLevel) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       SpeechSynthesis(Closure sendEvent, String id, String label, String displayName, Integer currentLevel) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,27 +21,16 @@ public class SpeechSynthesis extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentLevel = currentLevel
 
                deviceIntValuesMap.put("level", currentLevel)
        }
 
        // Methods to set values
        def setLevel(int newValue) {
-               if (!currentLevel.getValue().equals(newValue)) {
-                       String tmpID = id.toString()
-                       currentLevel.setValue(newValue)
-                       println("The level of speech synthesis with id:$tmpID is changed to $currentLevel")
-               }
+               action(newValue, "level")
        }
 
        def speak(String message) {
-               String tmpID = id.toString()
-               println("Speech synthesis with id:$tmpID, SPEAKING:\"$message\"!")
-       }
-
-       // Methods to return values
-       def getCurrentLevel() {
-               return currentLevel.getValue()
+               println("Speech synthesis with id:$id, SPEAKING:\"$message\"!")
        }
 }
index 70237ed..2497ce6 100644 (file)
@@ -2,9 +2,6 @@
 package SpeechSynthesis
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class SpeechSynthesises extends SmartThings {
        List speechSynthesises = new ArrayList()
                
@@ -13,15 +10,15 @@ public class SpeechSynthesises extends SmartThings {
                speechSynthesises = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("speechSynthesisID0")
-               StringBuilder label = new StringBuilder("speechSynthesis")
-               StringBuilder displayName = new StringBuilder("speechSynthesis0")
-               MutableInteger level = new MutableInteger()
+               String id = "speechSynthesisID0"
+               String label = "level"
+               String displayName = "speechSynthesiser"
+               Integer level
 
                if (init)
-                       level.setValue(50)
+                       level = 50
                else
-                       level.setValue(60)
+                       level = 60
 
                speechSynthesises.add(new SpeechSynthesis(sendEvent, id, label, displayName, level))
        }
@@ -34,12 +31,4 @@ public class SpeechSynthesises extends SmartThings {
        def speak(String message) {
                speechSynthesises[0].speak(message)
        }
-
-       // Methods to return values
-       def getCurrentLevel() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(speechSynthesises[0].getCurrentLevel())
-               return tmpValues
-       }
-
 }
index 538fca5..7f0faf3 100644 (file)
@@ -2,22 +2,16 @@
 package StepSensor
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class StepSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentGoal = new MutableInteger()
-       MutableInteger currentSteps = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       StepSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentSteps, MutableInteger currentGoal) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       StepSensor(Closure sendEvent, String id, String label, String displayName, Integer currentSteps, Integer currentGoal) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -27,19 +21,8 @@ public class StepSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentSteps = currentSteps
-               this.currentGoal = currentGoal
 
                deviceIntValuesMap.put("steps", currentSteps)
                deviceIntValuesMap.put("goal", currentGoal)
        }
-
-       // Methods to return values
-       def getCurrentSteps() {
-               return currentSteps.getValue()
-       }
-
-       def getCurrentGoal() {
-               return currentGoal.getValue()
-       }
 }
index bbe8fd8..067481f 100644 (file)
@@ -2,9 +2,6 @@
 package StepSensor
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class StepSensors extends SmartThings {
        List stepSensors = new ArrayList()
                
@@ -13,33 +10,20 @@ public class StepSensors extends SmartThings {
                stepSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("stepSensorID0")
-               StringBuilder label = new StringBuilder("stepSensor")
-               StringBuilder displayName = new StringBuilder("stepSensor0")
-               MutableInteger steps = new MutableInteger()
-               MutableInteger goal = new MutableInteger()
+               String id = "stepSensorID0"
+               String label = "steps"
+               String displayName = "stepSensor"
+               Integer steps
+               Integer goal
 
                if (init) {
-                       goal.setValue(50)
-                       steps.setValue(35)
+                       goal = 50
+                       steps = 35
                } else {
-                       goal.setValue(40)
-                       steps.setValue(60)
+                       goal = 40
+                       steps = 60
                }
 
                stepSensors.add(new StepSensor(sendEvent, id, label, displayName, steps, goal))
        }
-
-       // Methods to return values
-       def getCurrentSteps() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(stepSensors[0].getCurrentSteps())
-               return tmpValues
-       }
-
-       def getCurrentGoal() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(stepSensors[0].getCurrentGoal())
-               return tmpValues
-       }
 }
index b95bca1..d44846c 100644 (file)
@@ -4,18 +4,16 @@ import SmartThing.SmartThing
 
 public class Switch extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentSwitch = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
        // Possible values for eventsSince method
-       List<StringBuilder> possibleValues = new ArrayList<StringBuilder>();
+       List<String> possibleValues = new ArrayList<String>();
 
-       Switch(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentSwitch) {
-               deviceValuesMap = deviceValueSmartThing
+       Switch(Closure sendEvent, String id, String label, String displayName, String currentSwitch) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,7 +24,6 @@ public class Switch extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentSwitch = currentSwitch
                possibleValues.add("on")
                possibleValues.add("off")
 
@@ -35,7 +32,7 @@ public class Switch extends SmartThing {
 
        // Methods to set values
        def on() {
-               action(currentSwitch, "on", "switch")
+               action("on", "switch")
        }
 
        def on(LinkedHashMap metaData) {
@@ -43,25 +40,10 @@ public class Switch extends SmartThing {
        }
 
        def off() {
-               action(currentSwitch, "off", "switch")
+               action("off", "switch")
        }
 
        def off(LinkedHashMap metaData) {
                off()
        }
-
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the light with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentSwitch() {
-               return currentSwitch.toString()
-       }
 }
index a71a49f..4729adf 100644 (file)
@@ -9,15 +9,15 @@ public class Switches extends SmartThings {
                switches = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("switchID0")
-               StringBuilder label = new StringBuilder("switch")
-               StringBuilder displayName = new StringBuilder("switch0")
-               StringBuilder currentSwitch = new StringBuilder()
+               String id = "switchID0"
+               String label = "switch"
+               String displayName = "switch"
+               String currentSwitch
 
                if (init)
-                       currentSwitch.append("off")
+                       currentSwitch = "off"
                else
-                       currentSwitch.append("on")
+                       currentSwitch = "on"
 
                switches.add(new Switch(sendEvent, id, label, displayName, currentSwitch))
        }
@@ -38,11 +38,4 @@ public class Switches extends SmartThings {
        def off(LinkedHashMap metaData) {
                off()
        }
-
-       // Methods to return values
-       def getCurrentSwitch() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(switches[0].getCurrentSwitch())
-               return tmpValues
-       }
 }
index b4d09f7..0be1ee6 100644 (file)
@@ -2,21 +2,16 @@
 package SwitchLevel
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class SwitchLevel extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentLevel = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
        
-       SwitchLevel(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentLevel) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       SwitchLevel(Closure sendEvent, String id, String label, String displayName, Integer currentLevel) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,7 +21,6 @@ public class SwitchLevel extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentLevel = currentLevel
 
                deviceIntValuesMap.put("level", currentLevel)
        }
@@ -41,17 +35,6 @@ public class SwitchLevel extends SmartThing {
        }
 
        def setLevel(int newValue) {
-               if (!currentLevel.getValue().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.setValue(newValue)
-                       println("the switch with id:$tmpID is setted to level $level!")
-                       sendEvent([name: "level", value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-       
-       // Methods to return values
-       def getCurrentLevel() {
-               return currentLevel.getValue()
+               action(newValue, "level")
        }
 }
index c48e1cf..075fc44 100644 (file)
@@ -2,9 +2,6 @@
 package SwitchLevel
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class SwitchLevels extends SmartThings {
        List switchLevels = new ArrayList()
 
@@ -13,15 +10,15 @@ public class SwitchLevels extends SmartThings {
                switchLevels = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("switchLevelID0")
-               StringBuilder label = new StringBuilder("switchLevel")
-               StringBuilder displayName = new StringBuilder("switchLevel0")
-               MutableInteger level = new MutableInteger()
+               String id = "switchLevelID0"
+               String label = "level"
+               String displayName = "switchLevel"
+               Integer level
 
                if (init)
-                       level.setValue(50)
+                       level = 50
                else
-                       level.setValue(60)
+                       level = 60
 
                switchLevels.add(new SwitchLevel(sendEvent, id, label, displayName, level))
        }
@@ -38,11 +35,4 @@ public class SwitchLevels extends SmartThings {
        def setLevel(int newValue) {
                switchLevels[0].setLevel(newValue)
        }
-
-       // Methods to return values
-       def getCurrentLevel() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(switchLevels[0].getCurrentLevel())
-               return tmpValues
-       }
 }
index 99afe6a..23933b5 100644 (file)
@@ -2,21 +2,16 @@
 package TemperatureMeasurement
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class TemperatureMeasurement extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentTemperature = new MutableInteger()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
-       TemperatureMeasurement(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentTemperature) {
-               deviceIntValuesMap = deviceIntValueSmartThing
+       TemperatureMeasurement(Closure sendEvent, String id, String label, String displayName, Integer currentTemperature) {
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -26,14 +21,7 @@ public class TemperatureMeasurement extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentTemperature = currentTemperature
 
                deviceIntValuesMap.put("temperature", currentTemperature)
        }
-
-       // Methods to return values
-       def getCurrentTemperature() {
-               return currentTemperature.getValue()
-       }
-
 }
index a861cd2..5c942c1 100644 (file)
@@ -2,9 +2,6 @@
 package TemperatureMeasurement
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 public class TemperatureMeasurements extends SmartThings {
        List temperatureMeasurements = new ArrayList()
 
@@ -13,23 +10,16 @@ public class TemperatureMeasurements extends SmartThings {
                temperatureMeasurements = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("temperatureMeasurementID0")
-               StringBuilder label = new StringBuilder("temperature")
-               StringBuilder displayName = new StringBuilder("temperatureMeasurement0")
-               MutableInteger temperature = new MutableInteger()
+               String id = "temperatureMeasurementID0"
+               String label = "temperature"
+               String displayName = "temperatureMeasurement"
+               Integer temperature
 
                if (init)
-                       temperature.setValue(40)
+                       temperature = 40
                else
-                       temperature.setValue(60)
+                       temperature = 60
 
                temperatureMeasurements.add(new TemperatureMeasurement(sendEvent, id, label, displayName, temperature))
        }
-
-       // Methods to return values
-       def getCurrentTemperature() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(temperatureMeasurements[0].getCurrentTemperature())
-               return tmpValues
-       }
 }
index 4fa2c78..21c897f 100644 (file)
@@ -2,33 +2,20 @@
 package Thermostat
 import SmartThing.SmartThing
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 class Thermostat extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with numberical values
-       MutableInteger currentTemperature = new MutableInteger()
-       MutableInteger currentCoolingSetpoint = new MutableInteger()
-       MutableInteger currentHeatingSetpoint = new MutableInteger()
-       MutableInteger currentThermostatSetPoint = new MutableInteger()
-       // Features with string values
-       StringBuilder currentThermostatOperatingState = new StringBuilder()
-       StringBuilder currentThermostatFanMode = new StringBuilder()
-       StringBuilder currentThermostatMode = new StringBuilder()
-       StringBuilder currentClimateName = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
-       HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
-
-       Thermostat(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentTemperature, MutableInteger currentCoolingSetpoint, 
-                   MutableInteger currentHeatingSetpoint, MutableInteger currentThermostatSetPoint, StringBuilder currentThermostatOperatingState, StringBuilder currentThermostatFanMode, 
-                  StringBuilder currentThermostatMode, StringBuilder currentClimateName) {
-               deviceValuesMap = deviceValueSmartThing
-               deviceIntValuesMap = deviceIntValueSmartThing
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
+
+       Thermostat(Closure sendEvent, String id, String label, String displayName, Integer currentTemperature, Integer currentCoolingSetpoint, 
+                   Integer currentHeatingSetpoint, Integer currentThermostatSetPoint, String currentThermostatOperatingState, String currentThermostatFanMode, 
+                  String currentThermostatMode, String currentClimateName) {
+               deviceValueSmartThing = deviceValuesMap
+               deviceIntValueSmartThing = deviceIntValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -38,27 +25,24 @@ class Thermostat extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentTemperature = currentTemperature
-               this.currentCoolingSetpoint = currentCoolingSetpoint
-               this.currentHeatingSetpoint = currentHeatingSetpoint
-               this.currentThermostatSetPoint = currentThermostatSetPoint
-               this.currentThermostatOperatingState = currentThermostatOperatingState
-               this.currentThermostatFanMode = currentThermostatFanMode
-               this.currentThermostatMode = currentThermostatMode
-               this.currentClimateName = currentClimateName
 
                deviceValuesMap.put("temperature", currentTemperature)
                deviceValuesMap.put("thermostatOperatingState", currentThermostatOperatingState)
                deviceValuesMap.put("thermostatFanMode", currentThermostatFanMode)
                deviceValuesMap.put("thermostatMode", currentThermostatMode)
+               deviceValuesMap.put("climateName", currentClimateName)
                deviceIntValuesMap.put("coolingSetpoint", currentCoolingSetpoint)
                deviceIntValuesMap.put("heatingSetpoint", currentHeatingSetpoint)
                deviceIntValuesMap.put("thermostatSetpoint", currentThermostatSetPoint)
        }
 
        // Methods to set values
+       def setThermostatSetpoint(int newValue) {
+               action(newValue, "thermostatSetpoint")
+       }
+
        def setCoolingSetpoint(int newValue) {
-               action(this.currentCoolingSetpoint, newValue, "coolingSetpoint")
+               action(newValue, "coolingSetpoint")
        }
 
        def setCoolingSetpoint(String newValue) {
@@ -66,7 +50,7 @@ class Thermostat extends SmartThing {
        }
 
        def setHeatingSetpoint(int newValue) {
-               action(this.currentHeatingSetpoint, newValue, "heatingSetpoint")
+               action(newValue, "heatingSetpoint")
        }
 
        def setHeatingSetpoint(String newValue) {
@@ -74,92 +58,43 @@ class Thermostat extends SmartThing {
        }
 
        def setThermostatFanMode(String newValue) {
-               action(this.currentThermostatFanMode, newValue, "thermostatFanMode")
+               action(newValue, "thermostatFanMode")
+       }
+
+       def setThermostatOperatingState(String newValue) {
+               action(newValue, "thermostatOperatingState")
        }
 
        def setThermostatMode(String newValue) {
-               action(this.currentThermostatMode, newValue, "thermostatMode")
+               action(newValue, "thermostatMode")
        }
 
        def cool() {
-               action(this.currentThermostatMode, "cool", "thermostatMode")
+               action("cool", "thermostatMode")
        }
 
        def heat() {
-               action(this.currentThermostatMode, "heat", "thermostatMode")
+               action("heat", "thermostatMode")
        }
 
        def auto() {
-               action(this.currentThermostatMode, "auto", "thermostatMode")
+               action("auto", "thermostatMode")
        }
        
        def emergencyHeat() {
-               action(this.currentThermostatMode, "emergencyHeat", "thermostatMode")
+               action("emergencyHeat", "thermostatMode")
        }
 
        def off() {
-               action(this.currentThermostatMode, "off", "thermostatMode")
+               action("off", "thermostatMode")
        }
 
        def setClimate(String info, String newValue) {
-               action(currentClimateName, newValue, "climateName")
+               action(newValue, "climateName")
        }
 
        def setHold(String info1, int coolingSetpoint, int heatingSetpoint, String info2, String info3) {
                setHeatingSetpoint(heatingSetpoint)
                setCoolingSetpoint(coolingSetpoint)
        }
-
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the thermostat with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       def action(MutableInteger variable, int newValue, String feature) {
-               if (!variable.getValue().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.setValue(newValue)
-                       println("$feature for the thermostat with id:$tmpID is changed to $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentTemperature() {
-               return currentTemperature.getValue()
-       }
-
-       def getCurrentCoolingSetpoint() {
-               return currentCoolingSetpoint.getValue()
-       }
-       
-       def getCurrentHeatingSetpoint() {
-               return currentHeatingSetpoint.getValue()
-       }
-
-       def getCurrentThermostatSetPoint() {
-               return currentThermostatSetPoint.getValue()
-       }
-
-       def getCurrentThermostatOperatingState() {
-               return currentThermostatOperatingState.toString()
-       }
-
-       def getCurrentThermostatFanMode() {
-               return currentThermostatFanMode.toString()
-       }
-
-       def getCurrentThermostatMode() {
-               return currentThermostatMode.toString()
-       }
-
-       def getCurrentClimateName() {
-               return currentClimateName.toString()
-       }
 }
index 693ba93..b2d5981 100644 (file)
@@ -2,9 +2,6 @@
 package Thermostat
 import SmartThing.SmartThings
 
-//Importing mutable integer class
-import MutableInteger.MutableInteger
-
 class Thermostats extends SmartThings {
        List thermostats = new ArrayList()
 
@@ -13,34 +10,34 @@ class Thermostats extends SmartThings {
                thermostats = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("thermostatID0")
-               StringBuilder label = new StringBuilder("thermostat")
-               StringBuilder displayName = new StringBuilder("thermostat0")
-               StringBuilder climateName = new StringBuilder("climateName")
-               StringBuilder thermostatOperatingState = new StringBuilder()
-               StringBuilder thermostatFanMode = new StringBuilder()
-               StringBuilder thermostatMode = new StringBuilder()
-               MutableInteger temperature = new MutableInteger()
-               MutableInteger coolingSetpoint = new MutableInteger()
-               MutableInteger heatingSetpoint = new MutableInteger()
-               MutableInteger thermostatSetpoint = new MutableInteger()
+               String id = "thermostatID0"
+               String label = "thermostat"
+               String displayName = "thermostat"
+               String climateName "climateName"
+               String thermostatOperatingState
+               String thermostatFanMode
+               String thermostatMode
+               Integer temperature
+               Integer coolingSetpoint
+               Integer heatingSetpoint
+               Integer thermostatSetpoint
 
                if (init) {
-                       temperature.setValue(60)
-                       coolingSetpoint.setValue(70)
-                       heatingSetpoint.setValue(35)
-                       thermostatSetpoint.setValue(50)
-                       thermostatOperatingState.append("off")
-                       thermostatFanMode.append("off")
-                       thermostatMode.append("off")
+                       temperature = 60
+                       coolingSetpoint = 70
+                       heatingSetpoint = 35
+                       thermostatSetpoint = 50
+                       thermostatOperatingState = "off"
+                       thermostatFanMode = "off"
+                       thermostatMode = "off"
                } else {
-                       temperature.setValue(66)
-                       coolingSetpoint.setValue(80)
-                       heatingSetpoint.setValue(50)
-                       thermostatSetpoint.setValue(60)
-                       thermostatOperatingState.append("heating")
-                       thermostatFanMode.append("circulate")
-                       thermostatMode.append("auto")
+                       temperature = 66
+                       coolingSetpoint = 80
+                       heatingSetpoint = 50
+                       thermostatSetpoint = 60
+                       thermostatOperatingState = "heating"
+                       thermostatFanMode = "circulate"
+                       thermostatMode = "auto"
                }
 
                thermostats.add(new Thermostat(sendEvent, id, label, displayName, temperature, coolingSetpoint, 
@@ -49,6 +46,10 @@ class Thermostats extends SmartThings {
        }
 
        // Methods to set values
+       def setThermostatSetpoint(int thermostatSetpoint) {
+               thermostats[0].setThermostatSetpoint(thermostatSetpoint)
+       }
+
        def setCoolingSetpoint(int coolingSetpoint) {
                thermostats[0].setCoolingSetpoint(coolingSetpoint)
        }
@@ -73,6 +74,10 @@ class Thermostats extends SmartThings {
                thermostats[0].setThermostatMode(thermostatMode)
        }
 
+       def setThermostatOperatingState(String thermostatOperatingState) {
+               thermostats[0].setThermostatOperatingState(thermostatOperatingState)
+       }
+
        def setClimate(String info, String givenClimateName) {
                thermostats[0].setClimate(info, givenClimateName)
        }
@@ -101,53 +106,4 @@ class Thermostats extends SmartThings {
        def off() {
                thermostats[0].off()
        }
-
-       // Methods to return values
-       def getCurrentTemperature() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentTemperature())
-               return tmpValues
-       }
-
-       def getCurrentCoolingSetpoint() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentCoolingSetpoint())
-               return tmpValues
-       }
-       
-       def getCurrentHeatingSetpoint() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentHeatingSetpoint())
-               return tmpValues
-       }
-
-       def getCurrentThermostatSetPoint() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentThermostatSetPoint())
-               return tmpValues
-       }
-
-       def getCurrentThermostatOperatingState() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentThermostatOperatingState())
-               return tmpValues
-       }
-
-       def getCurrentThermostatFanMode() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentThermostatFanMode())
-               return tmpValues
-       }
-
-       def getCurrentThermostatMode() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentThermostatMode())
-               return tmpValues
-       }
-
-       def getCurrentClimateName() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(thermostats[0].getCurrentClimateName())
-               return tmpValues
-       }
 }
index a555d68..dbd8eb9 100644 (file)
@@ -3,15 +3,15 @@ package ThreeAxis
 
 public class ThreeAxis {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Other variables
        def sendEvent
        LinkedHashMap currentThreeAxis
        
 
-       ThreeAxis(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, LinkedHashMap currentThreeAxis) {
+       ThreeAxis(Closure sendEvent, String id, String label, String displayName, LinkedHashMap currentThreeAxis) {
                // Initialization
                this.id = id
                this.label = label
@@ -22,9 +22,8 @@ public class ThreeAxis {
 
        // Methods to set values
        def setValue(LinkedHashMap eventDataMap) {
-               def tmpID = id.toString()
                currentThreeAxis = new groovy.json.JsonSlurper().parseText(eventDataMap["value"])
-               println("the three axis with id:$tmpID of cube is chagned to $currentThreeAxis!")
+               println("the three axis with id:$id of cube is chagned to $currentThreeAxis!")
                sendEvent(eventDataMap)
        }
 
index b438542..1ef1b3a 100644 (file)
@@ -10,9 +10,9 @@ public class ThreeAxises extends SmartThings {
                threeAxises = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("threeAxisID0")
-               StringBuilder label = new StringBuilder("threeAxis")
-               StringBuilder displayName = new StringBuilder("threeAxis0")
+               String id = "threeAxisID0"
+               String label = "threeAxis"
+               String displayName = "threeAxis"
                LinkedHashMap threeAxis
 
                if (init)
index 0cd43a9..91eef55 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class Valve extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentValve = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       Valve(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentValve) {
-               deviceValuesMap = deviceValueSmartThing
+       Valve(Closure sendEvent, String id, String label, String displayName, String currentValve) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,14 +21,13 @@ public class Valve extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentValve = currentValve
 
-               deviceValuesMap.put("valve", currentValve)
+               deviceValuesMap.put("contact", currentContact)
        }
 
        // Methods to set values
        def open() {
-               action(currentValve, "open", "contact")
+               action("open", "contact")
        }
 
        def open(LinkedHashMap metaData) {
@@ -38,25 +35,10 @@ public class Valve extends SmartThing {
        }
 
        def close() {
-               action(currentValve, "closed", "contact")
+               action("closed", "contact")
        }
 
        def close(LinkedHashMap metaData) {
                close()
        }
-       
-       def action(StringBuilder variable, String newValue, String feature) {
-               if (!variable.toString().equals(newValue)) {
-                       String tmpID = id.toString()
-                       variable.replace(0, variable.length(), newValue)
-                       println("$feature of the valve with id:$tmpID is $newValue!")
-                       sendEvent([name: feature, value: newValue, deviceId: tmpID, descriptionText: "",
-                                  displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
-               }
-       }
-
-       // Methods to return values
-       def getCurrentValve() {
-               return currentValve.toString()
-       }
 }
index 3873ae9..051c283 100644 (file)
@@ -10,15 +10,15 @@ public class Valves extends SmartThings {
                valves = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("valveID0")
-               StringBuilder label = new StringBuilder("valve")
-               StringBuilder displayName = new StringBuilder("valve0")
-               StringBuilder valve = new StringBuilder()
+               String id = "valveID0"
+               String label = "contact"
+               String displayName = "valveSensor"
+               String valve
                
                if (init)
-                       valve.append("closed")
+                       valve = "closed"
                else
-                       valve.append("open")
+                       valve = "open"
 
                valves.add(new Valve(sendEvent, id, label, displayName, valve))
        }
@@ -39,12 +39,4 @@ public class Valves extends SmartThings {
        def close(LinkedHashMap metaData) {
                close()
        }
-
-       // Methods to return values
-       def getCurrentValve() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(valves[0].getCurrentValve())
-               return tmpValues
-       }
-
 }
index 8c4e921..b4369cd 100644 (file)
@@ -4,16 +4,14 @@ import SmartThing.SmartThing
 
 public class WaterSensor extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
-       // Features with string values
-       StringBuilder currentWater = new StringBuilder()
+       String id
+       String label
+       String displayName
        // Maps from features to values
-       HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       WaterSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentWater) {
-               deviceValuesMap = deviceValueSmartThing
+       WaterSensor(Closure sendEvent, String id, String label, String displayName, String currentWater) {
+               deviceValueSmartThing = deviceValuesMap
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
@@ -23,13 +21,7 @@ public class WaterSensor extends SmartThing {
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.currentWater = currentWater
 
                deviceValuesMap.put("water", currentWater)
        }
-
-       // Methods to return values
-       def getCurrentWater() {
-               return currentWater.toString()
-       }
 }
index 4813e03..adf0df9 100644 (file)
@@ -4,29 +4,22 @@ import SmartThing.SmartThings
 
 public class WaterSensors extends SmartThings {
        List waterSensors = new ArrayList()
-               
+
        WaterSensors(Closure sendEvent, boolean init) {
                // Only initialize one time since we only have one device for each capability
                waterSensors = smartThings
 
                // Initialization
-               StringBuilder id = new StringBuilder("waterSensorID0")
-               StringBuilder label = new StringBuilder("waterSensor")
-               StringBuilder displayName = new StringBuilder("waterSensor0")
-               StringBuilder water = new StringBuilder()
+               String id = "waterSensorID0"
+               String label = "water"
+               String displayName = "waterSensor"
+               String water
 
                if (init)
-                       water.append("dry")
+                       water = "dry"
                else
-                       water.append("wet")
+                       water = "wet"
 
                waterSensors.add(new WaterSensor(sendEvent, id, label, displayName, water))
        }
-               
-       // Methods to return values
-       def getCurrentWater() {
-               List tmpValues = new ArrayList()
-               tmpValues.add(waterSensors[0].getCurrentWater())
-               return tmpValues
-       }
 }
index 980a05a..0cc6851 100644 (file)
@@ -4,19 +4,18 @@ import SmartThing.SmartThing
 
 public class Touched extends SmartThing {
        // id, label, and display name of the device
-       StringBuilder id = new StringBuilder()
-       StringBuilder label = new StringBuilder()
-       StringBuilder displayName = new StringBuilder()
+       String id
+       String label
+       String displayName
 
        Touched(Closure sendEvent) {
+               id = "appTouchID0"
+               label = "appTouch"
+               displayName = "appTouchSensor"
+               
                idSmartThing = id
                labelSmartThing = label
                displayNameSmartThing = displayName
                sendEventSmartThings = sendEvent
-
-               // Initialization
-               id.append("appTouchID0")
-               label.append("appTouch")
-               displayName.append("appTouch0")
        }
 }
index 8220ad4..a9147cd 100644 (file)
@@ -1,2 +1,2 @@
-                       doorControlObject[0].setValue([name: "doorState", value: "closed", deviceId: "doorControlID0", descriptionText: "",
+                       doorControlObject[0].setValue([name: "door", value: "closed", deviceId: "doorControlID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index 35bd04e..6d228cb 100644 (file)
@@ -1,2 +1,2 @@
-                       doorControlObject[0].setValue([name: "doorState", value: "open", deviceId: "doorControlID0", descriptionText: "",
+                       doorControlObject[0].setValue([name: "door", value: "open", deviceId: "doorControlID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index b935c20..981232d 100644 (file)
@@ -1,2 +1,2 @@
-                       locationObject.setValue([name: "Location", value: "away", deviceId: "locationID0", descriptionText: "",
+                       locationObject.setValue([name: "mode", value: "away", deviceId: "locationID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index c28caa5..6791eec 100644 (file)
@@ -1,2 +1,2 @@
-                       locationObject.setValue([name: "Location", value: "home", deviceId: "locationID0", descriptionText: "",
+                       locationObject.setValue([name: "mode", value: "home", deviceId: "locationID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index 5f088d3..34c4781 100644 (file)
@@ -1,2 +1,2 @@
-                       locationObject.setValue([name: "Location", value: "night", deviceId: "locationID0", descriptionText: "",
+                       locationObject.setValue([name: "mode", value: "night", deviceId: "locationID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index 6791eec..1dbd8a8 100644 (file)
@@ -1,2 +1,2 @@
                        locationObject.setValue([name: "mode", value: "home", deviceId: "locationID0", descriptionText: "",
-                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
+                                       displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
\ No newline at end of file
index 869ed7e..5436425 100644 (file)
@@ -1,2 +1,2 @@
-                       motionSensorObjectp[0].setValue([name: "motion", value: "active", deviceId: "motionSensorID0", descriptionText: "",
+                       motionSensorObject[0].setValue([name: "motion", value: "active", deviceId: "motionSensorID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index 1409566..b8eef4b 100644 (file)
@@ -1,2 +1,2 @@
-                       touchSensorObject.setValue([name: "nfcTouch", value: "touched", deviceId: "nfcSensorID0", descriptionText: "",
+                       touchSensorObject[0].setValue([name: "nfcTouch", value: "touched", deviceId: "nfcSensorID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])
index ec7e7ff..803ed21 100644 (file)
@@ -1,2 +1,2 @@
-                       lockObject[0].setValue([name: "unlock", value: "unlocked ", deviceId: "lockID0", descriptionText: "",
+                       lockObject[0].setValue([name: "lock.unlocked", value: "unlocked", deviceId: "lockID0", descriptionText: "",
                                        displayed: true, linkText: "", isStateChange: false, unit: "", data: '{"info": "info"}'])