Infrastruction modification
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesises.groovy
1 //Create a class for speech synthesis
2 package SpeechSynthesis
3 import SmartThing.SmartThings
4
5 public class SpeechSynthesises extends SmartThings {
6         List speechSynthesises = new ArrayList()
7                 
8         SpeechSynthesises(Closure sendEvent, boolean init) {
9                 // Only initialize one time since we only have one device for each capability
10                 speechSynthesises = smartThings
11
12                 // Initialization
13                 StringBuilder id = new StringBuilder("speechSynthesisID0")
14                 StringBuilder label = new StringBuilder("speechSynthesis")
15                 StringBuilder displayName = new StringBuilder("speechSynthesis0")
16                 MutableInteger level = new MutableInteger()
17
18                 if (init)
19                         level.setValue(50)
20                 else
21                         level.setValue(60)
22
23                 speechSynthesises.add(new SpeechSynthesis(sendEvent, id, label, displayName, level))
24         }
25
26         // Methods to set values
27         def setLevel(int level) {
28                 speechSynthesises[0].setLevel(level)
29         }
30
31         def speak(String message) {
32                 speechSynthesises[0].speak(message)
33         }
34
35         // Methods to return values
36         def getCurrentLevel() {
37                 List tmpValues = new ArrayList()
38                 tmpValues.add(speechSynthesises[0].getCurrentLevel())
39                 return tmpValues
40         }
41
42 }