Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / SleepSensor / SleepSensor.groovy
index 5f6ff9e1582098fa85cdcf14db780fea113e1d1f..4ae6f089956150156dc36602151a7b02351c7c0c 100644 (file)
@@ -1,23 +1,27 @@
 //Create a class for sleep sensor
 package SleepSensor
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
 
-public class SleepSensor {
-       private String id
-       private String label
-       private String displayName
-       private String sleeping
+public class SleepSensor extends SmartThing {
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
+       // Maps from features to values
+       HashMap<String, String> deviceValuesMap = new HashMap<String, String>()
 
-       SleepSensor(String id, String label, String displayName, String sleeping) {
+       SleepSensor(Closure sendEvent, String id, String label, String displayName, String currentSleeping) {
+               deviceValueSmartThing = deviceValuesMap
+               idSmartThing = id
+               labelSmartThing = label
+               displayNameSmartThing = displayName
+               sendEventSmartThings = sendEvent
+
+               // Initialization
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.sleeping = sleeping
-       }
 
-       //By Model Checker
-       def setValue(String value) {
-               println("the sleeping state is changed to $value!")
-               this.sleeping = value
+               deviceValuesMap.put("sleeping", currentSleeping)
        }
 }