//Global Object for class switch!
-@Field def switchesoff = new switching(1)
+@Field def switchesoff = new switching(3)
//Global Object for class switch!
-@Field def switcheson = new switching(1)
+@Field def switcheson = new switching(3)
//Global Object for class lock!
-@Field def lock1 = new locking(1)
+@Field def lock1 = new locking(2)
//Global variable for mode!
-@Field def newMode = "away"
+@Field def newMode = "home"
//Global variable for number!
-@Field def waitfor = 5
+@Field def waitfor = 10
//Global Object for functions in subscribe method!
@Field def installed = this.&installed
//Global Object for functions in subscribe method!
private String displayName
private String currentSwitch
private String switchLatestValue
+ def Timers
switches(int id, String displayName, String currentSwitch, String switchLatestValue) {
+ this.Timers = new Timer()
this.id = id
this.displayName = displayName
this.currentSwitch = currentSwitch
}
def on(LinkedHashMap LHM) {
- sleep(LHM["delay"])
- println("the switch with id:$id is on!")
- this.switchLatestValue = this.currentSwitch
- this.currentSwitch = "on"
+ def task = Timers.runAfter(LHM["delay"]) {
+ println("the switch with id:$id is on!")
+ this.switchLatestValue = this.currentSwitch
+ this.currentSwitch = "on"
+ }
}
def off() {
}
def off(LinkedHashMap LHM) {
- sleep(LHM["delay"])
- println("the switch with id:$id is off!")
- this.switchLatestValue = this.currentSwitch
- this.currentSwitch = "off"
+ def task = Timers.runAfter(LHM["delay"]) {
+ println("the switch with id:$id is off!")
+ this.switchLatestValue = this.currentSwitch
+ this.currentSwitch = "off"
+ }
}
def currentValue(String S) {
public class switching{
List switches
int count
+ def Timers
switching(int count) {
+ this.Timers = new Timer()
this.count = count
if (count == 1) {
switches = [new switches(0, "switch0", "off", "off")]
def on(LinkedHashMap LHM) {
if (count == 1) {
- sleep(LHM["delay"])
- switches[0].on()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches[0].on()
+ }
} else {
- sleep(LHM["delay"])
- switches*.on()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches*.on()
+ }
}
}
def off(LinkedHashMap LHM) {
if (count == 1) {
- sleep(LHM["delay"])
- switches[0].off()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches[0].off()
+ }
} else {
- sleep(LHM["delay"])
- switches*.off()
+ def task = Timers.runAfter(LHM["delay"]) {
+ switches*.off()
+ }
}
}
//ExtractedObjects
//Global Object for class switch!
-@Field def switchesoff = new switching(1)
+@Field def switchesoff = new switching(3)
//Global Object for class switch!
-@Field def switcheson = new switching(1)
+@Field def switcheson = new switching(3)
//Global Object for class lock!
-@Field def lock1 = new locking(1)
+@Field def lock1 = new locking(2)
//Global variable for mode!
-@Field def newMode = "away"
+@Field def newMode = "home"
//Global variable for number!
-@Field def waitfor = 5
+@Field def waitfor = 10
//Global Object for functions in subscribe method!
@Field def installed = this.&installed
//Global Object for functions in subscribe method!