Fix condition time (#11866)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Zack Barett <zackbarett@hey.com>
This commit is contained in:
Bram Kragten 2022-02-26 22:18:33 +01:00 committed by GitHub
parent 298296a81f
commit 7abf9c2473
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,8 +117,8 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
); );
const data = { const data = {
mode_before: "value", mode_before: inputModeBefore ? "input" : "value",
mode_after: "value", mode_after: inputModeAfter ? "input" : "value",
...this.condition, ...this.condition,
}; };
@ -137,18 +137,11 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value; const newValue = ev.detail.value;
const newModeAfter = newValue.mode_after === "input"; this._inputModeAfter = newValue.mode_after === "input";
const newModeBefore = newValue.mode_before === "input"; this._inputModeBefore = newValue.mode_before === "input";
if (newModeAfter !== this._inputModeAfter) { delete newValue.mode_after;
this._inputModeAfter = newModeAfter; delete newValue.mode_before;
newValue.after = undefined;
}
if (newModeBefore !== this._inputModeBefore) {
this._inputModeBefore = newModeBefore;
newValue.before = undefined;
}
Object.keys(newValue).forEach((key) => Object.keys(newValue).forEach((key) =>
newValue[key] === undefined || newValue[key] === "" newValue[key] === undefined || newValue[key] === ""