+ _getConfigurationKey(key) {
+ return this._configuration.configurationKey.find((configElement) => configElement.key === key);
+ }
+
+ _addConfigurationKey(key, value, readonly = false, visible = true, reboot = false) {
+ const keyFound = this._getConfigurationKey(key);
+ if (!keyFound) {
+ this._configuration.configurationKey.push({
+ key,
+ readonly,
+ value,
+ visible,
+ reboot,
+ });
+ }
+ }
+
+ _setConfigurationKeyValue(key, value) {
+ const keyFound = this._getConfigurationKey(key);
+ if (keyFound) {
+ const keyIndex = this._configuration.configurationKey.indexOf(keyFound);
+ this._configuration.configurationKey[keyIndex].value = value;
+ }
+ }
+
+ async handleGetConfiguration(commandPayload) {
+ const configurationKey = [];
+ const unknownKey = [];
+ if (Utils.isEmptyArray(commandPayload.key)) {
+ for (const configuration of this._configuration.configurationKey) {
+ if (Utils.isUndefined(configuration.visible)) {
+ configuration.visible = true;
+ } else {
+ configuration.visible = Utils.convertToBoolean(configuration.visible);
+ }
+ if (!configuration.visible) {
+ continue;
+ }
+ configurationKey.push({
+ key: configuration.key,
+ readonly: configuration.readonly,
+ value: configuration.value,
+ });
+ }
+ } else {
+ for (const configurationKey of commandPayload.key) {
+ const keyFound = this._getConfigurationKey(configurationKey);
+ if (keyFound) {
+ if (Utils.isUndefined(keyFound.visible)) {
+ keyFound.visible = true;
+ } else {
+ keyFound.visible = Utils.convertToBoolean(configurationKey.visible);
+ }
+ if (!keyFound.visible) {
+ continue;
+ }
+ configurationKey.push({
+ key: keyFound.key,
+ readonly: keyFound.readonly,
+ value: keyFound.value,
+ });
+ } else {
+ unknownKey.push(configurationKey);
+ }
+ }
+ }
+ return {
+ configurationKey,
+ unknownKey,
+ };