more G-Labs products

Author Topic: Still don't understand how to find a function call syntax  (Read 1036 times)

January 22, 2016, 04:42:42 AM
Read 1036 times

kevinvinv

  • ****
  • Information
  • Sr. Member
  • Posts: 196
Hi all,  thanks for your patience.

I am still at a loss as to how to figure out the syntax of a particular command - in C# in my case.

As an example. the documentation says something like this:

Set the level of the module with address <module_address> to <level>% (0-100).
Syntax

/api/HomeAutomation.X10/<module_address>/Control.Level/<level>
GET /api/HomeAutomation.X10/A4/Control.Level/35



So how do I figure out how to call that function from a C# script?

Thanks!!!




January 22, 2016, 07:36:53 AM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
That is not the C# code, that is the WebAPI call.  You use that with a web call (e.g., web browser).  There is a different section of the help guide that includes the C# methods but it does not always include an example for seeing syntax (which is something I have struggled with at times.  I generally search the forum for examples for syntax which is not ideal.

January 23, 2016, 04:01:24 PM
Reply #2

kevinvinv

  • ****
  • Information
  • Sr. Member
  • Posts: 196

If you happen across the section of the help that contains ANY functions related to X10 listed...   I'd appreciate a pointer.  I guess I still haven't found it... but will keep looking.

I see the web api stuff which contains a lot of X10 commands -- and I see the "helper" section which seems to contain C# commands but I haven't found any X10 section in there.

Anyhow-  thanks again!!!   

January 24, 2016, 04:45:34 PM
Reply #3

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I've been using HG for a couple years and still struggle with determining syntax from the functions that are listed in the help section.  I generally just try it and see what the error is.  I wish there was a better way, but since I'm not a programmer by trade, this might be the standard way to document.   :-\

January 25, 2016, 04:39:23 PM
Reply #4

louis

  • **
  • Information
  • Jr. Member
  • Posts: 26
Hi Kevin,

Not sure if this is what you need, but have you taken a look at the X10 Firecracker Program.

This contains at least some hints to your question.

I asume you need something like:

var my_X10_mod = Modules.WithName("A4");
my_X10_mod.Level = 35;

I have no way to test it, but in ZWave it does work.

Cheers Louis

January 25, 2016, 11:45:04 PM
Reply #5

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
That's the method I almost always end up using to learn a new language.  Find example code that does similar tasks and glean as much information about syntax as possible.  I generally copy snippets from different sources and stitch them together to construct my first attempts at working code.