I edited the RelayActuator sketch to include 4 relays, on pins 3 to 6. I was having an issue controlling them so dug further, I can only see 3 of the 4 sensors in MYSController and added some serial debugging to the sketch to pinpoint where things are going wrong.
This is the output:
send: 2-2-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.3
send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-2 s=255,c=3,t=15,pt=0,l=1,sg=0:0
read: 0-0-2 s=255,c=3,t=6,pt=0,l=1,sg=0:M
sensor started, id=2, parent=0, distance=1
send: 2-2-0-0 s=255,c=3,t=11,pt=0,l=16,sg=0,st=ok:Desk Power Relay
send: 2-2-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
Init Sensor : 1, pin 3
before present...
send: 2-2-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
before pinMode...
Sensor configured - OK!
Init Sensor : 2, pin 4
before present...
send: 2-2-0-0 s=2,c=0,t=3,pt=0,l=0,sg=0,st=ok:
before pinMode...
Sensor configured - OK!
Init Sensor : 3, pin 5
before present...
send: 2-2-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,st=ok:
before pinMode...
Sensor configured - OK!
Init Sensor : 4, pin 6
before present...
The code was modified as follows:
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
Serial.print("Init Sensor : ");
Serial.print(sensor);
Serial.print(", pin ");
Serial.println(pin);
// Register all sensors to gw (they will be created as child devices)
Serial.println("before present...");
gw.present(sensor, S_LIGHT);
// Then set relay pins in output mode
Serial.println("before pinMode...");
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
Serial.println("Sensor configured - OK!");
Serial.println();
}
On the 4th sensor, it never gets past the present line.