//Create a class for smoke detector
package SmokeDetector
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
-public class SmokeDetector {
- private String id
- private String label
- private String displayName
- private String smoke
- private String currentSmokeValue
- private String smokeLatestValue
+public class SmokeDetector 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>()
- SmokeDetector(String id, String label, String displayName, String smoke, String smokeLatestValue) {
+ SmokeDetector(Closure sendEvent, String id, String label, String displayName, String currentSmoke) {
+ deviceValueSmartThing = deviceValuesMap
+ idSmartThing = id
+ labelSmartThing = label
+ displayNameSmartThing = displayName
+ sendEventSmartThings = sendEvent
+
+ // Initialization
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
- }
+ deviceValuesMap.put("smoke", currentSmoke)
}
}