Skip to content

Commit

Permalink
Check if connection is null
Browse files Browse the repository at this point in the history
  • Loading branch information
fondberg committed Jul 23, 2020
1 parent 501bcdb commit 9918b3b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 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.22';
const CARD_VERSION = '2.0.0-beta.24';
export default CARD_VERSION;
14 changes: 9 additions & 5 deletions src/spotify-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,19 @@ export class SpotifyCard extends LitElement {

private unsubscribe_entitites?: any;

doSubscribeEntities() {
this.unsubscribe_entitites = subscribeEntities(this.hass.connection, (entities) => this.entitiesUpdated(entities));
}

connectedCallback(): void {
super.connectedCallback();
this.spotcast_connector = new SpotcastConnector(this);
//get all available entities and when they update
setTimeout(() => {
this.unsubscribe_entitites = subscribeEntities(this.hass.connection, (entities) =>
this.entitiesUpdated(entities)
);
}, 1000);
if (this.hass.connection) {
this.doSubscribeEntities();
} else {
setTimeout(() => this.doSubscribeEntities(), 1000);
}
}

public disconnectedCallback() {
Expand Down

0 comments on commit 9918b3b

Please sign in to comment.