HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: nolio on October 12, 2014, 02:52:02 PM
-
Hi,
I try a simple csharp script to do an action when my generic sensor (aeon labs keyfob) is pressed. But with the following script :
When.ModuleParameterChanged( (module, parameter) =>
{ if(module.Is("TelecommandeInvit")) {
But the script never go in this "if".
If i don't use the :
When.ModuleParameterChanged( (module, parameter) =>
The if is always ok and do the action all the time ....
Any idea ?
Bye
-
Are you sure that you can address the module by "module.Is("TelecommandeInvit")"? That doesn't sound like the right way to address it, but I could be wrong.
-
Hi there,
Are you sure the button is named "TelecommandeInvit"? By adding the input/button module to a group (Configure - Groups and Modules - Actions+add module) you will be prompted to change the name of the module.
Here is an example of button press and button release events of a button named "InputButton".
The return statement of this function will determine if the thread should continue to find the trigger code for this ModuleParameterChange-event.
When.ModuleParameterChanged( (module, parameter) => {
if(module.Is( "InputButton" )) {
// button press
if( parameter.Name == "Status.Level" && parameter.Value == "0") {
// CODE HERE
return false;
}
// Button Release
else if( parameter.Name == "Status.Level" && parameter.Value == "1") {
// CODE HERE
return false;
}
}
return true;
});
You can also check for the type of module that has been changed:
if (module.IsOfDeviceType("Sensor"))
Documentation can be found on the following links:
http://www.homegenie.it/docs/doxy/d8/dc4/class_home_genie_1_1_automation_1_1_scripting_1_1_module_helper.html (http://www.homegenie.it/docs/doxy/d8/dc4/class_home_genie_1_1_automation_1_1_scripting_1_1_module_helper.html)
http://www.homegenie.it/docs/doxy/d4/dd7/class_home_genie_1_1_automation_1_1_scripting_1_1_events_helper.html (http://www.homegenie.it/docs/doxy/d4/dd7/class_home_genie_1_1_automation_1_1_scripting_1_1_events_helper.html)
-
Hi,
My button has not a name. "TelecommandeInvit" is the name of the device and the press button are number between 1 to 8.
I already try the other following code :
Modules.InDomain("HomeAutomation.ZWave").WithAddress("51").DecimalValue == 3.00
Modules.WithName("TelecommandeInvit")
parameter.DecimalValue == 3.00
With the existing function, perhaps, i can't do ...
Bye
PS : I am going to try something with "trigger code" like :
http://www.homegenie.it/forum/index.php?topic=407.0 (http://www.homegenie.it/forum/index.php?topic=407.0)
-
It work with the trigger code like this one :
http://www.homegenie.it/forum/index.php?topic=407.msg2343#msg2343 (http://www.homegenie.it/forum/index.php?topic=407.msg2343#msg2343)
and with "When condition evaluation switches to 'true'".
But i need to press another button to trigger again the code ...
So not exactly what i want but nearly ;)
-
It looks like you're trying to do what I'm trying:
http://www.homegenie.it/forum/index.php?topic=366.0 (http://www.homegenie.it/forum/index.php?topic=366.0)
Still haven't got it to work unfortunately...