Adding conflict variable in SpeechSynthesis device.
[smartthings-infrastructure.git] / SpeechSynthesis / SpeechSynthesises.groovy
index 50417cc8615a278a5bb8fce4f87ce69122c29b9b..69601c48d37019a82048cd8f82c8f7e6cca3de17 100644 (file)
@@ -12,6 +12,7 @@ public class SpeechSynthesises {
        private String label = "speechSynthesis0"
        private String displayName = "speechSynthesis0"
        private int level = 50
+       private boolean oneUser = true
 
                
        SpeechSynthesises(Closure sendEvent, int deviceNumbers, boolean init) {
@@ -21,10 +22,12 @@ public class SpeechSynthesises {
 
                if (init) {
                        this.level = 50
+                       this.oneUser = true
                } else {
                        this.level = 60
+                       this.oneUser = false
                }
-               speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level))
+               speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level, this.oneUser))
        }
 
        //Methods for closures
@@ -56,6 +59,12 @@ public class SpeechSynthesises {
 
        def speak(String message) {
                speechSynthesises[0].speak(message)
+               // As a conflict variable
+               if (oneUser) {
+                       oneUser = false
+               } else {
+                       oneUser = true
+               }
        }
 
        def getAt(int ix) {