more G-Labs products

Author Topic: handle event (csharp)  (Read 2060 times)

October 12, 2014, 02:52:02 PM
Read 2060 times

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
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 :
Code: [Select]
When.ModuleParameterChanged( (module, parameter) =>
{ if(module.Is("TelecommandeInvit"))  {
But the script never go in this "if".

If i don't use the :
Code: [Select]
When.ModuleParameterChanged( (module, parameter) =>The if is always ok and do the action all the time ....

Any idea ?

Bye

October 13, 2014, 04:10:23 AM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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.

October 13, 2014, 03:13:04 PM
Reply #2

MickEE

  • *
  • Information
  • Newbie
  • Posts: 17
    • MikaelStenstrand.com
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.

Code: [Select]
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:
Code: [Select]
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/d4/dd7/class_home_genie_1_1_automation_1_1_scripting_1_1_events_helper.html

October 17, 2014, 01:19:01 PM
Reply #3

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544
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 :
Code: [Select]
Modules.InDomain("HomeAutomation.ZWave").WithAddress("51").DecimalValue == 3.00
Code: [Select]
Modules.WithName("TelecommandeInvit")
Code: [Select]
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
« Last Edit: October 17, 2014, 01:26:25 PM by nolio »

October 17, 2014, 09:31:37 PM
Reply #4

nolio

  • *****
  • Information
  • Global Moderator
  • Posts: 544

It work with the trigger code like this one :
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 ;)

October 17, 2014, 10:00:18 PM
Reply #5

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
It looks like you're trying to do what I'm trying:
http://www.homegenie.it/forum/index.php?topic=366.0

Still haven't got it to work unfortunately...