HomeGenie Forum

General Category => Troubleshooting and Support => Topic started by: teo1969 on October 29, 2015, 09:37:31 PM

Title: HOW TO Run "Program Code" triggered from "Startup Code"
Post by: teo1969 on October 29, 2015, 09:37:31 PM
Dear, I have a PIR X10 sensor named: "B3" that trigger a C#  program "Startup Code" . I would like to run the code content in  "program code" section, when B3 goes "on".

I develop this code that succesfully read event X10(B3) sensor but i'm not able to run the corresponding "program code" when i recive "B3=on" event.

what 'wrong in my code? .... why when B3 goes "on", and i see my trigger notification, my program code is not executed?

**my startup/trigger code:**
Code: [Select]
When.ModuleParameterChanged((module, parameter) => {
       
        if (module.Is("B3"))
        {
         
          if (parameter.DecimalValue > 0){
              Program.Notify("Event: ON->GO", "execute my program code");
              return true;
  }else{
            Program.Notify("Event OFF: ","do nothing");
                return false;
          }
        }
  return false;
});
Program.GoBackground();

**my Program code:**
Code: [Select]
...
//TODO
Program.Notify("Program Code ","do somethings!!");
...

Many Thx in advance!!
Matteo
Title: Re: HOW TO Run "Program Code" triggered from "Startup Code"
Post by: Gene on October 29, 2015, 09:52:51 PM
move your current "startup code" to the "program code" and just put a
 
Code: [Select]
Program.Run();

in the startup code.
Title: Re: HOW TO Run "Program Code" triggered from "Startup Code"
Post by: teo1969 on October 31, 2015, 09:13:51 AM
Thanks, now it's working.