df299ebef448c25b8f77c7326ca1619125772d33
[smartthings-infrastructure.git] / Battery / Battery.groovy
1 //Create a class for battery
2 package Battery
3 import Timer.SimulatedTimer
4
5 public class Battery {
6         private String id
7         private String label
8         private String displayName
9         private String battery
10         private String currentBattery
11
12         Battery(String id, String label, String displayName, String battery) {
13                 this.id = id
14                 this.label = label
15                 this.displayName = displayName
16                 this.battery = battery
17                 this.currentBattery = battery
18         }
19
20         //By Model Checker
21         def setValue(String value) {
22                 println("the battery level with id:$id is changed to $value!")
23                 this.battery = value.toInteger()
24                 this.currentBattery = value.toInteger()
25         }
26
27         def currentValue(String deviceFeature) {
28                 if (deviceFeature == "battery") {
29                         return battery
30                 }
31         }
32
33 }