Fix thingtalk automations creation (#4328)

This commit is contained in:
Bram Kragten 2019-12-07 20:46:04 +01:00 committed by Paulus Schoutsen
parent 393adacc9e
commit b47ee1051c

View File

@ -182,18 +182,19 @@ class DialogThingtalk extends LitElement {
if (devices.length === 1) {
Object.entries(devices[0]).forEach(([field, value]) => {
this._config[type][index][field] = value;
return;
});
return;
}
const automation = { ...this._config[type][index] };
delete this._config[type][index];
const newAutomations: any[] = [];
devices.forEach((fields) => {
const newAutomation = { ...automation };
Object.entries(fields).forEach(([field, value]) => {
newAutomation[field] = value;
});
this._config[type].push(newAutomation);
newAutomations.push(newAutomation);
});
this._config[type].splice(index, 1, ...newAutomations);
});
});
this._sendConfig(this._value, this._config);