Skip to content

Commit

Permalink
feat(alarm): feat option to show keypad
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Apr 21, 2022
1 parent 750148b commit ab2e11e
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface AlarmControlPanelCardConfig extends LovelaceCardConfig {
icon?: string;
name?: string;
states?: string[];
show_keypad?: boolean;
layout?: Layout;
hide_state?: boolean;
tap_action?: ActionConfig;
Expand All @@ -23,6 +24,7 @@ export const alarmControlPanelCardCardConfigStruct = assign(
name: optional(string()),
icon: optional(string()),
states: optional(array()),
show_keypad: optional(boolean()),
layout: optional(layoutStruct),
hide_state: optional(boolean()),
tap_action: optional(actionConfigStruct),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const actions: Action[] = ["more-info", "navigate", "url", "call-service", "none

const states = ["armed_home", "armed_away", "armed_night", "armed_vacation", "armed_custom_bypass"];

const ALARM_CONTROL_PANEL_FIELDS = ["show_keypad"];

const computeSchema = memoizeOne((localize: LocalizeFunc, icon?: string): HaFormSchema[] => [
{ name: "entity", selector: { entity: { domain: ALARM_CONTROl_PANEL_ENTITY_DOMAINS } } },
{ name: "name", selector: { text: {} } },
Expand All @@ -44,6 +46,7 @@ const computeSchema = memoizeOne((localize: LocalizeFunc, icon?: string): HaForm
localize(`ui.card.alarm_control_panel.${state.replace("armed", "arm")}`),
]) as [string, string][],
},
{ name: "show_keypad", selector: { boolean: {} } },
{ name: "tap_action", selector: { "mush-action": { actions } } },
{ name: "hold_action", selector: { "mush-action": { actions } } },
{ name: "double_tap_action", selector: { "mush-action": { actions } } },
Expand Down Expand Up @@ -92,7 +95,9 @@ export class SwitchCardEditor extends LitElement implements LovelaceCardEditor {
if (GENERIC_FIELDS.includes(schema.name)) {
return customLocalize(`editor.card.generic.${schema.name}`);
}

if (ALARM_CONTROL_PANEL_FIELDS.includes(schema.name)) {
return customLocalize(`editor.card.alarm_control_panel.${schema.name}`);
}
if (schema.name === "states") {
return this.hass!.localize(
"ui.panel.lovelace.editor.card.alarm-panel.available_states"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class AlarmControlPanelCard extends LitElement implements LovelaceCard {
const entity_id = this._config?.entity;
if (entity_id) {
const entity = this.hass.states[entity_id];
return hasCode(entity);
return hasCode(entity) && (this._config?.show_keypad ?? false);
}
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "Schaltflächensteuerung?",
"show_position_control": "Positionssteuerung?"
},
"alarm_control_panel": {
"displayed_states": "Angezeigte Zustände"
},
"template": {
"primary": "Primäre Information",
"secondary": "Sekundäre Information",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "Έλεγχος κουμπιών;",
"show_position_control": "Έλεγχος θέσης;"
},
"alarm_control_panel": {
"displayed_states": "Εμφανιζόμενες καταστάσεις"
},
"template": {
"primary": "Πρωτεύουσες πληροφορίες",
"secondary": "Δευτερεύουσες πληροφορίες",
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"show_position_control": "Position control?"
},
"alarm_control_panel": {
"displayed_states": "Displayed states"
"show_keypad": "Show keypad"
},
"template": {
"primary": "Primary information",
Expand Down
2 changes: 1 addition & 1 deletion src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"show_position_control": "Contrôle de la position ?"
},
"alarm_control_panel": {
"displayed_states": "États affichés"
"show_keypad": "Afficher le clavier"
},
"template": {
"primary": "Information principale",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "Pulsanti di controllo",
"show_position_control": "Controllo percentuale apertura"
},
"alarm_control_panel": {
"displayed_states": "Mostra stati"
},
"template": {
"primary": "Informazione primaria",
"secondary": "Informazione secondaria",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "Kontollere med knapper?",
"show_position_control": "Posisjonskontroll?"
},
"alarm_control_panel": {
"displayed_states": "Viste tilstander"
},
"template": {
"primary": "Primærinformasjon",
"secondary": "Sekundærinformasjon",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "Bediening middels knoppen",
"show_position_control": "Bediening middels positie"
},
"alarm_control_panel": {
"displayed_states": "Weergegeven staten"
},
"template": {
"primary": "Primaire informatie",
"secondary": "Secundaire informatie",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
"show_buttons_control": "Mostrar botões?",
"show_position_control": "Mostrar controle de posição?"
},
"alarm_control_panel": {
"displayed_states": "Estados exibidos"
},
"template": {
"primary": "Informações primárias",
"secondary": "Informações secundárias",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
"show_buttons_control": "Visa kontrollknappar?",
"show_position_control": "Visa positionskontroll?"
},
"alarm_control_panel": {
"displayed_states": "Status som visas"
},
"template": {
"primary": "Primär information",
"secondary": "Sekundär information",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "Düğme kontrolleri",
"show_position_control": "Pozisyon kontrolü"
},
"alarm_control_panel": {
"displayed_states": "Görüntülenen durum"
},
"template": {
"primary": "Birinci bilgi",
"secondary": "İkinci bilgi",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
"show_buttons_control": "按钮控制?",
"show_position_control": "位置控制?"
},
"alarm_control_panel": {
"displayed_states": "显示的状态"
},
"template": {
"primary": "首要信息",
"secondary": "次要信息",
Expand Down
3 changes: 0 additions & 3 deletions src/translations/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
"show_buttons_control": "按鈕控制?",
"show_position_control": "位置控制?"
},
"alarm_control_panel": {
"displayed_states": "顯示的狀態"
},
"template": {
"primary": "主要訊息",
"secondary": "次要訊息",
Expand Down

0 comments on commit ab2e11e

Please sign in to comment.