mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
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:
parent
1bc2e6fc17
commit
5bfdc98217
@ -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 = "";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user