Add: Support for plexPlayer in input_select and input_text.

pull/48/head
Juraj Nyíri 3 years ago
parent d24869e603
commit b738269d8d

@ -25,8 +25,8 @@ You can also use Live TV library by specifying its name, usually "Live TV & DVR"
- **kodi**: Entity id of your media_player configured via [Kodi](https://www.home-assistant.io/integrations/kodi/). See [detailed instructions](#kodi). It is also possible to use short declaration with kodi.
- **plexPlayer**: Name or machine ID of your plex client. Use this if you do not have devices above. See [detailed instructions](#all-other-plex-clients). It is required to use detailed declaration with "plexPlayer:" property.
- **cast**: Entity id of your media_player configured via [Google Cast](https://www.home-assistant.io/integrations/cast/). See [detailed instructions](#google-cast). It is also possible to use short declaration with cast.
- **input_select**: Entity id of input select you wish to use for selecting media player to play on. State of this entity needs to be entity ID of media player of `androidtv`, `kodi` or `cast`. It is currently not possible to combine this with `plexPlayer`.
- **input_text**: Entity id of input text you wish to use for selecting media player to play on. State of this entity needs to be entity ID of media player of `androidtv`, `kodi` or `cast`. It is currently not possible to combine this with `plexPlayer`.
- **input_select**: Entity id of input select you wish to use for selecting media player to play on. State of this entity needs to be entity ID of media player of `androidtv`, `kodi` or `cast`. You can also use this with `plexPlayer`, in that case, provide name or machine ID of your plex client. You can also provide the same string as displayed in entities selection in UI editor for the card (beginning with `plexPlayer |`).
- **input_text**: Entity id of input text you wish to use for selecting media player to play on. State of this entity needs to be entity ID of media player of `androidtv`, `kodi` or `cast`. You can also use this with `plexPlayer`, in that case, provide name or machine ID of your plex client. You can also provide the same string as displayed in entities selection in UI editor for the card (beginning with `plexPlayer |`).
**port**: _Optional_ Port of your plex sever.

@ -19887,7 +19887,7 @@ class PlayController {
if (lodash.isArray(entityID)) {
for (let i = 0; i < entityID.length; i += 1) {
const realEntityID = lodash.get(this.entityStates[entityID[i]], 'state');
let realEntityKey = 'unknown';
let realEntityKey = 'plexPlayer';
lodash.forEach(this.entityRegistry, entityInRegister => {
if (lodash.isEqual(entityInRegister.entity_id, realEntityID)) {
realEntityKey = entityInRegister.platform;
@ -19901,7 +19901,7 @@ class PlayController {
}
else {
const realEntityID = lodash.get(this.entityStates[entityID], 'state');
let realEntityKey = 'unknown';
let realEntityKey = 'plexPlayer';
lodash.forEach(this.entityRegistry, entityInRegister => {
if (lodash.isEqual(entityInRegister.entity_id, realEntityID)) {
realEntityKey = entityInRegister.platform;
@ -20049,14 +20049,18 @@ class PlayController {
return this.entityStates;
};
this.getPlexPlayerMachineIdentifier = (entity) => {
if (lodash.isString(entity) && lodash.isEqual(entity.split(' | ').length, 4)) {
// eslint-disable-next-line no-param-reassign
[, , , entity] = entity.split(' | ');
}
let machineIdentifier = '';
let { plex } = this;
let entityName = '';
if (lodash.isString(entity)) {
entityName = entity;
entityName = entity.trim();
}
else if (lodash.isObjectLike(entity) && !lodash.isNil(entity.identifier)) {
entityName = entity.identifier;
entityName = entity.identifier.trim();
if (!lodash.isNil(entity.plex) && entity.plex) {
plex = entity.plex;
}

@ -592,7 +592,7 @@ class PlayController {
if (_.isArray(entityID)) {
for (let i = 0; i < entityID.length; i += 1) {
const realEntityID = _.get(this.entityStates[entityID[i]], 'state');
let realEntityKey = 'unknown';
let realEntityKey = 'plexPlayer';
_.forEach(this.entityRegistry, entityInRegister => {
if (_.isEqual(entityInRegister.entity_id, realEntityID)) {
realEntityKey = entityInRegister.platform;
@ -605,7 +605,7 @@ class PlayController {
}
} else {
const realEntityID = _.get(this.entityStates[entityID], 'state');
let realEntityKey = 'unknown';
let realEntityKey = 'plexPlayer';
_.forEach(this.entityRegistry, entityInRegister => {
if (_.isEqual(entityInRegister.entity_id, realEntityID)) {
realEntityKey = entityInRegister.platform;
@ -769,14 +769,18 @@ class PlayController {
};
private getPlexPlayerMachineIdentifier = (entity: string | Record<string, any>): string => {
if (_.isString(entity) && _.isEqual(entity.split(' | ').length, 4)) {
// eslint-disable-next-line no-param-reassign
[, , , entity] = entity.split(' | ');
}
let machineIdentifier = '';
let { plex } = this;
let entityName = '';
if (_.isString(entity)) {
entityName = entity;
entityName = entity.trim();
} else if (_.isObjectLike(entity) && !_.isNil(entity.identifier)) {
entityName = entity.identifier;
entityName = entity.identifier.trim();
if (!_.isNil(entity.plex) && entity.plex) {
plex = entity.plex;
}

Loading…
Cancel
Save