diff --git a/src/dialogs/more-info/controls/more-info-automation.js b/src/dialogs/more-info/controls/more-info-automation.js deleted file mode 100644 index d766184ee1..0000000000 --- a/src/dialogs/more-info/controls/more-info-automation.js +++ /dev/null @@ -1,53 +0,0 @@ -import "@material/mwc-button"; -import { html } from "@polymer/polymer/lib/utils/html-tag"; -import { PolymerElement } from "@polymer/polymer/polymer-element"; - -import "../../../components/ha-relative-time"; - -import LocalizeMixin from "../../../mixins/localize-mixin"; - -class MoreInfoAutomation extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - - -
-
[[localize('ui.card.automation.last_triggered')]]:
- -
- -
- - [[localize('ui.card.automation.trigger')]] - -
- `; - } - - static get properties() { - return { - hass: Object, - stateObj: Object, - }; - } - - handleTriggerTapped() { - this.hass.callService("automation", "trigger", { - entity_id: this.stateObj.entity_id, - }); - } -} - -customElements.define("more-info-automation", MoreInfoAutomation); diff --git a/src/dialogs/more-info/controls/more-info-automation.ts b/src/dialogs/more-info/controls/more-info-automation.ts new file mode 100644 index 0000000000..c73ac9c5b0 --- /dev/null +++ b/src/dialogs/more-info/controls/more-info-automation.ts @@ -0,0 +1,68 @@ +import { + LitElement, + html, + TemplateResult, + CSSResult, + css, + property, + customElement, +} from "lit-element"; +import { HassEntity } from "home-assistant-js-websocket"; +import "@material/mwc-button"; + +import "../../../components/ha-relative-time"; + +import { HomeAssistant } from "../../../types"; + +@customElement("more-info-automation") +class MoreInfoAutomation extends LitElement { + @property() public hass!: HomeAssistant; + @property() public stateObj?: HassEntity; + + protected render(): TemplateResult | void { + if (!this.hass || !this.stateObj) { + return html``; + } + + return html` +
+
${this.hass.localize("ui.card.automation.last_triggered")}:
+ +
+ +
+ + ${this.hass.localize("ui.card.automation.trigger")} + +
+ `; + } + + private handleAction() { + this.hass.callService("automation", "trigger", { + entity_id: this.stateObj!.entity_id, + }); + } + + static get styles(): CSSResult { + return css` + .flex { + display: flex; + justify-content: space-between; + } + .actions { + margin: 36px 0 8px 0; + text-align: right; + } + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "more-info-automation": MoreInfoAutomation; + } +}