Fix: Play button not working

pull/16/head
Juraj Nyíri 4 years ago
parent ff61397421
commit 2f4adbb26f

@ -19217,7 +19217,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.plex) { if (this.plex) {
const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]); const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]);
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
this.data.serverID = plexInfo; this.data.serverID = plexInfo.machineIdentifier;
lodash.forEach(plexSections, section => { lodash.forEach(plexSections, section => {
this.data[section.title1] = section.Metadata; this.data[section.title1] = section.Metadata;
}); });
@ -19316,7 +19316,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
lodash.forEach(this.data[this.config.libraryName], (movieData) => { lodash.forEach(this.data[this.config.libraryName], (movieData) => {
if (!this.maxCount || count < this.maxCount) { if (!this.maxCount || count < this.maxCount) {
count += 1; count += 1;
this.content.appendChild(this.getMovieElement(movieData, this.data.server_id)); this.content.appendChild(this.getMovieElement(movieData, this.data.serverID));
} }
else { else {
return true; return true;
@ -19548,11 +19548,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
console.log(command); console.log(command);
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
const { entity_id } = this.config; const { entity_id } = this.config;
this.hass.callService('androidtv', 'adb_command', { if (this.hassObj) {
// eslint-disable-next-line @typescript-eslint/camelcase this.hassObj.callService('androidtv', 'adb_command', {
entity_id, // eslint-disable-next-line @typescript-eslint/camelcase
command entity_id,
}); command
});
}
}); });
const titleElem = document.createElement('div'); const titleElem = document.createElement('div');
titleElem.innerHTML = escapeHtml(data.title); titleElem.innerHTML = escapeHtml(data.title);
@ -19605,6 +19607,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}; };
} }
set hass(hass) { set hass(hass) {
this.hassObj = hass;
if (!this.content) { if (!this.content) {
this.playSupported = this.playSupported =
hass.states[this.config.entity_id] && hass.states[this.config.entity_id] &&

@ -38,7 +38,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
previousPositions: Array<any> = []; previousPositions: Array<any> = [];
hassObj: HomeAssistant | undefined;
set hass(hass: HomeAssistant) { set hass(hass: HomeAssistant) {
this.hassObj = hass;
if (!this.content) { if (!this.content) {
this.playSupported = this.playSupported =
hass.states[this.config.entity_id] && hass.states[this.config.entity_id] &&
@ -59,7 +62,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.plex) { if (this.plex) {
const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]); const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]);
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
this.data.serverID = plexInfo; this.data.serverID = plexInfo.machineIdentifier;
_.forEach(plexSections, section => { _.forEach(plexSections, section => {
this.data[section.title1] = section.Metadata; this.data[section.title1] = section.Metadata;
}); });
@ -173,7 +176,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
_.forEach(this.data[this.config.libraryName], (movieData: Record<string, any>) => { _.forEach(this.data[this.config.libraryName], (movieData: Record<string, any>) => {
if (!this.maxCount || count < this.maxCount) { if (!this.maxCount || count < this.maxCount) {
count += 1; count += 1;
this.content.appendChild(this.getMovieElement(movieData, this.data.server_id)); this.content.appendChild(this.getMovieElement(movieData, this.data.serverID));
} else { } else {
return true; return true;
} }
@ -440,11 +443,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
console.log(command); console.log(command);
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
const { entity_id } = this.config; const { entity_id } = this.config;
this.hass.callService('androidtv', 'adb_command', { if (this.hassObj) {
// eslint-disable-next-line @typescript-eslint/camelcase this.hassObj.callService('androidtv', 'adb_command', {
entity_id, // eslint-disable-next-line @typescript-eslint/camelcase
command entity_id,
}); command
});
}
}); });
const titleElem = document.createElement('div'); const titleElem = document.createElement('div');

Loading…
Cancel
Save