2.0
Juraj Nyíri 3 years ago
parent e761e0eff9
commit e403f7acc9

@ -19714,17 +19714,37 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.showExtras.value = showExtrasValue; this.showExtras.value = showExtrasValue;
this.plexValidSection.appendChild(this.showExtras); this.plexValidSection.appendChild(this.showExtras);
let hasUIConfig = true; let hasUIConfig = true;
let canConvert = true;
if (lodash.isArray(this.config.entity)) { if (lodash.isArray(this.config.entity)) {
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
lodash.forEach(this.config.entity, entity => { lodash.forEach(this.config.entity, entity => {
if (lodash.isObjectLike(entity)) { if (lodash.isObjectLike(entity)) {
canConvert = !lodash.includes(lodash.keys(this.config.entity), 'plexPlayer');
hasUIConfig = false; hasUIConfig = false;
return false; return false;
} }
}); });
} }
else if (lodash.isObjectLike(this.config.entity)) { else if (lodash.isObjectLike(this.config.entity)) {
canConvert = !lodash.includes(lodash.keys(this.config.entity), 'plexPlayer');
hasUIConfig = false; hasUIConfig = false;
if (canConvert) {
const convertedEntities = [];
hasUIConfig = true;
if (lodash.isObjectLike(this.config.entity)) {
lodash.forOwn(this.config.entity, value => {
if (lodash.isString(value)) {
convertedEntities.push(value);
}
else if (lodash.isArray(value)) {
lodash.forEach(value, valueStr => {
convertedEntities.push(valueStr);
});
}
});
}
this.config.entity = convertedEntities;
}
} }
const devicesTitle = document.createElement('h2'); const devicesTitle = document.createElement('h2');
devicesTitle.innerHTML = `Devices Configuration`; devicesTitle.innerHTML = `Devices Configuration`;

@ -320,16 +320,35 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.plexValidSection.appendChild(this.showExtras); this.plexValidSection.appendChild(this.showExtras);
let hasUIConfig = true; let hasUIConfig = true;
let canConvert = true;
if (_.isArray(this.config.entity)) { if (_.isArray(this.config.entity)) {
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
_.forEach(this.config.entity, entity => { _.forEach(this.config.entity, entity => {
if (_.isObjectLike(entity)) { if (_.isObjectLike(entity)) {
canConvert = !_.includes(_.keys(this.config.entity), 'plexPlayer');
hasUIConfig = false; hasUIConfig = false;
return false; return false;
} }
}); });
} else if (_.isObjectLike(this.config.entity)) { } else if (_.isObjectLike(this.config.entity)) {
canConvert = !_.includes(_.keys(this.config.entity), 'plexPlayer');
hasUIConfig = false; hasUIConfig = false;
if (canConvert) {
const convertedEntities: Array<string> = [];
hasUIConfig = true;
if (_.isObjectLike(this.config.entity)) {
_.forOwn(this.config.entity, value => {
if (_.isString(value)) {
convertedEntities.push(value);
} else if (_.isArray(value)) {
_.forEach(value, valueStr => {
convertedEntities.push(valueStr);
});
}
});
}
this.config.entity = convertedEntities;
}
} }
const devicesTitle = document.createElement('h2'); const devicesTitle = document.createElement('h2');

Loading…
Cancel
Save