Fix time trigger (#11841)

This commit is contained in:
Bram Kragten 2022-02-24 21:36:18 +01:00 committed by GitHub
parent 48355aa98e
commit 151f8d5524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,9 +23,9 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
private _schema = memoizeOne( private _schema = memoizeOne(
(localize: LocalizeFunc, inputMode?: boolean): HaFormSchema[] => { (localize: LocalizeFunc, inputMode?: boolean): HaFormSchema[] => {
const modeSchema = inputMode const atSelector = inputMode
? { name: "at", selector: { entity: { domain: "input_datetime" } } } ? { entity: { domain: "input_datetime" } }
: { name: "at", selector: { time: {} } }; : { time: {} };
return [ return [
{ {
@ -47,7 +47,7 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
], ],
], ],
}, },
modeSchema, { name: "at", selector: atSelector },
]; ];
} }
); );
@ -80,7 +80,7 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
const schema: HaFormSchema[] = this._schema(this.hass.localize, inputMode); const schema: HaFormSchema[] = this._schema(this.hass.localize, inputMode);
const data = { const data = {
mode: "value", mode: inputMode ? "input" : "value",
...this.trigger, ...this.trigger,
}; };
@ -99,7 +99,8 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value; const newValue = ev.detail.value;
this._inputMode = newValue.mode.value === "input"; this._inputMode = newValue.mode === "input";
delete newValue.mode;
Object.keys(newValue).forEach((key) => Object.keys(newValue).forEach((key) =>
newValue[key] === undefined || newValue[key] === "" newValue[key] === undefined || newValue[key] === ""