diff --git a/src/panels/config/helpers/forms/dialog-schedule-block-info.ts b/src/panels/config/helpers/forms/dialog-schedule-block-info.ts index 7063e57ab2..b4815eec10 100644 --- a/src/panels/config/helpers/forms/dialog-schedule-block-info.ts +++ b/src/panels/config/helpers/forms/dialog-schedule-block-info.ts @@ -1,5 +1,6 @@ import type { CSSResultGroup } from "lit"; import { html, LitElement, nothing } from "lit"; +import memoizeOne from "memoize-one"; import { property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import { createCloseHeading } from "../../../../components/ha-dialog"; @@ -13,19 +14,6 @@ import type { } from "./show-dialog-schedule-block-info"; import type { SchemaUnion } from "../../../../components/ha-form/types"; -const SCHEMA = [ - { - name: "from", - required: true, - selector: { time: { no_second: true } }, - }, - { - name: "to", - required: true, - selector: { time: { no_second: true } }, - }, -]; - class DialogScheduleBlockInfo extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; @@ -35,10 +23,39 @@ class DialogScheduleBlockInfo extends LitElement { @state() private _params?: ScheduleBlockInfoDialogParams; + private _expand = false; + + private _schema = memoizeOne((expand: boolean) => [ + { + name: "from", + required: true, + selector: { time: { no_second: true } }, + }, + { + name: "to", + required: true, + selector: { time: { no_second: true } }, + }, + { + name: "advanced_settings", + type: "expandable" as const, + flatten: true, + expanded: expand, + schema: [ + { + name: "data", + required: false, + selector: { object: {} }, + }, + ], + }, + ]); + public showDialog(params: ScheduleBlockInfoDialogParams): void { this._params = params; this._error = undefined; this._data = params.block; + this._expand = !!params.block?.data; } public closeDialog(): void { @@ -66,7 +83,7 @@ class DialogScheduleBlockInfo extends LitElement {