Example #1
0
        public void Integration_test_AllLinkDatabase()
        {
            using (var plm = new Plm())
            {
                var database = plm.GetAllLinkDatabase();
                Assert.IsFalse(plm.Error);
                Assert.IsNotNull(database);

                foreach (var record in database.Records)
                {
                    Debug.Print("Device Id: {0}", record.DeviceId);
                    DeviceBase device;
                    if (plm.Network.TryConnectToDevice(record.DeviceId, out device))
                    {
                        Debug.Print("\tAll Link Database");
                        foreach (var subRecord in device.GetAllLinkDatabase().Records)
                        {
                            Debug.Print("\t\tDevice ID: {0}", subRecord.DeviceId);
                        }
                        if (!device.AllLinkDatabase.Records.Any())
                        {
                            Debug.Print("\t\tNot paired with any devices!");
                        }
                        Debug.Print("\tPeer Device Category: {0}", device.DeviceCategory);
                        Debug.Print("\tPeer Device Subcategory: {0}", device.DeviceSubcategory);
                    }
                    else
                    {
                        Debug.Print("\tFailed to connect to device!");
                    }
                }
            }
        }
        public void Integration_test_AllLinkDatabase()
        {
            using (var plm = new Plm())
            {
                var database = plm.GetAllLinkDatabase();
                Assert.IsFalse(plm.Error);
                Assert.IsNotNull(database);

                foreach (var record in database.Records)
                {
                  Debug.Print("Device Id: {0}", record.DeviceId);
                  DeviceBase device;
                  if (plm.Network.TryConnectToDevice(record.DeviceId, out device))
                  {
                    Debug.Print("\tAll Link Database");
                    foreach (var subRecord in device.GetAllLinkDatabase().Records)
                    {
                      Debug.Print("\t\tDevice ID: {0}", subRecord.DeviceId);
                    }
                    if (!device.AllLinkDatabase.Records.Any())
                    {
                      Debug.Print("\t\tNot paired with any devices!");
                    }
                    Debug.Print("\tPeer Device Category: {0}", device.DeviceCategory);
                    Debug.Print("\tPeer Device Subcategory: {0}", device.DeviceSubcategory);
                  }
                  else
                  {
                     Debug.Print("\tFailed to connect to device!");
                  }
                }
            }
        }
Example #3
0
        public List <InterfaceModule> GetModules()
        {
            // TODO: make 'modules' data persistent in order to store status for various X10 operations (eg. like Control.Level)
            List <InterfaceModule> modules = new List <InterfaceModule>();

            if (insteonPlm != null)
            {
                //
                // X10 modules
                //
                var x10HouseCodes = this.GetOption("HouseCodes");
                if (x10HouseCodes != null && !String.IsNullOrEmpty(x10HouseCodes.Value))
                {
                    string[] hc = x10HouseCodes.Value.Split(',');
                    for (int i = 0; i < hc.Length; i++)
                    {
                        for (int x = 1; x <= 16; x++)
                        {
                            modules.Add(new InterfaceModule()
                            {
                                Domain      = this.Domain,
                                Address     = (hc[i] + x.ToString()),
                                ModuleType  = ModuleTypes.Generic,
                                Description = "X10 Module"
                            });
                        }
                    }
                }
                //
                // Insteon devices discovery
                //
                var database = insteonPlm.GetAllLinkDatabase();
                foreach (var record in database.Records)
                {
                    // Connect to each device to figure out what it is
                    DeviceBase device;
                    if (insteonPlm.Network.TryConnectToDevice(record.DeviceId, out device))
                    {
                        // It responded. Get identification info
                        string address     = device.DeviceId.ToString();
                        string category    = device.DeviceCategoryCode.ToString();
                        string subcategory = device.DeviceSubcategoryCode.ToString();

                        ModuleTypes type = ModuleTypes.Generic;
                        switch (device.GetType().Name)
                        {
                        case "LightingControl":
                            type = ModuleTypes.Light;
                            break;

                        case "DimmableLightingControl":
                            type = ModuleTypes.Dimmer;
                            break;

                        case "SwitchedLightingControl":
                            type = ModuleTypes.Light;
                            break;

                        case "SensorsActuators":
                            type = ModuleTypes.Switch;
                            break;

                        case "WindowCoveringControl":
                            type = ModuleTypes.DoorWindow;
                            break;

                        case "PoolAndSpaControl":
                            type = ModuleTypes.Thermostat;
                            break;

                        case "IrrigationControl":
                            type = ModuleTypes.Switch;
                            break;
                        }

                        modules.Add(new InterfaceModule()
                        {
                            Domain     = this.Domain,
                            Address    = address,
                            ModuleType = type,
                            CustomData = category + "/" + subcategory
                        });
                    }
                    else
                    {
                        // couldn't connect - device removed?
                    }
                }
            }
            return(modules);
        }
Example #4
0
        public List <InterfaceModule> GetModules()
        {
            List <InterfaceModule> modules = new List <InterfaceModule>();

            if (insteonPlm != null)
            {
                //
                // discovery
                //
                var database = insteonPlm.GetAllLinkDatabase();
                foreach (var record in database.Records)
                {
                    // You can attempt to connect to each device
                    // to figure out what it is:
                    DeviceBase device;
                    if (insteonPlm.Network.TryConnectToDevice(record.DeviceId, out device))
                    {
                        // It responded.  You can get identification info like this:
                        string address     = device.DeviceId.ToString();
                        string category    = device.DeviceCategoryCode.ToString();
                        string subcategory = device.DeviceSubcategoryCode.ToString();

                        ModuleTypes type = ModuleTypes.Generic;
                        switch (device.GetType().Name)
                        {
                        case "LightingControl":
                            type = ModuleTypes.Light;
                            break;

                        case "DimmableLightingControl":
                            type = ModuleTypes.Dimmer;
                            break;

                        case "SwitchedLightingControl":
                            type = ModuleTypes.Light;
                            break;

                        case "SensorsActuators":
                            type = ModuleTypes.Switch;
                            break;

                        case "WindowCoveringControl":
                            type = ModuleTypes.DoorWindow;
                            break;

                        case "PoolAndSpaControl":
                            type = ModuleTypes.Thermostat;
                            break;

                        case "IrrigationControl":
                            type = ModuleTypes.Switch;
                            break;
                        }

                        modules.Add(new InterfaceModule()
                        {
                            Domain     = this.Domain,
                            Address    = address,
                            ModuleType = type,
                            CustomData = category + "/" + subcategory
                        });
                    }
                    else
                    {
                        // couldn't connect - device may have been removed?
                    }
                }
            }
            return(modules);
        }