Fixing a bug: should have been pushed, not push.
[smartthings-infrastructure.git] / Battery / Battery.groovy
index 5358fbdb6d465bd80c2b79846618a95c28be279f..df4b01a4eb26b43ffc75fb59ab718711240000af 100644 (file)
@@ -8,6 +8,7 @@ public class Battery {
        private String displayName
        private int battery
        private int currentBattery
+       private int batteryLatestValue
 
        Battery(String id, String label, String displayName, int battery) {
                this.id = id
@@ -15,6 +16,7 @@ public class Battery {
                this.displayName = displayName
                this.battery = battery
                this.currentBattery = battery
+               this.batteryLatestValue = battery
        }
 
        //By Model Checker
@@ -22,6 +24,7 @@ public class Battery {
                println("the battery level with id:$id is changed to $value!")
                this.battery = value.toInteger()
                this.currentBattery = value.toInteger()
+               this.batteryLatestValue = value.toInteger()
        }
 
        def currentValue(String deviceFeature) {
@@ -30,4 +33,10 @@ public class Battery {
                }
        }
 
+       def latestValue(String deviceFeature) {
+               if (deviceFeature == "battery") {
+                       return batteryLatestValue
+               }
+       }
+
 }