Removing getXXX methods + properties. Adding getProperty feature to SmartThing(s)
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesis.groovy
index a13e7f7a0ee5ab5378637350cb92a19b925829db..cd57d0ca8c086f51a3799830cb2590c3a2628ac4 100644 (file)
@@ -1,24 +1,33 @@
 //Create a class for speech synthesis
 package SpeechSynthesis
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
 
-public class SpeechSynthesis {
-       private String id
-       private String label
-       private String displayName
-       private int level
+public class SpeechSynthesis extends SmartThing {
+       // id, label, and display name of the device
+       String id
+       String label
+       String displayName
+       // Maps from features to values
+       HashMap<String, Integer> deviceIntValuesMap = new HashMap<String, Integer>()
 
+       SpeechSynthesis(Closure sendEvent, String id, String label, String displayName, Integer currentLevel) {
+               deviceIntValueSmartThing = deviceIntValuesMap
+               idSmartThing = id
+               labelSmartThing = label
+               displayNameSmartThing = displayName
+               sendEventSmartThings = sendEvent
 
-       SpeechSynthesis(String id, String label, String displayName, int level) {
+               // Initialization
                this.id = id
                this.label = label
                this.displayName = displayName
-               this.level = level
+
+               deviceIntValuesMap.put("level", currentLevel)
        }
 
-       def setLevel(int level) {
-               println("The level of speech synthesis with id:$id is changed to $level")
-               this.level = level
+       // Methods to set values
+       def setLevel(int newValue) {
+               action(newValue, "level")
        }
 
        def speak(String message) {