From e93cf6172e2f04881e91dc9705d6b6dc05db909b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 8 May 2021 01:07:41 +0200 Subject: [PATCH] Fix: Properly rename adb to androidtv --- README.md | 4 ++-- dist/plex-meets-homeassistant.js | 20 ++++++++++---------- src/modules/PlayController.ts | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e354312..24a95da 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Custom integration which integrates plex into Home Assistant and makes it possib **entity**: You need to configure at least one supported media_player entity. -- **adb**: Entity id of your media_player configured via [Android TV](https://www.home-assistant.io/integrations/androidtv/) +- **androidtv**: Entity id of your media_player configured via [Android TV](https://www.home-assistant.io/integrations/androidtv/) - **kodi**: Entity id of your media_player configured via [Kodi](https://www.home-assistant.io/integrations/kodi/). You also need to install and configure integration [Kodi Recently Added Media](https://github.com/jtbgroup/kodi-media-sensors) and its sensor **kodi_media_sensor_search**. @@ -39,7 +39,7 @@ Custom integration which integrates plex into Home Assistant and makes it possib _You can combine multiple supported entities_, in that case, entity for supported content will be chosen in order how you entered them. -As an example, if content can be played / shown both by kodi and adb, and you entered kodi first, it will be shown by kodi. If it cannot be played by kodi but can be played by adb, adb will be used. +As an example, if content can be played / shown both by kodi and androidtv, and you entered kodi first, it will be shown by kodi. If it cannot be played by kodi but can be played by androidtv, androidtv will be used. This will also work with play button being shown, it will only show when you can actually play content on your device. diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index b757b1c..66e5c63 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -18736,8 +18736,8 @@ class PlayController { case 'kodi': await this.playViaKodi(data.title, data.type); break; - case 'adb': - await this.playViaADB(data.key.split('/')[3], instantPlay); + case 'androidtv': + await this.playViaAndroidTV(data.key.split('/')[3], instantPlay); break; default: throw Error(`No service available to play ${data.title}!`); @@ -18763,7 +18763,7 @@ class PlayController { throw Error(`Plex type ${type} is not supported in Kodi.`); } }; - this.playViaADB = async (mediaID, instantPlay = false) => { + this.playViaAndroidTV = async (mediaID, instantPlay = false) => { const serverID = await this.plex.getServerID(); let command = `am start`; if (instantPlay) { @@ -18772,12 +18772,12 @@ class PlayController { command += ` -a android.intent.action.VIEW 'plex://server://${serverID}/com.plexapp.plugins.library/library/metadata/${mediaID}'`; this.hass.callService('androidtv', 'adb_command', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.adb, + entity_id: this.entity.androidtv, command: 'HOME' }); this.hass.callService('androidtv', 'adb_command', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.adb, + entity_id: this.entity.androidtv, command }); }; @@ -18785,7 +18785,7 @@ class PlayController { let service = ''; lodash.forEach(this.entity, (value, key) => { if (lodash.includes(this.supported[key], data.type)) { - if ((key === 'kodi' && this.isKodiSupported()) || (key === 'adb' && this.isADBSupported())) { + if ((key === 'kodi' && this.isKodiSupported()) || (key === 'androidtv' && this.isAndroidTVSupported())) { service = key; return false; } @@ -18807,10 +18807,10 @@ class PlayController { } return false; }; - this.isADBSupported = () => { - return (this.hass.states[this.entity.adb] && - this.hass.states[this.entity.adb].attributes && - this.hass.states[this.entity.adb].attributes.adb_response !== undefined); + this.isAndroidTVSupported = () => { + return (this.hass.states[this.entity.androidtv] && + this.hass.states[this.entity.androidtv].attributes && + this.hass.states[this.entity.androidtv].attributes.adb_response !== undefined); }; this.hass = hass; this.plex = plex; diff --git a/src/modules/PlayController.ts b/src/modules/PlayController.ts index 24b4e96..225c262 100644 --- a/src/modules/PlayController.ts +++ b/src/modules/PlayController.ts @@ -59,8 +59,8 @@ class PlayController { case 'kodi': await this.playViaKodi(data.title, data.type); break; - case 'adb': - await this.playViaADB(data.key.split('/')[3], instantPlay); + case 'androidtv': + await this.playViaAndroidTV(data.key.split('/')[3], instantPlay); break; default: throw Error(`No service available to play ${data.title}!`); @@ -86,7 +86,7 @@ class PlayController { } }; - private playViaADB = async (mediaID: number, instantPlay = false): Promise => { + private playViaAndroidTV = async (mediaID: number, instantPlay = false): Promise => { const serverID = await this.plex.getServerID(); let command = `am start`; @@ -98,12 +98,12 @@ class PlayController { this.hass.callService('androidtv', 'adb_command', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.adb, + entity_id: this.entity.androidtv, command: 'HOME' }); this.hass.callService('androidtv', 'adb_command', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.adb, + entity_id: this.entity.androidtv, command }); }; @@ -112,7 +112,7 @@ class PlayController { let service = ''; _.forEach(this.entity, (value, key) => { if (_.includes(this.supported[key], data.type)) { - if ((key === 'kodi' && this.isKodiSupported()) || (key === 'adb' && this.isADBSupported())) { + if ((key === 'kodi' && this.isKodiSupported()) || (key === 'androidtv' && this.isAndroidTVSupported())) { service = key; return false; } @@ -139,11 +139,11 @@ class PlayController { return false; }; - private isADBSupported = (): boolean => { + private isAndroidTVSupported = (): boolean => { return ( - this.hass.states[this.entity.adb] && - this.hass.states[this.entity.adb].attributes && - this.hass.states[this.entity.adb].attributes.adb_response !== undefined + this.hass.states[this.entity.androidtv] && + this.hass.states[this.entity.androidtv].attributes && + this.hass.states[this.entity.androidtv].attributes.adb_response !== undefined ); }; }