Hi
After a lot of testing it works, but
Channel 1 not received the status from the unit.
channel 2 to 8 change to the real position.
You can see in the log it's accept the changing in the CH 1 and return from true to false but it isn't change the status.
log for ch1 on/off and ch2 on.
1:39:24.433 PM Program.Notification {"Title":"module:","Message":"HomeGenie.Automation.Scripting.ModuleHelper"} 27 HomeAutomation.HomeGenie.Automation
1:39:24.432 PM Program.Notification {"Title":"in else:","Message":"True"} 27 HomeAutomation.HomeGenie.Automation
1:39:24.432 PM Program.Notification {"Title":"staus:","Message":"True"} 27 HomeAutomation.HomeGenie.Automation
1:39:24.431 PM Program.Notification {"Title":"messsage:","Message":"FN,OUT,ON,1"} 27 HomeAutomation.HomeGenie.Automation
1:39:24.431 PM Program.Notification {"Title":"Server String","Message":"FN,OUT,ON,1"}
1:40:20.711 PM Program.Notification {"Title":"module:","Message":"HomeGenie.Automation.Scripting.ModuleHelper"} 27 HomeAutomation.HomeGenie.Automation
1:40:20.710 PM Program.Notification {"Title":"in else:","Message":"False"} 27 HomeAutomation.HomeGenie.Automation
1:40:20.709 PM Program.Notification {"Title":"staus:","Message":"False"} 27 HomeAutomation.HomeGenie.Automation
1:40:20.709 PM Program.Notification {"Title":"messsage:","Message":"\r>FN,OUT,OFF,1"} 27 HomeAutomation.HomeGenie.Automation
1:40:20.709 PM Program.Notification {"Title":"Server String","Message":"\r>FN,OUT,OFF,1"}
1:41:03.109 PM Program.Notification {"Title":"Control","Message":" On"} 27 HomeAutomation.HomeGenie.Automation
1:41:03.109 PM Status.Level 1 2 HomeAutomation.SettingSwitch
1:41:03.108 PM Program.Notification {"Title":"module:","Message":"HomeGenie.Automation.Scripting.ModuleHelper"} 27 HomeAutomation.HomeGenie.Automation
1:41:03.107 PM Program.Notification {"Title":"in else:","Message":"True"} 27 HomeAutomation.HomeGenie.Automation
1:41:03.107 PM Program.Notification {"Title":"staus:","Message":"True"} 27 HomeAutomation.HomeGenie.Automation
1:41:03.107 PM Program.Notification {"Title":"messsage:","Message":"\r>FN,OUT,ON,2"} 27 HomeAutomation.HomeGenie.Automation
1:41:03.107 PM Program.Notification {"Title":"Server String","Message":"\r>FN,OUT,ON,2"}
code
var remoteServer = "192.168.1.147"; //server IP address
var remotePort = 7078; //TCP port
var SettingSwitchModules = Modules.InDomain("HomeAutomation.SettingSwitch");
//Relays control commands
var relay01on = "FN,ON,1\x0D";
var relay02on = "FN,ON,2\x0D";
var relay03on = "FN,ON,3\x0D";
var relay04on = "FN,ON,4\x0D";
var relay05on = "FN,ON,5\x0D";
var relay06on = "FN,ON,6\x0D";
var relay07on = "FN,ON,7\x0D";
var relay08on = "FN,ON,8\x0D";
var relay01off = "FN,OFF,1\x0D";
var relay02off = "FN,OFF,2\x0D";
var relay03off = "FN,OFF,3\x0D";
var relay04off = "FN,OFF,4\x0D";
var relay05off = "FN,OFF,5\x0D";
var relay06off = "FN,OFF,6\x0D";
var relay07off = "FN,OFF,7\x0D";
var relay08off = "FN,OFF,8\x0D";
Action<string> HandleStringReceived = (string message) => {
// this will be called every time a message is received from the tcp channel
Program.Notify("Server String", message);
//string status = "";
var tokens = message.Split(',');
var status = tokens[tokens.Length-2].Equals("ON");
var channel = double.Parse(tokens[tokens.Length-1]);
Program.Notify("messsage:", message);
Program.Notify("staus:", status.ToString());
if (message.StartsWith("") || (message.StartsWith("\r>") || (message.StartsWith("\r>FN,OUT")))) //This should be a condition that is certainly, on the basis that this status message. I think that the status message first character is ">".
{
Program.Notify("in else:", status.ToString());
var module = SettingSwitchModules.WithAddress(channel.ToString()).Get();
Program.Notify("module:", module.ToString());
if (module.Parameter("Status.Level").DecimalValue != channel)
{
if (status)
module.Command("Control.On").Execute();
else
module.Command("Control.Off").Execute();
}
}
};
Br
kobi