mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
Add support for new timer properties (#11940)
This commit is contained in:
parent
e263b57296
commit
ac670614b4
@ -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) =>
|
||||
|
@ -46,7 +46,7 @@ class MoreInfoTimer extends LitElement {
|
||||
<ha-attributes
|
||||
.hass=${this.hass}
|
||||
.stateObj=${this.stateObj}
|
||||
extra-filters="remaining"
|
||||
extra-filters="remaining,restore"
|
||||
></ha-attributes>
|
||||
`;
|
||||
}
|
||||
|
@ -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"
|
||||
)}
|
||||
></ha-textfield>
|
||||
<ha-formfield
|
||||
.label=${this.hass.localize(
|
||||
"ui.dialogs.helper_settings.timer.restore"
|
||||
)}
|
||||
>
|
||||
<ha-checkbox
|
||||
.configValue=${"restore"}
|
||||
.checked=${this._restore}
|
||||
@click=${this._toggleRestore}
|
||||
>
|
||||
</ha-checkbox>
|
||||
</ha-formfield>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -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,
|
||||
|
@ -900,7 +900,8 @@
|
||||
"step": "Step size"
|
||||
},
|
||||
"timer": {
|
||||
"duration": "Duration"
|
||||
"duration": "Duration",
|
||||
"restore": "Restore?"
|
||||
}
|
||||
},
|
||||
"options_flow": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user