2.0
Juraj Nyíri 3 years ago
parent b225de83fd
commit 5b26ffd259

@ -19459,6 +19459,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.playTrailer = document.createElement('paper-dropdown-menu'); this.playTrailer = document.createElement('paper-dropdown-menu');
this.showExtras = document.createElement('paper-dropdown-menu'); this.showExtras = document.createElement('paper-dropdown-menu');
this.showSearch = document.createElement('paper-dropdown-menu'); this.showSearch = document.createElement('paper-dropdown-menu');
this.runBefore = document.createElement('paper-dropdown-menu');
this.runAfter = document.createElement('paper-dropdown-menu');
this.devicesTabs = 0; this.devicesTabs = 0;
this.entities = []; this.entities = [];
this.scriptEntities = []; this.scriptEntities = [];
@ -19528,6 +19530,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
else if (lodash.isEqual(this.showSearch.value, 'No')) { else if (lodash.isEqual(this.showSearch.value, 'No')) {
this.config.showSearch = false; this.config.showSearch = false;
} }
this.config.runBefore = this.runBefore.value;
this.config.runAfter = this.runAfter.value;
} }
if (!lodash.isEqual(this.config, originalConfig)) { if (!lodash.isEqual(this.config, originalConfig)) {
this.fireEvent(this, 'config-changed', { config: this.config }); this.fireEvent(this, 'config-changed', { config: this.config });
@ -19571,7 +19575,6 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.scriptEntities.push(key); this.scriptEntities.push(key);
} }
}); });
console.log(this.scriptEntities);
this.entitiesRegistry = await fetchEntityRegistry(this.hassObj.connection); this.entitiesRegistry = await fetchEntityRegistry(this.hassObj.connection);
} }
this.entities = []; this.entities = [];
@ -19742,6 +19745,32 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
this.showSearch.value = showSearchValue; this.showSearch.value = showSearchValue;
this.plexValidSection.appendChild(this.showSearch); this.plexValidSection.appendChild(this.showSearch);
this.runBefore.innerHTML = '';
const runBeforeItems = document.createElement('paper-listbox');
runBeforeItems.appendChild(addDropdownItem(''));
lodash.forEach(this.scriptEntities, entity => {
runBeforeItems.appendChild(addDropdownItem(entity));
});
runBeforeItems.slot = 'dropdown-content';
this.runBefore.label = 'Script to execute before starting the media';
this.runBefore.appendChild(runBeforeItems);
this.runBefore.style.width = '100%';
this.runBefore.addEventListener('value-changed', this.valueUpdated);
this.runBefore.value = this.config.runBefore;
this.plexValidSection.appendChild(this.runBefore);
this.runAfter.innerHTML = '';
const runAfterItems = document.createElement('paper-listbox');
runAfterItems.appendChild(addDropdownItem(''));
lodash.forEach(this.scriptEntities, entity => {
runAfterItems.appendChild(addDropdownItem(entity));
});
runAfterItems.slot = 'dropdown-content';
this.runAfter.label = 'Script to execute after starting the media';
this.runAfter.appendChild(runAfterItems);
this.runAfter.style.width = '100%';
this.runAfter.addEventListener('value-changed', this.valueUpdated);
this.runAfter.value = this.config.runAfter;
this.plexValidSection.appendChild(this.runAfter);
let hasUIConfig = true; let hasUIConfig = true;
let canConvert = true; let canConvert = true;
if (lodash.isArray(this.config.entity)) { if (lodash.isArray(this.config.entity)) {
@ -19862,6 +19891,12 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
else { else {
this.config.showSearch = true; this.config.showSearch = true;
} }
if (!lodash.isNil(config.runBefore)) {
this.config.runBefore = config.runBefore;
}
if (!lodash.isNil(config.runAfter)) {
this.config.runAfter = config.runAfter;
}
this.render(); this.render();
}; };
this.configChanged = (newConfig) => { this.configChanged = (newConfig) => {
@ -21911,10 +21946,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (config.maxCount && config.maxCount !== '') { if (config.maxCount && config.maxCount !== '') {
this.maxCount = config.maxCount; this.maxCount = config.maxCount;
} }
if (config.runBefore) { if (config.runBefore && !lodash.isEqual(config.runBefore, '')) {
this.runBefore = config.runBefore; this.runBefore = config.runBefore;
} }
if (config.runAfter) { if (config.runAfter && !lodash.isEqual(config.runAfter, '')) {
this.runAfter = config.runAfter; this.runAfter = config.runAfter;
} }
if (!lodash.isNil(config.playTrailer)) { if (!lodash.isNil(config.playTrailer)) {

@ -40,6 +40,10 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
showSearch: any = document.createElement('paper-dropdown-menu'); showSearch: any = document.createElement('paper-dropdown-menu');
runBefore: any = document.createElement('paper-dropdown-menu');
runAfter: any = document.createElement('paper-dropdown-menu');
devicesTabs = 0; devicesTabs = 0;
hassObj: HomeAssistant | undefined; hassObj: HomeAssistant | undefined;
@ -120,6 +124,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} else if (_.isEqual(this.showSearch.value, 'No')) { } else if (_.isEqual(this.showSearch.value, 'No')) {
this.config.showSearch = false; this.config.showSearch = false;
} }
this.config.runBefore = this.runBefore.value;
this.config.runAfter = this.runAfter.value;
} }
if (!_.isEqual(this.config, originalConfig)) { if (!_.isEqual(this.config, originalConfig)) {
this.fireEvent(this, 'config-changed', { config: this.config }); this.fireEvent(this, 'config-changed', { config: this.config });
@ -166,7 +172,6 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.scriptEntities.push(key); this.scriptEntities.push(key);
} }
}); });
console.log(this.scriptEntities);
this.entitiesRegistry = await fetchEntityRegistry(this.hassObj.connection); this.entitiesRegistry = await fetchEntityRegistry(this.hassObj.connection);
} }
@ -350,6 +355,34 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.showSearch.value = showSearchValue; this.showSearch.value = showSearchValue;
this.plexValidSection.appendChild(this.showSearch); this.plexValidSection.appendChild(this.showSearch);
this.runBefore.innerHTML = '';
const runBeforeItems: any = document.createElement('paper-listbox');
runBeforeItems.appendChild(addDropdownItem(''));
_.forEach(this.scriptEntities, entity => {
runBeforeItems.appendChild(addDropdownItem(entity));
});
runBeforeItems.slot = 'dropdown-content';
this.runBefore.label = 'Script to execute before starting the media';
this.runBefore.appendChild(runBeforeItems);
this.runBefore.style.width = '100%';
this.runBefore.addEventListener('value-changed', this.valueUpdated);
this.runBefore.value = this.config.runBefore;
this.plexValidSection.appendChild(this.runBefore);
this.runAfter.innerHTML = '';
const runAfterItems: any = document.createElement('paper-listbox');
runAfterItems.appendChild(addDropdownItem(''));
_.forEach(this.scriptEntities, entity => {
runAfterItems.appendChild(addDropdownItem(entity));
});
runAfterItems.slot = 'dropdown-content';
this.runAfter.label = 'Script to execute after starting the media';
this.runAfter.appendChild(runAfterItems);
this.runAfter.style.width = '100%';
this.runAfter.addEventListener('value-changed', this.valueUpdated);
this.runAfter.value = this.config.runAfter;
this.plexValidSection.appendChild(this.runAfter);
let hasUIConfig = true; let hasUIConfig = true;
let canConvert = true; let canConvert = true;
if (_.isArray(this.config.entity)) { if (_.isArray(this.config.entity)) {
@ -473,6 +506,14 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.config.showSearch = true; this.config.showSearch = true;
} }
if (!_.isNil(config.runBefore)) {
this.config.runBefore = config.runBefore;
}
if (!_.isNil(config.runAfter)) {
this.config.runAfter = config.runAfter;
}
this.render(); this.render();
}; };

@ -1551,10 +1551,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (config.maxCount && config.maxCount !== '') { if (config.maxCount && config.maxCount !== '') {
this.maxCount = config.maxCount; this.maxCount = config.maxCount;
} }
if (config.runBefore) { if (config.runBefore && !_.isEqual(config.runBefore, '')) {
this.runBefore = config.runBefore; this.runBefore = config.runBefore;
} }
if (config.runAfter) { if (config.runAfter && !_.isEqual(config.runAfter, '')) {
this.runAfter = config.runAfter; this.runAfter = config.runAfter;
} }
if (!_.isNil(config.playTrailer)) { if (!_.isNil(config.playTrailer)) {

Loading…
Cancel
Save