HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: nunofx on August 03, 2014, 11:36:17 PM

Title: Control device based on others trigger (using FGS221)
Post by: nunofx on August 03, 2014, 11:36:17 PM
Hi,

I've a FGS221 where one relay is connected to a light and the other to a fan. I want to turn off the fan 30m after turn off the light.

I did some code but is not working because virtual module is not getting caught on the event change.

Code: [Select]
When.ModuleParameterChanged( (module, parameter) =>
{
if (module.Is("WC Fan") && parameter.Is("Status.Level"))
       {
        if (module.Is("WC Fan") && parameter.Is("Status.IsOn"))
            {
                Pause(1800);
                Modules.WithName("WC Fan").Off();
      return false;
            }       
        }
return true;
});

However module.Is("WC Fan") never returns true but if I use another node that is not virtual, everything works.

Thanks + BRegards,
Nuno
Title: Re: Control device based on others trigger (using FGS221)
Post by: bkenobi on August 04, 2014, 03:05:52 AM
It looks like that should work.  You should consider that using that approach locks your code for 30 minutes though.  You might consider using a timer function instead.  Gene has some examples if you need one (i.e., Smart Lights).  If the pause was shorter (less than a 2-3 minutes), I'd probably just use the pause statement but with a longer hold time it might cause issues.
Title: Re: Control device based on others trigger (using FGS221)
Post by: Gene on August 04, 2014, 03:54:40 PM
Why not using a simple wizard script?

g.
Title: Re: Control device based on others trigger (using FGS221)
Post by: nunofx on August 04, 2014, 11:51:22 PM
Why not using a simple wizard script?

g.

How can I "code" event change trigger using wizard? Can you give me an example?

Are you referring to something like the image?

Btw, the "condition switches to true" only executes the code on the transition from on to off and not during all the time while the light is off, right?

Thanks.
Title: Re: Control device based on others trigger (using FGS221)
Post by: nunofx on August 31, 2014, 07:24:20 PM
Why not using a simple wizard script?

g.

How can I "code" event change trigger using wizard? Can you give me an example?

Are you referring to something like the image?

Btw, the "condition switches to true" only executes the code on the transition from on to off and not during all the time while the light is off, right?

Thanks.

I tested the image's code but if during the count-down I turn on the light and then off, the old timer persists and I want to reset it on this condition. I think only some C# code could solve my problem.