diff --git a/src/components/ha-selector/ha-selector-media.ts b/src/components/ha-selector/ha-selector-media.ts index fc998f5d05..bd45f5dec1 100644 --- a/src/components/ha-selector/ha-selector-media.ts +++ b/src/components/ha-selector/ha-selector-media.ts @@ -8,7 +8,7 @@ import { getSignedPath } from "../../data/auth"; import { MediaClassBrowserSettings, MediaPickedEvent, - SUPPORT_BROWSE_MEDIA, + MediaPlayerEntityFeature, } from "../../data/media-player"; import type { MediaSelector, MediaSelectorValue } from "../../data/selector"; import type { HomeAssistant } from "../../types"; @@ -80,7 +80,8 @@ export class HaMediaSelector extends LitElement { const supportsBrowse = !this.value?.entity_id || - (stateObj && supportsFeature(stateObj, SUPPORT_BROWSE_MEDIA)); + (stateObj && + supportsFeature(stateObj, MediaPlayerEntityFeature.BROWSE_MEDIA)); return html` - ${supportsFeature(stateObj, SUPPORT_BROWSE_MEDIA) + ${supportsFeature(stateObj, MediaPlayerEntityFeature.BROWSE_MEDIA) ? html` - ${(supportsFeature(stateObj, SUPPORT_VOLUME_SET) || - supportsFeature(stateObj, SUPPORT_VOLUME_BUTTONS)) && + ${(supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_SET) || + supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_BUTTONS)) && ![UNAVAILABLE, UNKNOWN, "off"].includes(stateObj.state) ? html`
- ${supportsFeature(stateObj, SUPPORT_VOLUME_MUTE) + ${supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_MUTE) ? html` ` : ""} - ${supportsFeature(stateObj, SUPPORT_VOLUME_BUTTONS) + ${supportsFeature( + stateObj, + MediaPlayerEntityFeature.VOLUME_BUTTONS + ) ? html` ` : ""} - ${supportsFeature(stateObj, SUPPORT_VOLUME_SET) + ${supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_SET) ? html` @@ -168,7 +166,7 @@ class MoreInfoMediaPlayer extends LitElement { ` : ""} ${![UNAVAILABLE, UNKNOWN, "off"].includes(stateObj.state) && - supportsFeature(stateObj, SUPPORT_SELECT_SOUND_MODE) && + supportsFeature(stateObj, MediaPlayerEntityFeature.SELECT_SOUND_MODE) && stateObj.attributes.sound_mode_list?.length ? html`
diff --git a/src/panels/config/cloud/account/dialog-cloud-tts-try.ts b/src/panels/config/cloud/account/dialog-cloud-tts-try.ts index b93cbeac21..68e93478f4 100644 --- a/src/panels/config/cloud/account/dialog-cloud-tts-try.ts +++ b/src/panels/config/cloud/account/dialog-cloud-tts-try.ts @@ -14,7 +14,7 @@ import "../../../../components/ha-select"; import "../../../../components/ha-textarea"; import type { HaTextArea } from "../../../../components/ha-textarea"; import { showAutomationEditor } from "../../../../data/automation"; -import { SUPPORT_PLAY_MEDIA } from "../../../../data/media-player"; +import { MediaPlayerEntityFeature } from "../../../../data/media-player"; import { convertTextToSpeech } from "../../../../data/tts"; import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box"; import { haStyleDialog } from "../../../../resources/styles"; @@ -94,7 +94,7 @@ export class DialogTryTts extends LitElement { .filter( (entity) => computeStateDomain(entity) === "media_player" && - supportsFeature(entity, SUPPORT_PLAY_MEDIA) + supportsFeature(entity, MediaPlayerEntityFeature.PLAY_MEDIA) ) .map( (entity) => html` diff --git a/src/panels/lovelace/cards/hui-media-control-card.ts b/src/panels/lovelace/cards/hui-media-control-card.ts index 8f2f47303f..05d6faf3b2 100644 --- a/src/panels/lovelace/cards/hui-media-control-card.ts +++ b/src/panels/lovelace/cards/hui-media-control-card.ts @@ -31,10 +31,8 @@ import { handleMediaControlClick, MediaPickedEvent, MediaPlayerEntity, + MediaPlayerEntityFeature, mediaPlayerPlayMedia, - SUPPORT_BROWSE_MEDIA, - SUPPORT_SEEK, - SUPPORT_TURN_ON, } from "../../../data/media-player"; import type { HomeAssistant } from "../../../types"; import { findEntities } from "../common/find-entities"; @@ -174,7 +172,8 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { const isOffState = entityState === "off"; const isUnavailable = isUnavailableState(entityState) || - (entityState === "off" && !supportsFeature(stateObj, SUPPORT_TURN_ON)); + (entityState === "off" && + !supportsFeature(stateObj, MediaPlayerEntityFeature.TURN_ON)); const hasNoImage = !this._image; const controls = computeMediaControls(stateObj, false); const showControls = @@ -282,7 +281,10 @@ export class HuiMediaControlCard extends LitElement implements LovelaceCard { ` )} - ${supportsFeature(stateObj, SUPPORT_BROWSE_MEDIA) + ${supportsFeature( + stateObj, + MediaPlayerEntityFeature.BROWSE_MEDIA + ) ? html` ` : ""} - ${assumedState && supportsFeature(stateObj, SUPPORT_PLAY) + ${assumedState && supportsFeature(stateObj, MediaPlayerEntityFeature.PLAY) ? html` ` : ""} - ${assumedState && supportsFeature(stateObj, SUPPORT_PAUSE) + ${assumedState && + supportsFeature(stateObj, MediaPlayerEntityFeature.PAUSE) ? html`
- ${supportsFeature(stateObj, SUPPORT_TURN_ON) && + ${supportsFeature(stateObj, MediaPlayerEntityFeature.TURN_ON) && entityState === "off" && !isUnavailableState(entityState) ? html` @@ -214,11 +207,14 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow { @click=${this._togglePower} > ` - : !supportsFeature(stateObj, SUPPORT_VOLUME_SET) && - !supportsFeature(stateObj, SUPPORT_VOLUME_BUTTONS) + : !supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_SET) && + !supportsFeature( + stateObj, + MediaPlayerEntityFeature.VOLUME_BUTTONS + ) ? buttons : ""} - ${supportsFeature(stateObj, SUPPORT_TURN_OFF) && + ${supportsFeature(stateObj, MediaPlayerEntityFeature.TURN_OFF) && entityState !== "off" && !isUnavailableState(entityState) ? html` @@ -231,13 +227,16 @@ class HuiMediaPlayerEntityRow extends LitElement implements LovelaceRow { : ""}
- ${(supportsFeature(stateObj, SUPPORT_VOLUME_SET) || - supportsFeature(stateObj, SUPPORT_VOLUME_BUTTONS)) && + ${(supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_SET) || + supportsFeature(stateObj, MediaPlayerEntityFeature.VOLUME_BUTTONS)) && ![UNAVAILABLE, UNKNOWN, "off"].includes(entityState) ? html`
- ${supportsFeature(stateObj, SUPPORT_VOLUME_MUTE) + ${supportsFeature( + stateObj, + MediaPlayerEntityFeature.VOLUME_MUTE + ) ? html` ` : !this._veryNarrow && - supportsFeature(stateObj, SUPPORT_VOLUME_BUTTONS) + supportsFeature( + stateObj, + MediaPlayerEntityFeature.VOLUME_BUTTONS + ) ? html` computeStateDomain(entity) === "media_player" && - supportsFeature(entity, SUPPORT_BROWSE_MEDIA) && + supportsFeature(entity, MediaPlayerEntityFeature.BROWSE_MEDIA) && !this._hiddenEntities.has(entity.entity_id) ); }