private int deviceNumbers
private List contacts
def sendEvent
-
-
-
+
Contacting(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.deviceNumbers = deviceNumbers
this.contacts = []
- int id = 0
- for (int i = 0;i < deviceNumbers;i++) {
- contacts.add(new Contacts(id, "contact"+id.toString(), "closed", "closed"))//By default closed
- id = id+1
+ if (deviceNumbers == 1) {
+ contacts = [new Contacts(sendEvent, 0, "contact0", "closed", "closed")]
+ } else if (deviceNumbers == 2) {
+ contacts = [new Contacts(sendEvent, 0, "contact0", "closed", "closed"), new Contacts(sendEvent, 1, "contact1", "closed", "closed")]
+ } else if (deviceNumbers == 3) {
+ contacts = [new Contacts(sendEvent, 0, "contact0", "closed", "closed"), new Contacts(sendEvent, 1, "contact1", "closed", "closed")
+ ,new Contacts(sendEvent, 2, "contact2", "closed", "closed")]
}
}
//Global Object for class switch!
@Field def switcheson = new Switching(sendEvent, 1)
//Global Object for class lock!
-@Field def lock1 = new Locking(sendEvent, 2)
+@Field def lock1 = new Locking(sendEvent, 1)
//Global variable for mode!
@Field def newMode = "away"
//Global variable for number!
Locking(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.timers = new Timer()
+ timers.cancel() //Timer is ready to use
this.deviceNumbers = deviceNumbers
this.locks = []
- int id = 0
- for (int i = 0;i < deviceNumbers;i++) {
- locks.add(new Locks(sendEvent, id, "lock"+id, "locked", "locked"))//By default locked
- id = id+1
+ if (deviceNumbers == 1) {
+ locks = [new Locks(sendEvent, 0, "lock0", "locked", "locked")]
+ } else if (deviceNumbers == 2) {
+ locks = [new Locks(sendEvent, 0, "lock0", "locked", "locked"), new Locks(sendEvent, 1, "lock1", "locked", "locked")]
+ } else if (deviceNumbers == 3) {
+ locks = [new Locks(sendEvent, 0, "lock0", "locked", "locked"), new Locks(sendEvent, 1, "lock1", "locked", "locked")
+ ,new Locks(sendEvent, 2, "lock2", "locked", "locked")]
}
}
this.lockCurrentValue = lockCurrentValue
this.lockLatestValue = lockLatestValue
this.timers = new Timer()
+ timers.cancel() //Timer is ready to use
}
//By Apps
Switches(Closure sendEvent, int id, String displayName, String switchCurrentValue, String switchLatestValue) {
this.sendEvent = sendEvent
this.timers = new Timer()
+ timers.cancel() //Timer is ready to use
this.id = id
this.displayName = displayName
this.switchCurrentValue = switchCurrentValue
Switching(Closure sendEvent, int deviceNumbers) {
this.sendEvent = sendEvent
this.timers = new Timer()
+ timers.cancel() //Timer is ready to use
this.deviceNumbers = deviceNumbers
this.switches = []
- int id = 0
- for (int i = 0;i < deviceNumbers;i++) {
- switches.add(new Switches(sendEvent, id, "switch"+id.toString(), "off", "off"))
- id = id+1
+ if (deviceNumbers == 1) {
+ switches = [new Switches(sendEvent, 0, "switch0", "off", "off")]
+ } else if (deviceNumbers == 2) {
+ switches = [new Switches(sendEvent, 0, "switch0", "off", "off"), new Switches(sendEvent, 1, "switch1", "off", "off")]
+ } else if (deviceNumbers == 3) {
+ switches = [new Switches(sendEvent, 0, "switch0", "off", "off"), new Switches(sendEvent, 1, "switch1", "off", "off")
+ ,new Switches(sendEvent, 2, "switch2", "off", "off")]
}
+ println("salam")
}
//By Apps
//Global Object for class switch!
@Field def switcheson = new Switching(sendEvent, 1)
//Global Object for class lock!
-@Field def lock1 = new Locking(sendEvent, 2)
+@Field def lock1 = new Locking(sendEvent, 1)
//Global variable for mode!
@Field def newMode = "away"
//Global variable for number!