Skip to content

Commit

Permalink
Use assist chip in alarm control panel card
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Nov 9, 2023
1 parent 145e999 commit 7908404
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/panels/lovelace/cards/hui-alarm-panel-card.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { HassEntity } from "home-assistant-js-websocket";
import {
css,
CSSResultGroup,
html,
LitElement,
PropertyValues,
css,
html,
nothing,
} from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { styleMap } from "lit/directives/style-map";
import { HassEntity } from "home-assistant-js-websocket";
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
import { fireEvent } from "../../../common/dom/fire_event";
import { alarmPanelIcon } from "../../../common/entity/alarm_panel_icon";
import { stateColorCss } from "../../../common/entity/state_color";
import { supportsFeature } from "../../../common/entity/supports-feature";
import "../../../components/chips/ha-assist-chip";
import "../../../components/ha-card";
import "../../../components/ha-chip";
import "../../../components/ha-textfield";
import type { HaTextField } from "../../../components/ha-textfield";
import {
callAlarmAction,
FORMAT_NUMBER,
ALARM_MODES,
AlarmMode,
FORMAT_NUMBER,
callAlarmAction,
} from "../../../data/alarm_control_panel";
import { UNAVAILABLE } from "../../../data/entity";
import type { HomeAssistant } from "../../../types";
import { findEntities } from "../common/find-entities";
import { createEntityNotFoundWarning } from "../components/hui-warning";
import type { LovelaceCard } from "../types";
import { AlarmPanelCardConfig, AlarmPanelCardConfigState } from "./types";
import { supportsFeature } from "../../../common/entity/supports-feature";

const BUTTONS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "", "0", "clear"];

Expand Down Expand Up @@ -190,18 +190,18 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
${this._config.name ||
stateObj.attributes.friendly_name ||
stateLabel}
<ha-chip
hasIcon
<ha-assist-chip
filled
style=${styleMap({
"--alarm-state-color": stateColorCss(stateObj),
})}
class=${classMap({ [stateObj.state]: true })}
@click=${this._handleMoreInfo}
.label=${stateLabel}
>
<ha-svg-icon slot="icon" .path=${alarmPanelIcon(stateObj.state)}>
</ha-svg-icon>
${stateLabel}
</ha-chip>
</ha-assist-chip>
</h1>
<div id="armActions" class="actions">
${(stateObj.state === "disarmed"
Expand Down Expand Up @@ -312,10 +312,9 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
--alarm-state-color: var(--state-inactive-color);
}
ha-chip {
--ha-chip-background-color: var(--alarm-state-color);
ha-assist-chip {
--ha-assist-chip-filled-container-color: var(--alarm-state-color);
--primary-text-color: var(--text-primary-color);
line-height: initial;
}
.card-header {
Expand Down

0 comments on commit 7908404

Please sign in to comment.