From b47ee1051c7de775b7e67023eac46eca7af702b0 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Sat, 7 Dec 2019 20:46:04 +0100 Subject: [PATCH] Fix thingtalk automations creation (#4328) --- src/panels/config/automation/thingtalk/dialog-thingtalk.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/panels/config/automation/thingtalk/dialog-thingtalk.ts b/src/panels/config/automation/thingtalk/dialog-thingtalk.ts index 09fa45a7f1..9aa87d029d 100644 --- a/src/panels/config/automation/thingtalk/dialog-thingtalk.ts +++ b/src/panels/config/automation/thingtalk/dialog-thingtalk.ts @@ -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);