From 8991e0152665d949a93974adaae29fa7047d41e0 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 25 Feb 2019 12:46:45 +0100 Subject: [PATCH] Fix merging params for discovered devices with user overrides --- libnymea/devicemanager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libnymea/devicemanager.cpp b/libnymea/devicemanager.cpp index 77396492..21fcbf36 100644 --- a/libnymea/devicemanager.cpp +++ b/libnymea/devicemanager.cpp @@ -478,13 +478,13 @@ DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassI return DeviceErrorDeviceDescriptorNotFound; } - // Merge params. Use the ones from the descriptor unless overrides are provided in the function call + // Merge params from discovered descriptor and additional overrides provided on API call. User provided params have higher priority than discovery params. ParamList finalParams; - foreach (const Param ¶m, descriptor.params()) { - if (params.hasParam(param.paramTypeId())) { - finalParams.append(Param(param.paramTypeId(), params.paramValue(param.paramTypeId()))); - } else { - finalParams.append(param); + foreach (const ParamType ¶mType, deviceClass.paramTypes()) { + if (params.hasParam(paramType.id())) { + finalParams.append(Param(paramType.id(), params.paramValue(paramType.id()))); + } else if (descriptor.params().hasParam(paramType.id())) { + finalParams.append(Param(paramType.id(), descriptor.params().paramValue(paramType.id()))); } }