private void GetCurrentDevices() { var deviceEnumerator = HS.GetDeviceEnumerator() as clsDeviceEnumeration; if (deviceEnumerator == null) { throw new HspiException(Invariant($"{PluginData.PlugInName} failed to get a device enumerator from HomeSeer.")); } string parentAddress = DeviceIdentifier.CreateRootAddress(rootDeviceId); do { DeviceClass device = deviceEnumerator.GetNext(); if ((device != null) && (device.get_Interface(HS) != null) && (device.get_Interface(HS).Trim() == PluginData.PlugInName)) { string address = device.get_Address(HS); if (address == parentAddress) { parentRefId = device.get_Ref(HS); } else if (address.StartsWith(parentAddress, StringComparison.Ordinal)) { DeviceData childDeviceData = GetDeviceData(device); if (childDeviceData != null) { currentChildDevices.Add(address, childDeviceData); } } } } while (!deviceEnumerator.Finished); }
private HSDevices GetCurrentDevices() { var deviceEnumerator = HS.GetDeviceEnumerator() as clsDeviceEnumeration; if (deviceEnumerator == null) { throw new HspiException(Invariant($"{PlugInData.PlugInName} failed to get a device enumerator from HomeSeer.")); } int?parentRefId = null; var currentChildDevices = new Dictionary <int, DeviceData>(); string parentAddress = DeviceIdentifier.CreateRootAddress(); do { DeviceClass device = deviceEnumerator.GetNext(); if ((device != null) && (device.get_Interface(HS) != null) && (device.get_Interface(HS).Trim() == PlugInData.PlugInName)) { string address = device.get_Address(HS); if (address == parentAddress) { parentRefId = device.get_Ref(HS); } else { var childDeviceData = DeviceIdentifier.Identify(device); if (childDeviceData != null) { if (importDevicesData.TryGetValue(childDeviceData.DeviceId, out var importDeviceData)) { device.set_Status_Support(HS, true); currentChildDevices.Add(device.get_Ref(HS), new NumberDeviceData(importDeviceData)); } } } } } while (!deviceEnumerator.Finished); return(new HSDevices() { ParentRefId = parentRefId, Children = currentChildDevices, }); }