diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index b4213c0..4eb4710 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19217,7 +19217,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { if (this.plex) { const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]); // eslint-disable-next-line @typescript-eslint/camelcase - this.data.serverID = plexInfo; + this.data.serverID = plexInfo.machineIdentifier; lodash.forEach(plexSections, section => { this.data[section.title1] = section.Metadata; }); @@ -19316,7 +19316,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { lodash.forEach(this.data[this.config.libraryName], (movieData) => { if (!this.maxCount || count < this.maxCount) { count += 1; - this.content.appendChild(this.getMovieElement(movieData, this.data.server_id)); + this.content.appendChild(this.getMovieElement(movieData, this.data.serverID)); } else { return true; @@ -19548,11 +19548,13 @@ class PlexMeetsHomeAssistant extends HTMLElement { console.log(command); // eslint-disable-next-line @typescript-eslint/camelcase const { entity_id } = this.config; - this.hass.callService('androidtv', 'adb_command', { - // eslint-disable-next-line @typescript-eslint/camelcase - entity_id, - command - }); + if (this.hassObj) { + this.hassObj.callService('androidtv', 'adb_command', { + // eslint-disable-next-line @typescript-eslint/camelcase + entity_id, + command + }); + } }); const titleElem = document.createElement('div'); titleElem.innerHTML = escapeHtml(data.title); @@ -19605,6 +19607,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; } set hass(hass) { + this.hassObj = hass; if (!this.content) { this.playSupported = hass.states[this.config.entity_id] && diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 4c21202..b01abae 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -38,7 +38,10 @@ class PlexMeetsHomeAssistant extends HTMLElement { previousPositions: Array = []; + hassObj: HomeAssistant | undefined; + set hass(hass: HomeAssistant) { + this.hassObj = hass; if (!this.content) { this.playSupported = hass.states[this.config.entity_id] && @@ -59,7 +62,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { if (this.plex) { const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]); // eslint-disable-next-line @typescript-eslint/camelcase - this.data.serverID = plexInfo; + this.data.serverID = plexInfo.machineIdentifier; _.forEach(plexSections, section => { this.data[section.title1] = section.Metadata; }); @@ -173,7 +176,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { _.forEach(this.data[this.config.libraryName], (movieData: Record) => { if (!this.maxCount || count < this.maxCount) { count += 1; - this.content.appendChild(this.getMovieElement(movieData, this.data.server_id)); + this.content.appendChild(this.getMovieElement(movieData, this.data.serverID)); } else { return true; } @@ -440,11 +443,13 @@ class PlexMeetsHomeAssistant extends HTMLElement { console.log(command); // eslint-disable-next-line @typescript-eslint/camelcase const { entity_id } = this.config; - this.hass.callService('androidtv', 'adb_command', { - // eslint-disable-next-line @typescript-eslint/camelcase - entity_id, - command - }); + if (this.hassObj) { + this.hassObj.callService('androidtv', 'adb_command', { + // eslint-disable-next-line @typescript-eslint/camelcase + entity_id, + command + }); + } }); const titleElem = document.createElement('div');