mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add unavailable badge for tile card (#14582)
add unavailable badge for tile card
This commit is contained in:
parent
228fd4b7fe
commit
d622d9d420
@ -1,6 +1,7 @@
|
|||||||
|
import { mdiExclamationThick } from "@mdi/js";
|
||||||
import { HassEntity } from "home-assistant-js-websocket";
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
import { computeDomain } from "../../../../../common/entity/compute_domain";
|
import { computeDomain } from "../../../../../common/entity/compute_domain";
|
||||||
import { UNAVAILABLE_STATES } from "../../../../../data/entity";
|
import { UNAVAILABLE, UNKNOWN } from "../../../../../data/entity";
|
||||||
import { HomeAssistant } from "../../../../../types";
|
import { HomeAssistant } from "../../../../../types";
|
||||||
import { computeClimateBadge } from "./tile-badge-climate";
|
import { computeClimateBadge } from "./tile-badge-climate";
|
||||||
import { computePersonBadge } from "./tile-badge-person";
|
import { computePersonBadge } from "./tile-badge-person";
|
||||||
@ -17,9 +18,15 @@ export type ComputeBadgeFunction = (
|
|||||||
) => TileBadge | undefined;
|
) => TileBadge | undefined;
|
||||||
|
|
||||||
export const computeTileBadge: ComputeBadgeFunction = (stateObj, hass) => {
|
export const computeTileBadge: ComputeBadgeFunction = (stateObj, hass) => {
|
||||||
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
|
if (stateObj.state === UNKNOWN) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
|
return {
|
||||||
|
color: "var(--rgb-orange-color)",
|
||||||
|
iconPath: mdiExclamationThick,
|
||||||
|
};
|
||||||
|
}
|
||||||
const domain = computeDomain(stateObj.entity_id);
|
const domain = computeDomain(stateObj.entity_id);
|
||||||
switch (domain) {
|
switch (domain) {
|
||||||
case "person":
|
case "person":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user