Alarm codes (#3566)

* Handle alarm codes from keyboard input

Closes https://github.com/home-assistant/home-assistant-polymer/issues/2602

* remove friendly_name changes

* remove unnecessary TS check
This commit is contained in:
Ian Richardson 2019-09-02 00:23:37 -05:00 committed by Paulus Schoutsen
parent 1bc2e6fc17
commit 5bfdc98217

View File

@ -21,6 +21,7 @@ import {
FORMAT_NUMBER, FORMAT_NUMBER,
} from "../../../data/alarm_control_panel"; } from "../../../data/alarm_control_panel";
import { AlarmPanelCardConfig } from "./types"; import { AlarmPanelCardConfig } from "./types";
import { PaperInputElement } from "@polymer/paper-input/paper-input";
const ICONS = { const ICONS = {
armed_away: "hass:shield-lock", armed_away: "hass:shield-lock",
@ -144,6 +145,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
? html`` ? html``
: html` : html`
<paper-input <paper-input
id="alarmCode"
label="Alarm Code" label="Alarm Code"
type="password" type="password"
.value="${this._code}" .value="${this._code}"
@ -198,11 +200,17 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
} }
private _handleActionClick(e: MouseEvent): void { private _handleActionClick(e: MouseEvent): void {
const input = this.shadowRoot!.querySelector(
"#alarmCode"
) as PaperInputElement;
const code =
this._code ||
(input && input.value && input.value.length > 0 ? input.value : "");
callAlarmAction( callAlarmAction(
this.hass!, this.hass!,
this._config!.entity, this._config!.entity,
(e.currentTarget! as any).action, (e.currentTarget! as any).action,
this._code! code
); );
this._code = ""; this._code = "";
} }