import { LitElement, html, TemplateResult, CSSResult, css, property, PropertyValues, customElement, } from "lit-element"; import "@material/mwc-button"; import { HomeAssistant } from "../../../types"; import { TimerEntity } from "../../../data/timer"; @customElement("more-info-timer") class MoreInfoTimer extends LitElement { @property() public hass!: HomeAssistant; @property() public stateObj?: TimerEntity; protected render(): TemplateResult | void { if (!this.hass || !this.stateObj) { return html``; } return html`
${this.stateObj.state === "idle" || this.stateObj.state === "paused" ? html` ${this.hass!.localize("ui.card.timer.actions.start")} ` : ""} ${this.stateObj.state === "active" ? html` ${this.hass!.localize("ui.card.timer.actions.pause")} ` : ""} ${this.stateObj.state === "active" || this.stateObj.state === "paused" ? html` ${this.hass!.localize("ui.card.timer.actions.cancel")} ${this.hass!.localize("ui.card.timer.actions.finish")} ` : ""}
`; } protected updated(changedProps: PropertyValues) { super.updated(changedProps); if (!changedProps.has("stateObj") || !this.stateObj) { return; } } private _handleActionClick(e: MouseEvent): void { const action = (e.currentTarget as any).action; this.hass.callService("timer", action, { entity_id: this.stateObj!.entity_id, }); } static get styles(): CSSResult { return css` .actions { margin: 0 8px; padding-top: 20px; display: flex; flex-wrap: wrap; justify-content: center; } `; } } declare global { interface HTMLElementTagNameMap { "more-info-timer": MoreInfoTimer; } }