Thanks for the fantastic support, however I'm afraid my lack of knowledge of C# is letting me down.
I managed to get a single switch to work fine, in fact the code below allows one switch to work correctly, also using the api I can get all 3 to operate but no matter how I try I can't get more than one to oporate from the GUI.. Can anyone advise, much appreciated.
Program.AddVirtualModules("Components.RFX433A", "Switch", "homegenie/generic/switch", 1, 3);
var portname = "/dev/ttyUSB0";
SerialPort
.WithName( portname )
.Connect( 38400 );
When.WebServiceCallReceived("Components.RFX433A", ( args ) =>
{
string[] reqs = ((string)args).Split('/');
var res = "{ 'ResponseValue' : 'ERROR' }";
try
{
string command = reqs[2];
var module1 = Modules.InDomain("Components.RFX433A").WithAddress("1").Get();
var module2 = Modules.InDomain("Components.RFX433A").WithAddress("2").Get();
var module3 = Modules.InDomain("Components.RFX433A").WithAddress("3").Get();
switch(command)
{
case "Control.On":
byte[] message = { 0x0A, 0x14, 0x00, 0x02, 0xF4, 0x5F, 0x59, 0x01, 0x01, 0x00, 0x00 };
SerialPort.SendMessage(message);
Program.RaiseEvent(module1, "Status.Level", "1", "RFX433A");
res = "{ 'ResponseValue' : 'OK' }";
break;
case "Control.Off":
byte[] message2 = { 0x0A, 0x14, 0x00, 0x02, 0xF4, 0x5F, 0x59, 0x01, 0x00, 0x00, 0x00 };
SerialPort.SendMessage(message2);
Program.RaiseEvent(module1, "Status.Level", "0", "RFX433A");
res = "{ 'ResponseValue' : 'OK' }";
break;
case "Control2.On":
byte[] message3 = { 0x0A, 0x14, 0x00, 0x02, 0xF3, 0x17, 0xE0, 0x08, 0x01, 0x00, 0x00 };
SerialPort.SendMessage(message3);
Program.RaiseEvent(module2, "Status.Level", "1", "RFX433A");
res = "{ 'ResponseValue' : 'OK' }";
break;
case "Control2.Off":
byte[] message4 = { 0x0A, 0x14, 0x00, 0x02, 0xF3, 0x17, 0xE0, 0x08, 0x00, 0x00, 0x00 };
SerialPort.SendMessage(message4);
Program.RaiseEvent(module2, "Status.Level", "0", "RFX433A");
res = "{ 'ResponseValue' : 'OK' }";
break;
case "Control3.On":
byte[] message5 = { 0x0A, 0x14, 0x00, 0x02, 0xF3, 0x17, 0xE0, 0x0D, 0x01, 0x00, 0x00 };
SerialPort.SendMessage(message5);
Program.RaiseEvent(module3, "Status.Level", "1", "RFX433A");
res = "{ 'ResponseValue' : 'OK' }";
break;
case "Control3.Off":
byte[] message6 = { 0x0A, 0x14, 0x00, 0x02, 0xF3, 0x17, 0xE0, 0x0D, 0x00, 0x00, 0x00 };
SerialPort.SendMessage(message6);
Program.RaiseEvent(module3, "Status.Level", "0", "RFX433A");
res = "{ 'ResponseValue' : 'OK' }";
break;
}
}
catch (Exception ex)
{
res = ex.Message + " " + ex.StackTrace;
}
// unable to process request
return res;
});
//
Program.GoBackground();