Fix alarm panel (#5291)

Fixes https://github.com/home-assistant/frontend/issues/5073
This commit is contained in:
Bram Kragten 2020-03-20 15:21:25 +01:00 committed by GitHub
parent 0d404e0e37
commit 685a0807d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -12,9 +12,9 @@ export const callAlarmAction = (
| "arm_night"
| "arm_custom_bypass"
| "disarm",
code: string
code?: string
) => {
hass!.callService("alarm_control_panel", "alarm_" + action, {
hass!.callService("alarm_control_panel", `alarm_${action}`, {
entity_id: entity,
code,
});

View File

@ -248,17 +248,17 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
}
private _handleActionClick(e: MouseEvent): void {
const input = this._input!;
const code =
input && input.value && input.value.length > 0 ? input.value : "";
const input = this._input;
callAlarmAction(
this.hass!,
this._config!.entity,
(e.currentTarget! as any).action,
code
input?.value || undefined
);
if (input) {
input.value = "";
}
}
private _handleMoreInfo() {
fireEvent(this, "hass-more-info", {