Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setTimeout for subscribe
Browse files Browse the repository at this point in the history
fondberg committed Jul 23, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8c8dd1c commit 501bcdb
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions dist/spotify-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/spotify-card.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const CARD_VERSION = '2.0.0-beta.21';
const CARD_VERSION = '2.0.0-beta.22';
export default CARD_VERSION;
7 changes: 5 additions & 2 deletions src/spotify-card.ts
Original file line number Diff line number Diff line change
@@ -73,7 +73,11 @@ export class SpotifyCard extends LitElement {
super.connectedCallback();
this.spotcast_connector = new SpotcastConnector(this);
//get all available entities and when they update
this.unsubscribe_entitites = subscribeEntities(this.hass.connection, (entities) => this.entitiesUpdated(entities));
setTimeout(() => {
this.unsubscribe_entitites = subscribeEntities(this.hass.connection, (entities) =>
this.entitiesUpdated(entities)
);
}, 1000);
}

public disconnectedCallback() {
@@ -84,7 +88,6 @@ export class SpotifyCard extends LitElement {
//Callback when hass-entity has changed
entitiesUpdated(entities: HassEntities): void {
let updateDevices = false;
console.log('ENTITIES:', entities);
for (const item in entities) {
// Are there any changes to media players
if (item.startsWith('media_player')) {

0 comments on commit 501bcdb

Please sign in to comment.