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