Value filtering finished
[smartthings-infrastructure.git] / EnergyMeter / EnergyMeter.groovy
index a0ab13ea73c4363e6743b9347686f7fcb07ac9ff..83f2283c3bdae185c2f27dd7ae8373717c863dbe 100644 (file)
@@ -8,12 +8,14 @@ public class EnergyMeter {
        private String displayName
        private int energy
        private int currentEnergy
+       private String status
 
-       EnergyMeter(String id, String label, String displayName, int energy) {
+       EnergyMeter(String id, String label, String displayName, int energy, String status) {
                this.id = id
                this.label = label
                this.displayName = displayName
                this.energy = energy
+               this.status = status
        }
 
        //By Model Checker
@@ -23,10 +25,29 @@ public class EnergyMeter {
                this.currentEnergy = value.toInteger()
        }
 
+       def reset() {
+               if (status != "on") {
+                       status = "on"
+                       println("the energy meter is on!")
+               }
+       }
+
+       def off() {
+               if (status != "off") {
+                       status = "off"
+                       println("the energy meter is off!")
+               }
+       }
+
        def currentValue(String deviceFeature) {
                if (deviceFeature == "energy") {
                        return energy
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "energy") {
+                       return energy
+               }
+       }
 }