HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: KaZe on March 11, 2015, 11:40:25 AM
-
Hi!
I need little help!
I wrote a C # program to manage eight relays.
I created the switches with the following code:
Program.AddVirtualModules ("HomeAutomation.SettingSwitch", "Switch", "homegenie / generic / switch", 1, 8);
The relays status every 5 seconds retrieves, and attempts to set the virtual switch status of the returned value ("status level").
I can look at the states with the following code:
var SettingSwitchModules = Modules.InDomain("HomeAutomation.SettingSwitch");
for (int i = 0; i < 8; i++)
{
var module = SettingSwitchModules.WithAddress((8-i).ToString()).Get();
if ((module.Parameter("Status.Level").DecimalValue).ToString() != relayarray[i].ToString())
{
if ((module.Parameter("Status.Level").DecimalValue).ToString() =="1")
{
Program .Notify("Switch","You need to turn OFF the relay "+(8-i).ToString()");
}
}
}
How do I the state of the virtual switches (status level) change?
-
I found the answer in the other topic:
// Turn Switch on
module.Command("Control.On").Set();
// or Off
module.Command("Control.Off").Set();
// or Toggle the switch
module.Command("Control.Toggle").Set();
It"s works!
-
Your code has an extra space in the notify line:
Program .Notify("Switch","You need to turn OFF the relay "+(8-i).ToString()");
Should be
Program.Notify("Switch","You need to turn OFF the relay "+(8-i).ToString()");
Also, you should be able to simplify your commands to control the relay state to:
// Turn Switch on
module.On();
// or Off
module.Off();
// or Toggle the switch
module.Toggle();
-
Thx!
I updated my code.