/// <summary> /// Initializes a new instance of the <see cref="PluginConfig"/> class. /// </summary> /// <param name="HS">The homeseer application.</param> public PluginConfig(IHSApplication HS) { this.HS = HS; debugLogging = GetValue(DebugLoggingKey, false); string deviceIdsConcatString = GetValue(DeviceIds, string.Empty); var deviceIds = deviceIdsConcatString.Split(DeviceIdsSeparator); foreach (var deviceId in deviceIds) { if (string.IsNullOrWhiteSpace(deviceId)) { continue; } string ipAddressString = GetValue(IPAddressKey, string.Empty, deviceId); if (!IPAddress.TryParse(ipAddressString, out var deviceIP)) { deviceIP = IPAddress.None; } string name = GetValue(NameKey, string.Empty, deviceId); string username = GetValue(UserNameKey, string.Empty, deviceId); string passwordEncrypted = GetValue(PasswordKey, string.Empty, deviceId); string password = HS.DecryptString(passwordEncrypted, EncryptPassword); devices.Add(deviceId, new AirVisualNode(deviceId, name, deviceIP, username, password)); } }
/// <summary> /// Initializes a new instance of the <see cref="PluginConfig"/> class. /// </summary> /// <param name="HS">The homeseer application.</param> public PluginConfig(IHSApplication HS) { this.HS = HS; debugLogging = GetValue(DebugLoggingKey, false); string deviceIdsConcatString = GetValue(DeviceIds, string.Empty); var deviceIds = deviceIdsConcatString.Split(DeviceIdsSeparator); foreach (var deviceId in deviceIds) { if (string.IsNullOrWhiteSpace(deviceId)) { continue; } string ipAddressString = GetValue(IPAddressKey, string.Empty, deviceId); IPAddress.TryParse(ipAddressString, out var deviceIP); var resolution = new Dictionary <DeviceType, double>(); foreach (var item in System.Enum.GetValues(typeof(DeviceType))) { DeviceType deviceType = (DeviceType)item; resolution.Add(deviceType, GetValue(ResolutionKey(deviceType), GetDefaultResolution(deviceType), deviceId)); } string enabledPortsString = GetValue(PortsEnabledKey, string.Empty, deviceId); var enabledPorts = new SortedSet <int>(); foreach (var portString in enabledPortsString.Split(PortsEnabledSeparator)) { if (int.TryParse(portString, NumberStyles.Any, CultureInfo.InvariantCulture, out var port)) { enabledPorts.Add(port); } } var enabledTypes = new SortedSet <DeviceType>(); foreach (var item in System.Enum.GetValues(typeof(DeviceType))) { if (GetValue(item.ToString(), false, deviceId)) { enabledTypes.Add((DeviceType)item); } } string name = GetValue(NameKey, string.Empty, deviceId); string username = GetValue(UserNameKey, string.Empty, deviceId); string passwordEncrypted = GetValue(PasswordKey, string.Empty, deviceId); string password = HS.DecryptString(passwordEncrypted, EncryptPassword); devices.Add(deviceId, new MPowerDevice(deviceId, name, deviceIP, username, password, enabledTypes, resolution, enabledPorts)); } }