Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesis.groovy
1 //Create a class for speech synthesis
2 package SpeechSynthesis
3 import SmartThing.SmartThing
4
5 public class SpeechSynthesis extends SmartThing {
6         // id, label, and display name of the device
7         String id
8         String label
9         String displayName
10         // Maps from features to values
11         HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
12
13         SpeechSynthesis(Closure sendEvent, String id, String label, String displayName, Integer currentLevel) {
14                 deviceIntValueSmartThing = deviceIntValuesMap
15                 idSmartThing = id
16                 labelSmartThing = label
17                 displayNameSmartThing = displayName
18                 sendEventSmartThings = sendEvent
19
20                 // Initialization
21                 this.id = id
22                 this.label = label
23                 this.displayName = displayName
24
25                 deviceIntValuesMap.put("level", currentLevel)
26         }
27
28         // Methods to set values
29         def setLevel(int newValue) {
30                 action(newValue, "level")
31         }
32
33         def speak(String message) {
34                 println("Speech synthesis with id:$id, SPEAKING:\"$message\"!")
35         }
36 }