2.0
Juraj Nyíri 3 years ago
parent 9015086217
commit 5a780bec45

@ -20818,34 +20818,58 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.renderInitialData = async () => { this.renderInitialData = async () => {
let { entity } = JSON.parse(JSON.stringify(this.config)); let { entity } = JSON.parse(JSON.stringify(this.config));
const processEntity = (entityObj, entityString) => { const processEntity = (entityObj, entityString) => {
lodash.forEach(this.entityRegistry, entityInRegister => { let realEntityString = entityString;
if (lodash.isEqual(entityInRegister.entity_id, entityString)) { let isPlexPlayer = false;
switch (entityInRegister.platform) { if (lodash.startsWith(entityString, 'plexPlayer | ')) {
case 'cast': // eslint-disable-next-line prefer-destructuring
if (lodash.isNil(entityObj.cast)) { realEntityString = entityString.split(' | ')[3];
// eslint-disable-next-line no-param-reassign isPlexPlayer = true;
entityObj.cast = []; }
} else if (lodash.startsWith(entityString, 'androidtv | ') ||
entityObj.cast.push(entityInRegister.entity_id); lodash.startsWith(entityString, 'kodi | ') ||
break; lodash.startsWith(entityString, 'cast | ')) {
case 'androidtv': // eslint-disable-next-line prefer-destructuring
if (lodash.isNil(entityObj.androidtv)) { realEntityString = entityString.split(' | ')[1];
// eslint-disable-next-line no-param-reassign isPlexPlayer = false;
entityObj.androidtv = []; }
} if (isPlexPlayer) {
entityObj.androidtv.push(entityInRegister.entity_id); if (lodash.isNil(entityObj.plexPlayer)) {
break; // eslint-disable-next-line no-param-reassign
case 'kodi': entityObj.plexPlayer = [];
if (lodash.isNil(entityObj.kodi)) {
// eslint-disable-next-line no-param-reassign
entityObj.kodi = [];
}
entityObj.kodi.push(entityInRegister.entity_id);
break;
// pass
}
} }
}); entityObj.plexPlayer.push(realEntityString);
}
else {
lodash.forEach(this.entityRegistry, entityInRegister => {
if (lodash.isEqual(entityInRegister.entity_id, realEntityString)) {
switch (entityInRegister.platform) {
case 'cast':
if (lodash.isNil(entityObj.cast)) {
// eslint-disable-next-line no-param-reassign
entityObj.cast = [];
}
entityObj.cast.push(entityInRegister.entity_id);
break;
case 'androidtv':
if (lodash.isNil(entityObj.androidtv)) {
// eslint-disable-next-line no-param-reassign
entityObj.androidtv = [];
}
entityObj.androidtv.push(entityInRegister.entity_id);
break;
case 'kodi':
if (lodash.isNil(entityObj.kodi)) {
// eslint-disable-next-line no-param-reassign
entityObj.kodi = [];
}
entityObj.kodi.push(entityInRegister.entity_id);
break;
// pass
}
}
});
}
console.log(realEntityString);
}; };
const entityOrig = entity; const entityOrig = entity;
if (lodash.isString(entityOrig)) { if (lodash.isString(entityOrig)) {
@ -20858,6 +20882,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
processEntity(entity, entityStr); processEntity(entity, entityStr);
}); });
} }
console.log(entity);
this.loading = true; this.loading = true;
this.renderPage(); this.renderPage();
try { try {

@ -235,35 +235,59 @@ class PlexMeetsHomeAssistant extends HTMLElement {
let { entity } = JSON.parse(JSON.stringify(this.config)); let { entity } = JSON.parse(JSON.stringify(this.config));
const processEntity = (entityObj: Record<string, any>, entityString: string): void => { const processEntity = (entityObj: Record<string, any>, entityString: string): void => {
_.forEach(this.entityRegistry, entityInRegister => { let realEntityString = entityString;
if (_.isEqual(entityInRegister.entity_id, entityString)) { let isPlexPlayer = false;
switch (entityInRegister.platform) { if (_.startsWith(entityString, 'plexPlayer | ')) {
case 'cast': // eslint-disable-next-line prefer-destructuring
if (_.isNil(entityObj.cast)) { realEntityString = entityString.split(' | ')[3];
// eslint-disable-next-line no-param-reassign isPlexPlayer = true;
entityObj.cast = []; } else if (
} _.startsWith(entityString, 'androidtv | ') ||
entityObj.cast.push(entityInRegister.entity_id); _.startsWith(entityString, 'kodi | ') ||
break; _.startsWith(entityString, 'cast | ')
case 'androidtv': ) {
if (_.isNil(entityObj.androidtv)) { // eslint-disable-next-line prefer-destructuring
// eslint-disable-next-line no-param-reassign realEntityString = entityString.split(' | ')[1];
entityObj.androidtv = []; isPlexPlayer = false;
} }
entityObj.androidtv.push(entityInRegister.entity_id); if (isPlexPlayer) {
break; if (_.isNil(entityObj.plexPlayer)) {
case 'kodi': // eslint-disable-next-line no-param-reassign
if (_.isNil(entityObj.kodi)) { entityObj.plexPlayer = [];
// eslint-disable-next-line no-param-reassign
entityObj.kodi = [];
}
entityObj.kodi.push(entityInRegister.entity_id);
break;
default:
// pass
}
} }
}); entityObj.plexPlayer.push(realEntityString);
} else {
_.forEach(this.entityRegistry, entityInRegister => {
if (_.isEqual(entityInRegister.entity_id, realEntityString)) {
switch (entityInRegister.platform) {
case 'cast':
if (_.isNil(entityObj.cast)) {
// eslint-disable-next-line no-param-reassign
entityObj.cast = [];
}
entityObj.cast.push(entityInRegister.entity_id);
break;
case 'androidtv':
if (_.isNil(entityObj.androidtv)) {
// eslint-disable-next-line no-param-reassign
entityObj.androidtv = [];
}
entityObj.androidtv.push(entityInRegister.entity_id);
break;
case 'kodi':
if (_.isNil(entityObj.kodi)) {
// eslint-disable-next-line no-param-reassign
entityObj.kodi = [];
}
entityObj.kodi.push(entityInRegister.entity_id);
break;
default:
// pass
}
}
});
}
console.log(realEntityString);
}; };
const entityOrig = entity; const entityOrig = entity;
@ -276,6 +300,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
processEntity(entity, entityStr); processEntity(entity, entityStr);
}); });
} }
console.log(entity);
this.loading = true; this.loading = true;
this.renderPage(); this.renderPage();
try { try {

Loading…
Cancel
Save