Adding event for Power as variation is needed in power values.
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesis.groovy
index a13e7f7a0ee5ab5378637350cb92a19b925829db..1f25d79b5c873edf53c060076b4281ea383c8c5c 100644 (file)
@@ -7,21 +7,31 @@ public class SpeechSynthesis {
        private String label
        private String displayName
        private int level
+       private boolean oneUser
 
 
-       SpeechSynthesis(String id, String label, String displayName, int level) {
+       SpeechSynthesis(String id, String label, String displayName, int level, boolean oneUser) {
                this.id = id
                this.label = label
                this.displayName = displayName
                this.level = level
+               this.oneUser = oneUser
        }
 
        def setLevel(int level) {
-               println("The level of speech synthesis with id:$id is changed to $level")
-               this.level = level
+               if (level != this.level) {
+                       println("The level of speech synthesis with id:$id is changed to $level")
+                       this.level = level
+               }
        }
 
        def speak(String message) {
                println("Speech synthesis with id:$id, SPEAKING:\"$message\"!")
+               // As a conflict variable
+               if (oneUser) {
+                       this.oneUser = false
+               } else {
+                       this.oneUser = true
+               }
        }
 }