Add: input_text entity support

pull/47/head
Juraj Nyíri 3 years ago
parent 254abcb03d
commit 403a081dd1

@ -19882,7 +19882,7 @@ class PlayController {
}; };
this.exportEntity = (entityID, key) => { this.exportEntity = (entityID, key) => {
const entities = []; const entities = [];
if (lodash.isEqual(key, 'inputSelect')) { if (lodash.isEqual(key, 'inputSelect') || lodash.isEqual(key, 'inputText')) {
// special processing for templates // special processing for templates
if (lodash.isArray(entityID)) { if (lodash.isArray(entityID)) {
for (let i = 0; i < entityID.length; i += 1) { for (let i = 0; i < entityID.length; i += 1) {
@ -20031,7 +20031,7 @@ class PlayController {
} }
// get values for template entities // get values for template entities
for (const [key, value] of Object.entries(this.entity)) { for (const [key, value] of Object.entries(this.entity)) {
if (lodash.isEqual(key, 'inputSelect')) { if (lodash.isEqual(key, 'inputSelect') || lodash.isEqual(key, 'inputText')) {
const entities = this.exportEntity(value, key); const entities = this.exportEntity(value, key);
for (const entity of entities) { for (const entity of entities) {
if (!lodash.isNil(this.hass.states[entity.value])) { if (!lodash.isNil(this.hass.states[entity.value])) {
@ -20350,7 +20350,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
if (lodash.isEqual(entityRegistry.platform, 'cast') || if (lodash.isEqual(entityRegistry.platform, 'cast') ||
lodash.isEqual(entityRegistry.platform, 'kodi') || lodash.isEqual(entityRegistry.platform, 'kodi') ||
lodash.isEqual(entityRegistry.platform, 'androidtv') || lodash.isEqual(entityRegistry.platform, 'androidtv') ||
lodash.isEqual(entityRegistry.platform, 'input_select')) { lodash.isEqual(entityRegistry.platform, 'input_select') ||
lodash.isEqual(entityRegistry.platform, 'input_text')) {
const entityName = `${entityRegistry.platform} | ${entityRegistry.entity_id}`; const entityName = `${entityRegistry.platform} | ${entityRegistry.entity_id}`;
entities.appendChild(addDropdownItem(entityName)); entities.appendChild(addDropdownItem(entityName));
addedEntityStrings.push(entityName); addedEntityStrings.push(entityName);
@ -21918,12 +21919,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
else if (lodash.startsWith(entityString, 'androidtv | ') || else if (lodash.startsWith(entityString, 'androidtv | ') ||
lodash.startsWith(entityString, 'kodi | ') || lodash.startsWith(entityString, 'kodi | ') ||
lodash.startsWith(entityString, 'cast | ')) { lodash.startsWith(entityString, 'cast | ') ||
// eslint-disable-next-line prefer-destructuring lodash.startsWith(entityString, 'input_select | ') ||
realEntityString = entityString.split(' | ')[1]; lodash.startsWith(entityString, 'input_text | ')) {
isPlexPlayer = false;
}
else if (lodash.startsWith(entityString, 'input_select | ')) {
// eslint-disable-next-line prefer-destructuring // eslint-disable-next-line prefer-destructuring
realEntityString = entityString.split(' | ')[1]; realEntityString = entityString.split(' | ')[1];
isPlexPlayer = false; isPlexPlayer = false;
@ -21967,6 +21965,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
entityObj.inputSelect.push(entityInRegister.entity_id); entityObj.inputSelect.push(entityInRegister.entity_id);
break; break;
case 'input_text':
if (lodash.isNil(entityObj.inputText)) {
// eslint-disable-next-line no-param-reassign
entityObj.inputText = [];
}
entityObj.inputText.push(entityInRegister.entity_id);
break;
// pass // pass
} }
} }

@ -279,7 +279,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
_.isEqual(entityRegistry.platform, 'cast') || _.isEqual(entityRegistry.platform, 'cast') ||
_.isEqual(entityRegistry.platform, 'kodi') || _.isEqual(entityRegistry.platform, 'kodi') ||
_.isEqual(entityRegistry.platform, 'androidtv') || _.isEqual(entityRegistry.platform, 'androidtv') ||
_.isEqual(entityRegistry.platform, 'input_select') _.isEqual(entityRegistry.platform, 'input_select') ||
_.isEqual(entityRegistry.platform, 'input_text')
) { ) {
const entityName = `${entityRegistry.platform} | ${entityRegistry.entity_id}`; const entityName = `${entityRegistry.platform} | ${entityRegistry.entity_id}`;
entities.appendChild(addDropdownItem(entityName)); entities.appendChild(addDropdownItem(entityName));

@ -587,7 +587,7 @@ class PlayController {
private exportEntity = (entityID: Array<any> | string, key: string): Array<Record<string, any>> => { private exportEntity = (entityID: Array<any> | string, key: string): Array<Record<string, any>> => {
const entities: Array<Record<string, any>> = []; const entities: Array<Record<string, any>> = [];
if (_.isEqual(key, 'inputSelect')) { if (_.isEqual(key, 'inputSelect') || _.isEqual(key, 'inputText')) {
// special processing for templates // special processing for templates
if (_.isArray(entityID)) { if (_.isArray(entityID)) {
for (let i = 0; i < entityID.length; i += 1) { for (let i = 0; i < entityID.length; i += 1) {
@ -750,7 +750,7 @@ class PlayController {
// get values for template entities // get values for template entities
for (const [key, value] of Object.entries(this.entity)) { for (const [key, value] of Object.entries(this.entity)) {
if (_.isEqual(key, 'inputSelect')) { if (_.isEqual(key, 'inputSelect') || _.isEqual(key, 'inputText')) {
const entities = this.exportEntity(value, key); const entities = this.exportEntity(value, key);
for (const entity of entities) { for (const entity of entities) {
if (!_.isNil(this.hass.states[entity.value])) { if (!_.isNil(this.hass.states[entity.value])) {

@ -290,15 +290,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} else if ( } else if (
_.startsWith(entityString, 'androidtv | ') || _.startsWith(entityString, 'androidtv | ') ||
_.startsWith(entityString, 'kodi | ') || _.startsWith(entityString, 'kodi | ') ||
_.startsWith(entityString, 'cast | ') _.startsWith(entityString, 'cast | ') ||
_.startsWith(entityString, 'input_select | ') ||
_.startsWith(entityString, 'input_text | ')
) { ) {
// eslint-disable-next-line prefer-destructuring // eslint-disable-next-line prefer-destructuring
realEntityString = entityString.split(' | ')[1]; realEntityString = entityString.split(' | ')[1];
isPlexPlayer = false; isPlexPlayer = false;
} else if (_.startsWith(entityString, 'input_select | ')) {
// eslint-disable-next-line prefer-destructuring
realEntityString = entityString.split(' | ')[1];
isPlexPlayer = false;
} }
if (isPlexPlayer) { if (isPlexPlayer) {
if (_.isNil(entityObj.plexPlayer)) { if (_.isNil(entityObj.plexPlayer)) {
@ -338,6 +336,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
entityObj.inputSelect.push(entityInRegister.entity_id); entityObj.inputSelect.push(entityInRegister.entity_id);
break; break;
case 'input_text':
if (_.isNil(entityObj.inputText)) {
// eslint-disable-next-line no-param-reassign
entityObj.inputText = [];
}
entityObj.inputText.push(entityInRegister.entity_id);
break;
default: default:
// pass // pass
} }

Loading…
Cancel
Save