HomeGenie Forum
Automation Program Plugins and Wizard Scripting => Help => Topic started by: clintonearl on December 02, 2015, 04:38:26 AM
-
Hello! New to HomeGenie and wish to create a few virtual switches to keep track of general states around the house (whether we're home, whether we have guests, etc).
I've attempted to create virtual switches a few different times, but I cannot seem to properly interact with them once they're created.
Here's the code I'm currently attempting- a simple AddVirtualModules, grab it, turn it on, and then read its value. This always returns false, though.
Program.AddVirtualModules("HomeAutomation.VirtualSwitches", "Switch", "homegenie/generic/switch", 1, 4);
var module1 = Modules.InDomain("HomeAutomation.VirtualSwitches").WithAddress("1").Get();
module1.On();
Program.Notify("First virtual switch", "" + module1.IsOn);
Please help!
Thanks,
-Clint
-
I've had issues using IsOn in the past so I just check status of the module manually.
module1.Parameters("Status.Level").Value
This will be 0 if off and up to 1 if on. IsOn would be cleaner but for whatever reason it wasn't working when I tried to use it (meaning I was implementing it incorrectly clearly).
-
bkenobi, thanks for the reply!
I found out my issue: you need to have the program enabled before you can interact with the virtual switches. The program created the switches fine, I was able to create modules for them, but it wasn't until the program was enabled that I could actually start setting their levels. If this was included in the docs, I must have missed it. :)
Now that I've figured that out, I'm on my way and loving HomeGenie!