diff --git a/source/_integrations/plex.markdown b/source/_integrations/plex.markdown index 629a2e122d3..cdaea375535 100644 --- a/source/_integrations/plex.markdown +++ b/source/_integrations/plex.markdown @@ -26,6 +26,7 @@ Support for playing music directly on linked [Sonos](/integrations/sonos/) speak There is currently support for the following device types within Home Assistant: - [Sensor](#sensor) +- [Button](#button) - [Media Player](#media-player) If a Plex server has been claimed by a Plex account via the [claim interface](https://plex.tv/claim), Home Assistant will require authentication to connect. @@ -97,6 +98,43 @@ The library sensors are disabled by default, but can be enabled via the Plex int +## Button + +A `button.scan_clients` entity is available to discover new controllable Plex clients. This may be necessary in scripts or automations which control a Plex client app, but where the underlying device must be turned on first. This button is preferred over the legacy `plex.scan_for_clients` service. + +Example script: + +{% raw %} + +```yaml +play_plex_on_tv: + sequence: + - service: media_player.select_source + target: + entity_id: media_player.smart_tv + data: + source: "Plex" + - wait_for_trigger: + - platform: state + entity_id: media_player.smart_tv + to: "on" + timeout: + seconds: 10 + - service: button.press + target: + entity_id: button.scan_clients_plex + - wait_template: "{{ not is_state('media_player.plex_smart_tv', 'unavailable') }}" + timeout: "00:00:10" + continue_on_timeout: false + - service: media_player.play_media + target: + entity_id: media_player.plex_smart_tv + data: + media_content_id: "{"library_name": "Movies", "title": "Zoolander"}" + media_content_type: movie +``` + +{% endraw %} ## Media Player @@ -335,37 +373,6 @@ Refresh a Plex library to scan for new and updated media. | `server_name` | No | Name of Plex server to use if multiple servers configured. | "My Plex Server" | | `library_name` | Yes | Name of Plex library to update. | "TV Shows" | -### Service `plex.scan_for_clients` - -Scan for new controllable Plex clients. This may be necessary in scripts or automations which control a Plex `media_player` entity, but where the underlying device must be turned on first. - -Example script: - -{% raw %} - -```yaml -play_plex_on_tv: - sequence: - - service: media_player.select_source - target: - entity_id: media_player.smart_tv - data: - source: "Plex" - - wait_template: "{{ is_state('media_player.smart_tv', 'On') }}" - timeout: "00:00:10" - - service: plex.scan_for_clients - - wait_template: "{{ not is_state('media_player.plex_smart_tv', 'unavailable') }}" - timeout: "00:00:10" - continue_on_timeout: false - - service: media_player.play_media - target: - entity_id: media_player.plex_smart_tv - data: - media_content_id: "{"library_name": "Movies", "title": "Zoolander"}" - media_content_type: movie -``` - -{% endraw %} ## Notes