HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: amji71 on June 04, 2015, 02:44:34 AM

Title: How to enable and disable a program using virtual switch
Post by: amji71 on June 04, 2015, 02:44:34 AM
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!
Title: Re: How to enable and disable a program using virtual switch
Post by: bkenobi on June 04, 2015, 04:54:12 AM
The easiest thing would probably just adding the virtual switch value in the trigger code.
Title: Re: How to enable and disable a program using virtual switch
Post by: dani on June 04, 2015, 10:27:52 AM
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
Title: Re: How to enable and disable a program using virtual switch
Post by: amji71 on June 21, 2015, 12:22:42 AM
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!