more G-Labs products

Author Topic: Gene - API Help needed  (Read 494 times)

October 04, 2016, 10:12:15 AM
Read 494 times

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
Gene (or anyone else with the knowledge)

I am writing a test app at the moment (with a view to making it an interface once the debugging is done)

I need a list of the modules which I have done by making an api call:


Code: [Select]
        public List<Module> GetModules(string host)
        {
            var url = $"http://{host}/api/HomeAutomation.HomeGenie/Config/Modules.List";
            return JsonConvert.DeserializeObject<List<Module>>(this.Get(url));
        }


and creating /copying classes to represent the module and group structure.. I also get module properties..

Code: [Select]
    class Module
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public string DeviceType { get; set; }
        public string Domain { get; set; }
        public string Address { get; set; }
        public ModuleProperties[] Properties { get; set; }
        public string RoutingNode { get; set; }
    }

    public class ModuleProperties
    {

        public string Name { get; set; }
        public string Description { get; set; }
        public string Value { get; set; }
        public string UpdateTime { get; set; }
       
    }


 I have a test program running in HG, which currently does:

Code: [Select]
Program.Setup(()=>{
  Program.AddFeature("", "Switch,Light", "Module.GUID", "Module Guid","text");
});

As I want to populate modules with a GUID that I can use to identify them.

How do I know from the API what 'features' are available on a module? - or is it possible to set a default value on a feature? (IE 00000-0000-0000 (IE.. blank guid, I know that's not the correct format!) so that I can then find the ones with blank values, ie I haven't yet set it.


I'm also assuming if I take the module and add the additional property to the module properties array and then post that at:

http://ip/api/HomeAutomation.HomeGenie/Config/Modules.Update/

it should add the property?

it would be nice if modules had a guid by default however :)



« Last Edit: October 04, 2016, 10:14:26 AM by [email protected] »

October 04, 2016, 07:26:00 PM
Reply #1

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
Fixed it by editing the class for NeedsUpdate and UpdateTime..

its pretty horrible code I've written though... refactor later.