private DeviceData GetDeviceData(DeviceClass hsDevice) { var id = DeviceIdentifier.Identify(hsDevice); if (id == null) { return(null); } var device = GetDevice(id.Port, id.DeviceType); device.RefId = hsDevice.get_Ref(HS); return(device); }
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, }); }
private DeviceDataBase GetDeviceData(DeviceClass hsDevice) { var id = DeviceIdentifier.Identify(hsDevice); if (id == null) { return(null); } var device = GetDevice(id); if (device != null) { device.RefId = hsDevice.get_Ref(HS); } return(device); }