Merge pull request #642 from felipecrs/not-show-unavailable
Do not show unavailable media players
This commit is contained in:
+14
-8
@@ -3,7 +3,9 @@ import {
|
|||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues, TemplateResult, unsafeCSS
|
PropertyValues,
|
||||||
|
TemplateResult,
|
||||||
|
unsafeCSS,
|
||||||
} from 'lit';
|
} from 'lit';
|
||||||
import { customElement, property, state } from 'lit/decorators.js';
|
import { customElement, property, state } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
@@ -18,7 +20,7 @@ import {
|
|||||||
ConditionState,
|
ConditionState,
|
||||||
conditionStateRequestHandler,
|
conditionStateRequestHandler,
|
||||||
getOverriddenConfig,
|
getOverriddenConfig,
|
||||||
getOverridesByKey
|
getOverridesByKey,
|
||||||
} from './card-condition.js';
|
} from './card-condition.js';
|
||||||
import './components/elements.js';
|
import './components/elements.js';
|
||||||
import { FrigateCardElements } from './components/elements.js';
|
import { FrigateCardElements } from './components/elements.js';
|
||||||
@@ -38,7 +40,7 @@ import {
|
|||||||
CAMERA_BIRDSEYE,
|
CAMERA_BIRDSEYE,
|
||||||
CARD_VERSION,
|
CARD_VERSION,
|
||||||
MEDIA_PLAYER_SUPPORT_BROWSE_MEDIA,
|
MEDIA_PLAYER_SUPPORT_BROWSE_MEDIA,
|
||||||
REPO_URL
|
REPO_URL,
|
||||||
} from './const.js';
|
} from './const.js';
|
||||||
import './editor.js';
|
import './editor.js';
|
||||||
import { localize } from './localize/localize.js';
|
import { localize } from './localize/localize.js';
|
||||||
@@ -61,14 +63,14 @@ import {
|
|||||||
MediaShowInfo,
|
MediaShowInfo,
|
||||||
MenuButton,
|
MenuButton,
|
||||||
Message,
|
Message,
|
||||||
RawFrigateCardConfig
|
RawFrigateCardConfig,
|
||||||
} from './types.js';
|
} from './types.js';
|
||||||
import {
|
import {
|
||||||
convertActionToFrigateCardCustomAction,
|
convertActionToFrigateCardCustomAction,
|
||||||
createFrigateCardCustomAction,
|
createFrigateCardCustomAction,
|
||||||
frigateCardHandleAction,
|
frigateCardHandleAction,
|
||||||
frigateCardHasAction,
|
frigateCardHasAction,
|
||||||
getActionConfigGivenAction
|
getActionConfigGivenAction,
|
||||||
} from './utils/action.js';
|
} from './utils/action.js';
|
||||||
import { contentsChanged } from './utils/basic.js';
|
import { contentsChanged } from './utils/basic.js';
|
||||||
import { getCameraIcon, getCameraID, getCameraTitle } from './utils/camera.js';
|
import { getCameraIcon, getCameraID, getCameraTitle } from './utils/camera.js';
|
||||||
@@ -79,7 +81,7 @@ import {
|
|||||||
homeAssistantSignPath,
|
homeAssistantSignPath,
|
||||||
isHassDifferent,
|
isHassDifferent,
|
||||||
isTriggeredState,
|
isTriggeredState,
|
||||||
sideLoadHomeAssistantElements
|
sideLoadHomeAssistantElements,
|
||||||
} from './utils/ha';
|
} from './utils/ha';
|
||||||
import { getEventID } from './utils/ha/browse-media.js';
|
import { getEventID } from './utils/ha/browse-media.js';
|
||||||
import { DeviceList, getAllDevices } from './utils/ha/device-registry.js';
|
import { DeviceList, getAllDevices } from './utils/ha/device-registry.js';
|
||||||
@@ -87,7 +89,7 @@ import {
|
|||||||
ExtendedEntityCache,
|
ExtendedEntityCache,
|
||||||
getAllEntities,
|
getAllEntities,
|
||||||
getExtendedEntities,
|
getExtendedEntities,
|
||||||
getExtendedEntity
|
getExtendedEntity,
|
||||||
} from './utils/ha/entity-registry.js';
|
} from './utils/ha/entity-registry.js';
|
||||||
import { ResolvedMediaCache } from './utils/ha/resolved-media.js';
|
import { ResolvedMediaCache } from './utils/ha/resolved-media.js';
|
||||||
import { supportsFeature } from './utils/ha/update.js';
|
import { supportsFeature } from './utils/ha/update.js';
|
||||||
@@ -499,7 +501,11 @@ export class FrigateCard extends LitElement {
|
|||||||
const isValidMediaPlayer = (entity: string): boolean => {
|
const isValidMediaPlayer = (entity: string): boolean => {
|
||||||
if (entity.startsWith('media_player.')) {
|
if (entity.startsWith('media_player.')) {
|
||||||
const stateObj = this._hass?.states[entity];
|
const stateObj = this._hass?.states[entity];
|
||||||
if (stateObj && supportsFeature(stateObj, MEDIA_PLAYER_SUPPORT_BROWSE_MEDIA)) {
|
if (
|
||||||
|
stateObj &&
|
||||||
|
stateObj.state !== 'unavailable' &&
|
||||||
|
supportsFeature(stateObj, MEDIA_PLAYER_SUPPORT_BROWSE_MEDIA)
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user