Skip to content

Commit

Permalink
Revert "fix: only allow entities with platform=sonos"
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Jan 3, 2024
1 parent ef51105 commit e515efb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/card.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HomeAssistant } from 'custom-card-helpers';
import { css, html, LitElement } from 'lit';
import { property, state } from 'lit/decorators.js';
import { choose } from 'lit/directives/choose.js';
import Store from './model/store';
import { CardConfig, HomeAssistant, Section } from './types';
import { CardConfig, Section } from './types';
import './components/footer';
import './editor/editor';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/base-editor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css, LitElement } from 'lit';
import { fireEvent } from 'custom-card-helpers';
import { fireEvent, HomeAssistant } from 'custom-card-helpers';
import { property } from 'lit/decorators.js';
import { CardConfig, HomeAssistant } from '../types';
import { CardConfig } from '../types';
import Store from '../model/store';
import { dispatch } from '../utils/utils';

Expand Down
6 changes: 2 additions & 4 deletions src/model/store.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { HomeAssistant } from 'custom-card-helpers';
import HassService from '../services/hass-service';
import MediaBrowseService from '../services/media-browse-service';
import MediaControlService from '../services/media-control-service';
import {
CardConfig,
ConfigPredefinedGroup,
ConfigPredefinedGroupPlayer,
HomeAssistant,
PredefinedGroup,
PredefinedGroupPlayer,
Section,
Expand Down Expand Up @@ -110,9 +110,7 @@ export default class Store {

public getMediaPlayerHassEntities(hass: HomeAssistant) {
const configEntities = [...new Set(this.config.entities)];
return Object.values(this.hass.entities)
.filter((e) => e.entity_id.includes('media_player.') && e.platform === 'sonos')
.map((e) => hass.states[e.entity_id])
return Object.values(hass.states)
.filter(getGroupPlayerIds)
.filter((hassEntity) => {
const includesEntity = configEntities.includes(hassEntity.entity_id);
Expand Down
3 changes: 2 additions & 1 deletion src/services/hass-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HomeAssistant, MediaPlayerItem, Section, TemplateResult } from '../types';
import { HomeAssistant } from 'custom-card-helpers';
import { MediaPlayerItem, Section, TemplateResult } from '../types';
import { ServiceCallRequest } from 'custom-card-helpers/dist/types';
import { CALL_MEDIA_DONE, CALL_MEDIA_STARTED } from '../constants';
import { MediaPlayer } from '../model/media-player';
Expand Down
11 changes: 1 addition & 10 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HomeAssistant as HomeAssistantBase, LovelaceCardConfig } from 'custom-card-helpers';
import { LovelaceCardConfig } from 'custom-card-helpers';
import { MediaPlayer } from './model/media-player';

declare global {
Expand Down Expand Up @@ -117,12 +117,3 @@ export enum MediaPlayerEntityFeature {
REPEAT_SET = 262144,
GROUPING = 524288,
}

export interface HomeAssistant extends HomeAssistantBase {
entities: { [id: string]: EntityRegistryDisplayEntry };
}

export interface EntityRegistryDisplayEntry {
entity_id: string;
platform?: string;
}

0 comments on commit e515efb

Please sign in to comment.