Don't assume position of items in array (#7927)

This commit is contained in:
Tim McCormick 2021-01-26 21:59:58 +00:00 committed by GitHub
parent 9d289bfa34
commit 9988227d93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,11 +128,19 @@ class ZwaveNodeProtection extends LocalizeMixin(PolymerElement) {
if (this.protection.length === 0) {
return;
}
let options = [];
let value_id = -1;
let selected = -1;
this.protection.forEach(function (item) {
if (item.key === "options") options = item.value;
else if (item.key === "value_id") value_id = item.value;
else if (item.key === "selected") selected = item.value;
});
this.setProperties({
protectionNode: true,
_protectionOptions: this.protection[0].value,
_loadedProtectionValue: this.protection[1].value,
_protectionValueID: this.protection[2].value,
_protectionOptions: options,
_loadedProtectionValue: selected,
_protectionValueID: value_id,
});
}
}