more G-Labs products

Author Topic: How to enable and disable a program using virtual switch  (Read 1162 times)

June 04, 2015, 02:44:34 AM
Read 1162 times

amji71

  • *
  • Information
  • Newbie
  • Posts: 10
How do I enable/disable an automation program using a virtual switch?  What is the c# reference for enabling/disabling a program?

I have written the bit where presence sets the values for a thermostat. Now i wish to override this function by disabling this program for the times i do not want thermostat values to be determined by presence. I understand I can use a virtual switch, but what is the code that would enable/disable a program?

Thanks!

June 04, 2015, 04:54:12 AM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
The easiest thing would probably just adding the virtual switch value in the trigger code.

June 04, 2015, 10:27:52 AM
Reply #2

dani

  • *****
  • Information
  • Global Moderator
  • Posts: 535
For Enabled the program, the syntax is Program.Run("ID or NAME");
For Desabled, there is the command Stop() but you have to get the pointer of the program, I don't find a command as Run(), or you have to set a parameter that is read by your program.

Or Yes as bkenoki says, the virtual switch is attach to your program as I preconise to igorbertifoc for squeezebox (Sources on APP CONTRIBUTION)

Cheers
Dani
« Last Edit: June 04, 2015, 10:37:54 AM by dani »

June 21, 2015, 12:22:42 AM
Reply #3

amji71

  • *
  • Information
  • Newbie
  • Posts: 10
Thank you Dani and Bkenobi!

This is how I finally made it work:

Net.WebService("http://username:password@ipaddressofthemachine/api/HomeAutomation.HomeGenie/Automation/Programs.Enable/1000(where this number is the number of the program)").GetData();

for disabling:
Net.WebService("http://192.168.1.X/api/HomeAutomation.HomeGenie/Automation/Programs.Disable/1000").GetData();

This works beautifully with a Virtual Switch, as you suggested. 
Many thanks!