diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 07ecb42..1fda3e5 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19714,17 +19714,37 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.showExtras.value = showExtrasValue; this.plexValidSection.appendChild(this.showExtras); let hasUIConfig = true; + let canConvert = true; if (lodash.isArray(this.config.entity)) { // eslint-disable-next-line consistent-return lodash.forEach(this.config.entity, entity => { if (lodash.isObjectLike(entity)) { + canConvert = !lodash.includes(lodash.keys(this.config.entity), 'plexPlayer'); hasUIConfig = false; return false; } }); } else if (lodash.isObjectLike(this.config.entity)) { + canConvert = !lodash.includes(lodash.keys(this.config.entity), 'plexPlayer'); 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'); devicesTitle.innerHTML = `Devices Configuration`; diff --git a/src/editor.ts b/src/editor.ts index d54c17d..13abdb6 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -320,16 +320,35 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement { this.plexValidSection.appendChild(this.showExtras); let hasUIConfig = true; + let canConvert = true; if (_.isArray(this.config.entity)) { // eslint-disable-next-line consistent-return _.forEach(this.config.entity, entity => { if (_.isObjectLike(entity)) { + canConvert = !_.includes(_.keys(this.config.entity), 'plexPlayer'); hasUIConfig = false; return false; } }); } else if (_.isObjectLike(this.config.entity)) { + canConvert = !_.includes(_.keys(this.config.entity), 'plexPlayer'); hasUIConfig = false; + if (canConvert) { + const convertedEntities: Array = []; + 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');