HomeGenie Forum
General Category => Troubleshooting and Support => Topic started by: kevinvinv on January 11, 2016, 04:52:18 AM
-
The documentation lists a particular API call like this for example
/api/HomeAutomation.X10/<module_address>/Control.Off
But how do I understand how to CALL this "function" from C# for example? That doesn't seem to be clear to me.
Thanks for your patience! :)
-
The API you mentioned is what is referred to as "webapi" (I think, that's how I refer to it anyway). The widgets and external code can "call" these to execute things in HG. I use these webapi URL's to link my Amazon Echo to IFTTT to turn on lights:
http://<IP>/api/HomeAutomation.X10/A1/Control.On
http://<IP>/api/HomeAutomation.ZWave/16/Control.Off
Depending how a given module is coded, it can return a value (to the web browser) like:
result: {"ResponseValue":"OK"}
To turn a module off you could do (examples are not tested so not 100% sure accurate):
Modules.WithName("Light 1").On();
Modules.InGroup("Living Room").WithName("Lamp").Off();
Modules.WithAddress("A1").On();
var sirenModules = Modules.WithFeature("HomeGenie.SecurityAlarm").OfDeviceType("Siren");
sirenModules.On();
//if you are inside an if statement to match name, group, features etc, then
module.Off();
-
Read here about the API command syntax:
http://genielabs.github.io/HomeGenie/api/mig/overview.html (http://genielabs.github.io/HomeGenie/api/mig/overview.html)
In your example we have
/api/HomeAutomation.X10/<module_address>/Control.Off
domain = HomeAutomation.X10
address = <module_address> (let's prentend it to be "A5")
command = Control.Off
So to call this from a script you will use:
var module = Modules.InDomain("HomeAutomation.X10").WithAddress("A5");
module.Command("Control.Off").Execute();
// or as kevin1 said you can use the shortcut
module.Off();
reading this http://genielabs.github.io/HomeGenie/programs.html (http://genielabs.github.io/HomeGenie/programs.html) can also help.
Cheers,
g.