diff --git a/src/data/timer.ts b/src/data/timer.ts index cff601b60a..4631454e12 100644 --- a/src/data/timer.ts +++ b/src/data/timer.ts @@ -12,6 +12,7 @@ export type TimerEntity = HassEntityBase & { attributes: HassEntityAttributeBase & { duration: string; remaining: string; + restore: boolean; }; }; @@ -26,12 +27,14 @@ export interface Timer { name: string; icon?: string; duration?: string | number | DurationDict; + restore?: boolean; } export interface TimerMutableParams { name: string; icon: string; duration: string | number | DurationDict; + restore: boolean; } export const fetchTimer = (hass: HomeAssistant) => diff --git a/src/dialogs/more-info/controls/more-info-timer.ts b/src/dialogs/more-info/controls/more-info-timer.ts index 55dbe3168a..63be3032f9 100644 --- a/src/dialogs/more-info/controls/more-info-timer.ts +++ b/src/dialogs/more-info/controls/more-info-timer.ts @@ -46,7 +46,7 @@ class MoreInfoTimer extends LitElement { `; } diff --git a/src/panels/config/helpers/forms/ha-timer-form.ts b/src/panels/config/helpers/forms/ha-timer-form.ts index 5d7b13cfad..5aef7ca212 100644 --- a/src/panels/config/helpers/forms/ha-timer-form.ts +++ b/src/panels/config/helpers/forms/ha-timer-form.ts @@ -21,16 +21,20 @@ class HaTimerForm extends LitElement { @state() private _duration!: string | number | DurationDict; + @state() private _restore!: boolean; + set item(item: Timer) { this._item = item; if (item) { this._name = item.name || ""; this._icon = item.icon || ""; this._duration = item.duration || "00:00:00"; + this._restore = item.restore || false; } else { this._name = ""; this._icon = ""; this._duration = "00:00:00"; + this._restore = false; } } @@ -79,6 +83,18 @@ class HaTimerForm extends LitElement { "ui.dialogs.helper_settings.timer.duration" )} > + + + + `; } @@ -104,6 +120,13 @@ class HaTimerForm extends LitElement { }); } + private _toggleRestore() { + this._restore = !this._restore; + fireEvent(this, "value-changed", { + value: { ...this._item, restore: this._restore }, + }); + } + static get styles(): CSSResultGroup { return [ haStyle, diff --git a/src/translations/en.json b/src/translations/en.json index 3d48b16f2c..2d05c998e8 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -900,7 +900,8 @@ "step": "Step size" }, "timer": { - "duration": "Duration" + "duration": "Duration", + "restore": "Restore?" } }, "options_flow": {