Fixing bugs in infra
[smartthings-infrastructure.git] / ColorTemperature / ColorTemperatures.groovy
1 //Create a class for color temperature
2 package ColorTemperature
3 import SmartThing.SmartThings
4
5 //Importing mutable integer class
6 import MutableInteger.MutableInteger
7
8 public class ColorTemperatures extends SmartThings {
9         List colorTemperatues = new ArrayList()
10
11         ColorTemperatures(Closure sendEvent, boolean init) {
12                 // Only initialize one time since we only have one device for each capability
13                 colorTemperatues = smartThings
14
15                 // Initialization
16                 StringBuilder id = new StringBuilder("colorTemperatureID0")
17                 StringBuilder label = new StringBuilder("colorTemperature")
18                 StringBuilder displayName = new StringBuilder("colorTemperature0")
19                 MutableInteger colorTemperatue = new MutableInteger()
20
21                 if (init)
22                         colorTemperature = 10000
23                 else
24                         colorTemperatues = 15000
25
26                 colorTemperatues.add(new ColorTemperature(sendEvent, id, label, displayName, colorTemperature))
27         }
28         
29         // Methods to set values
30         def setColorTemperature(int newValue) {
31                 colorTemperatues[0].setColorTemperature(newValue)
32         }
33
34         // Methods to return values
35         def getCurrentColorTemperature() {
36                 List tmpValues = new ArrayList()
37                 tmpValues.add(colorTemperatues[0].getCurrentColorTemperature())
38                 return tmpValues
39         }
40 }