private NameValueCollection GetCurrentDeviceImportDevices() { HSHelper hsHelper = new HSHelper(HS); var deviceEnumerator = HS.GetDeviceEnumerator() as clsDeviceEnumeration; var currentDevices = new NameValueCollection(); var importDevicesData = pluginConfig.ImportDevicesData; 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); var childDeviceData = DeviceIdentifier.Identify(device); if (childDeviceData != null) { if (pluginConfig.ImportDevicesData.TryGetValue(childDeviceData.DeviceId, out var importDeviceData)) { currentDevices.Add(device.get_Ref(HS).ToString(CultureInfo.CurrentCulture), hsHelper.GetName(device)); } } } } while (!deviceEnumerator.Finished); return(currentDevices); }
/// <summary> /// Gets the current devices for plugin from Homeseer /// </summary> /// <returns>Current devices for plugin</returns> /// <exception cref="HspiException"></exception> private IDictionary <string, DeviceClass> GetCurrentDevices() { var deviceEnumerator = HS.GetDeviceEnumerator() as clsDeviceEnumeration; if (deviceEnumerator == null) { throw new HspiException(Invariant($"{Name} failed to get a device enumerator from HomeSeer.")); } var currentDevices = new Dictionary <string, DeviceClass>(); do { CancellationToken.ThrowIfCancellationRequested(); DeviceClass device = deviceEnumerator.GetNext(); if ((device != null) && (device.get_Interface(HS) != null) && (device.get_Interface(HS).Trim() == Name)) { string address = device.get_Address(HS); currentDevices.Add(address, device); } } while (!deviceEnumerator.Finished); return(currentDevices); }
private void GetCurrentDevices() { if (!(HS.GetDeviceEnumerator() is clsDeviceEnumeration deviceEnumerator)) { throw new HspiException(Invariant($"{PluginData.PlugInName} failed to get a device enumerator from HomeSeer.")); } string baseAddress = DeviceIdentifier.CreateDeviceIdSpecficAddress(CameraSettings.Id); do { DeviceClass device = deviceEnumerator.GetNext(); if ((device != null) && (device.get_Interface(HS) != null) && string.Equals(device.get_Interface(HS).Trim(), PluginData.PlugInName, StringComparison.Ordinal)) { string address = device.get_Address(HS); if (address.StartsWith(baseAddress, StringComparison.Ordinal)) { var deviceData = GetDeviceData(device); if (deviceData != null) { devices.Add(address, deviceData); deviceData.OnPlugInLoad(HS, CameraSettings); if (deviceData.IsRootDevice) { parentRefId = device.get_Ref(HS); } } } } } while (!deviceEnumerator.Finished); }
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); }
public IDictionary <int, string> GetDevices() { Dictionary <int, string> devices = new Dictionary <int, string>(); var deviceEnumerator = HS.GetDeviceEnumerator() as clsDeviceEnumeration; do { DeviceClass device = deviceEnumerator.GetNext(); if (device != null) { devices.Add(device.get_Ref(HS), GetName(device)); } }while (!deviceEnumerator.Finished); return(devices); }
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 async Task RecordTrackedDevices() { var collector = await GetInfluxDBMeasurementsCollector().ConfigureAwait(false); if (collector != null) { var deviceEnumerator = HS.GetDeviceEnumerator() as clsDeviceEnumeration; do { DeviceClass device = deviceEnumerator.GetNext(); if (device != null) { if (collector.IsTracked(device.get_Ref(HS), null)) { await RecordDeviceValue(collector, HS, device).ConfigureAwait(false); } } ShutdownCancellationToken.ThrowIfCancellationRequested(); }while (!deviceEnumerator.Finished); } }