Infrastruction modification
[smartthings-infrastructure.git] / Battery / Battery.groovy
1 //Create a class for battery
2 package Battery
3 import SmartThing.SmartThing
4
5 public class Battery extends SmartThing {
6         // id, label, and display name of the device
7         StringBuilder id = new StringBuilder()
8         StringBuilder label = new StringBuilder()
9         StringBuilder displayName = new StringBuilder()
10         // Features with numberical values
11         MutableInteger currentBattery = new MutableInteger()
12         // Maps from features to values
13         HashMap<String, MutableInteger> deviceIntValuesMap = new HashMap<String, MutableInteger>()
14
15         Battery(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentBattery) {
16                 deviceIntValuesMap = deviceIntValueSmartThing
17                 idSmartThing = id
18                 labelSmartThing = label
19                 displayNameSmartThing = displayName
20                 sendEventSmartThings = sendEvent
21
22                 // Initialization
23                 this.id = id
24                 this.label = label
25                 this.displayName = displayName
26                 this.currentBattery = currentBattery
27
28                 deviceIntValuesMap.put("battery", currentBattery)
29         }
30
31         // Methods to return values
32         def getCurrentBattery() {
33                 return currentBattery.toString()
34         }
35 }