mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
Unified alarm panel icons everywhere (#10021)
This commit is contained in:
parent
0adc4b33ef
commit
9c1153ef37
24
src/common/entity/alarm_panel_icon.ts
Normal file
24
src/common/entity/alarm_panel_icon.ts
Normal file
@ -0,0 +1,24 @@
|
||||
/** Return an icon representing a alarm panel state. */
|
||||
|
||||
export const alarmPanelIcon = (state?: string) => {
|
||||
switch (state) {
|
||||
case "armed_away":
|
||||
return "hass:shield-lock";
|
||||
case "armed_vacation":
|
||||
return "hass:shield-airplane";
|
||||
case "armed_home":
|
||||
return "hass:shield-home";
|
||||
case "armed_night":
|
||||
return "hass:shield-moon";
|
||||
case "armed_custom_bypass":
|
||||
return "hass:security";
|
||||
case "pending":
|
||||
return "hass:shield-outline";
|
||||
case "triggered":
|
||||
return "hass:bell-ring";
|
||||
case "disarmed":
|
||||
return "hass:shield-off";
|
||||
default:
|
||||
return "hass:shield";
|
||||
}
|
||||
};
|
@ -5,6 +5,7 @@ import { HassEntity } from "home-assistant-js-websocket";
|
||||
* Optionally pass in a state to influence the domain icon.
|
||||
*/
|
||||
import { DEFAULT_DOMAIN_ICON, FIXED_DOMAIN_ICONS } from "../const";
|
||||
import { alarmPanelIcon } from "./alarm_panel_icon";
|
||||
import { binarySensorIcon } from "./binary_sensor_icon";
|
||||
import { coverIcon } from "./cover_icon";
|
||||
import { sensorIcon } from "./sensor_icon";
|
||||
@ -18,18 +19,7 @@ export const domainIcon = (
|
||||
|
||||
switch (domain) {
|
||||
case "alarm_control_panel":
|
||||
switch (compareState) {
|
||||
case "armed_home":
|
||||
return "hass:bell-plus";
|
||||
case "armed_night":
|
||||
return "hass:bell-sleep";
|
||||
case "disarmed":
|
||||
return "hass:bell-outline";
|
||||
case "triggered":
|
||||
return "hass:bell-ring";
|
||||
default:
|
||||
return "hass:bell";
|
||||
}
|
||||
return alarmPanelIcon(compareState);
|
||||
|
||||
case "binary_sensor":
|
||||
return binarySensorIcon(compareState, stateObj);
|
||||
|
@ -13,7 +13,6 @@ import secondsToDuration from "../../common/datetime/seconds_to_duration";
|
||||
import { computeStateDisplay } from "../../common/entity/compute_state_display";
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import { domainIcon } from "../../common/entity/domain_icon";
|
||||
import { stateIcon } from "../../common/entity/state_icon";
|
||||
import { timerTimeRemaining } from "../../data/timer";
|
||||
import { formatNumber } from "../../common/string/format_number";
|
||||
@ -141,26 +140,6 @@ export class HaStateLabelBadge extends LitElement {
|
||||
}
|
||||
switch (domain) {
|
||||
case "alarm_control_panel":
|
||||
if (entityState.state === "pending") {
|
||||
return "hass:clock-fast";
|
||||
}
|
||||
if (entityState.state === "armed_away") {
|
||||
return "hass:nature";
|
||||
}
|
||||
if (entityState.state === "armed_home") {
|
||||
return "hass:home-variant";
|
||||
}
|
||||
if (entityState.state === "armed_night") {
|
||||
return "hass:weather-night";
|
||||
}
|
||||
if (entityState.state === "armed_custom_bypass") {
|
||||
return "hass:shield-home";
|
||||
}
|
||||
if (entityState.state === "triggered") {
|
||||
return "hass:alert-circle";
|
||||
}
|
||||
// state == 'disarmed'
|
||||
return domainIcon(domain, entityState);
|
||||
case "binary_sensor":
|
||||
case "device_tracker":
|
||||
case "updater":
|
||||
|
@ -12,6 +12,7 @@ import { customElement, property, state, query } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
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 "../../../components/ha-card";
|
||||
import "../../../components/ha-label-badge";
|
||||
import {
|
||||
@ -24,17 +25,6 @@ import { createEntityNotFoundWarning } from "../components/hui-warning";
|
||||
import type { LovelaceCard } from "../types";
|
||||
import { AlarmPanelCardConfig } from "./types";
|
||||
|
||||
const ICONS = {
|
||||
armed_away: "hass:shield-lock",
|
||||
armed_custom_bypass: "hass:security",
|
||||
armed_home: "hass:shield-home",
|
||||
armed_night: "hass:shield-moon",
|
||||
armed_vacation: "hass:shield-lock",
|
||||
disarmed: "hass:shield-check",
|
||||
pending: "hass:shield-outline",
|
||||
triggered: "hass:bell-ring",
|
||||
};
|
||||
|
||||
const BUTTONS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "", "0", "clear"];
|
||||
|
||||
@customElement("hui-alarm-panel-card")
|
||||
@ -162,7 +152,7 @@ class HuiAlarmPanelCard extends LitElement implements LovelaceCard {
|
||||
>
|
||||
<ha-label-badge
|
||||
class="${classMap({ [stateObj.state]: true })}"
|
||||
.icon="${ICONS[stateObj.state] || "hass:shield-outline"}"
|
||||
.icon="${alarmPanelIcon(stateObj.state)}"
|
||||
.label="${this._stateIconLabel(stateObj.state)}"
|
||||
@click=${this._handleMoreInfo}
|
||||
></ha-label-badge>
|
||||
|
Loading…
x
Reference in New Issue
Block a user