HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: Qu3uk on July 04, 2015, 04:36:39 AM

Title: First Program Help - Widget Disconnected
Post by: Qu3uk on July 04, 2015, 04:36:39 AM
Hey,

So I'm new to home genie and as I don't have any hardware it supports I thought I'd attempt to write a program or two. First I thought I'd control the Lightpack I have attached to the TV. I was aiming for simple on/off.

However I've looked over various bits of code and started but hit a hurdle where the widget on/off buttons won't fire the module changed event.

I added the virtual module to the dashboard and nothing, I get the "Entered!" notification sometimes but I'm assuming that's other modules firing. So the question is why is my widget disconnected?

Also as this program is only controlling one device is there much point in having a virtual module, I read there is a module associated to the program but I'm unsure how its addressable.

Code: [Select]
When.ModuleParameterChanged( (module, property) => {
  Program.Notify("HomeAutomation.Prismatik", "Entered!");
  if (module.Instance.Domain == "HomeAutomation.Prismatik" )
{
      Program.Notify("HomeAutomation.Prismatik", "Fired!");
        switch (property.Name) {
          case "Control.On":
          Program.Notify("HomeAutomation.Prismatik", "Command ON");
              break;
          case "Control.Off":
          Program.Notify("HomeAutomation.Prismatik", "Command OFF");
              break;
          default: 
              break;
        }
        return false;
    }
      return true;
});

Program.GoBackground();

Code: [Select]
Program.Setup(()=>{
Program.AddOption("IPAddress", "", "0. Enter IP address of Prismatik", "text");
  Program.AddOption("Port", "", "1. Enter port of Prismatik", "text");
  Program.AddOption("APIKey", "", "2. Prismatik API Key", "text");
 
  Program.AddVirtualModules("HomeAutomation.Prismatik", "Light", "homegenie/generic/colorlight", 1, 1);
 
});

return true;

Title: Re: First Program Help - Widget Disconnected
Post by: dani on July 04, 2015, 09:33:20 AM
When you press On/Off button in a virtual module, it is the When.WebServiceCallReceived that is call.
When.ModuleParameterChanged is call by reception of event from Physical module.

You can find following a program that simulate temp Sensors, Buttons and Dimmers. In the parameter of the module you can tell how many Virtual Modules you want created.

Cheers
Dani
Title: Re: First Program Help - Widget Disconnected
Post by: Qu3uk on July 04, 2015, 09:59:18 PM
Great Thanks! Now that's been pointed out it actually makes sense I guess.

Got it working though, controlling my TV's backlights!
I'll be sure to post the code once I've refined it a little.