Filter out unavailable calendars in calendar panel (#14584)

This commit is contained in:
Philip Allgaier 2022-12-06 18:28:29 +01:00 committed by GitHub
parent 076a6c4459
commit b06db26540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { getColorByIndex } from "../common/color/colors";
import { computeDomain } from "../common/entity/compute_domain";
import { computeStateName } from "../common/entity/compute_state_name";
import type { HomeAssistant } from "../types";
import { UNAVAILABLE_STATES } from "./entity";
export interface Calendar {
entity_id: string;
@ -134,7 +135,11 @@ const getCalendarDate = (dateObj: any): string | undefined => {
export const getCalendars = (hass: HomeAssistant): Calendar[] =>
Object.keys(hass.states)
.filter((eid) => computeDomain(eid) === "calendar")
.filter(
(eid) =>
computeDomain(eid) === "calendar" &&
!UNAVAILABLE_STATES.includes(hass.states[eid].state)
)
.sort()
.map((eid, idx) => ({
entity_id: eid,