Commit #9: More classes + Extractor with Rahmadi's editions + Fixing some bugs
[smartthings-infrastructure.git] / SmokeDetector / SmokeDetector.groovy
diff --git a/SmokeDetector/SmokeDetector.groovy b/SmokeDetector/SmokeDetector.groovy
new file mode 100644 (file)
index 0000000..3182cc3
--- /dev/null
@@ -0,0 +1,41 @@
+//Create a class for smoke detector
+package SmokeDetector
+import Timer.SimulatedTimer
+
+public class SmokeDetector {
+       private String id
+       private String label
+       private String displayName
+       private String smoke
+       private String currentSmokeValue
+       private String smokeLatestValue
+
+       SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) {
+               this.id = id
+               this.label = label
+               this.displayName = displayName
+               this.smoke = smoke
+               this.currentSmokeValue = smoke
+               this.smokeLatestValue = smokeLatestValue
+       }
+
+       def setValue(String value) {
+               this.smokeLatestValue = smoke
+               println("the smoke detector with id:$id is triggered to $value!")
+               this.smoke = value
+               this.currentSmokeValue = value
+       }
+
+       
+       def currentValue(String deviceFeature) {
+               if (deviceFeature == "smoke") {
+                       return currentSmokeValue
+               }
+       }
+
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "smoke") {
+                       return smokeLatestValue
+               }
+       }
+}