more G-Labs products

Author Topic: Unable to update virtual modules?  (Read 971 times)

December 02, 2015, 04:38:26 AM
Read 971 times

clintonearl

  • *
  • Information
  • Newbie
  • Posts: 2
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.

Code: [Select]
Program.AddVirtualModules("HomeAutomation.VirtualSwitches", "Switch", "homegenie/generic/switch", 1, 4);
Code: [Select]
var module1 = Modules.InDomain("HomeAutomation.VirtualSwitches").WithAddress("1").Get();
module1.On();
Program.Notify("First virtual switch", "" + module1.IsOn);

Please help!

Thanks,
-Clint
« Last Edit: December 02, 2015, 12:25:27 PM by clintonearl »

December 02, 2015, 04:42:25 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I've had issues using IsOn in the past so I just check status of the module manually.

Code: [Select]
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).

December 06, 2015, 03:13:17 PM
Reply #2

clintonearl

  • *
  • Information
  • Newbie
  • Posts: 2
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!