Infrastruction modification
[smartthings-infrastructure.git] / Battery / Batteries.groovy
1 //Create a class for battery
2 package Battery
3 import SmartThing.SmartThings
4
5 public class Batteries extends SmartThings {
6         List batteries = new ArrayList()
7
8         Batteries(Closure sendEvent, boolean init) {
9                 batteries = smartThings
10
11                 StringBuilder id = new StringBuilder("batteryID0")
12                 StringBuilder label = new StringBuilder("battery")
13                 StringBuilder displayName = new StringBuilder("battery0")
14                 MutableInteger battery = new MutableInteger()
15
16                 // Initialization
17                 if (init)
18                         battery.setValue(50)
19                 else
20                         battery.setValue(0)
21
22                 batteries.add(new Battery(sendEvent, id, label, displayName, battery))
23         }
24
25         // Methods to return values
26         def getCurrentBattery() {
27                 List tmpValues = new ArrayList()
28                 tmpValues.add(batteries[0].getCurrentBattery())
29                 return tmpValues
30         }
31 }