Skip to content

Instantly share code, notes, and snippets.

@joe248
Created August 14, 2023 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joe248/c0b2fa8fecdef6d71620a89980ec32d3 to your computer and use it in GitHub Desktop.
Save joe248/c0b2fa8fecdef6d71620a89980ec32d3 to your computer and use it in GitHub Desktop.
script:
play_plex_album_on_roku_tv:
alias: Play Plex album on Roku TV
sequence:
# turn on the TV if it's not on
- choose:
- conditions:
- condition: state
entity_id: media_player.43_tcl_roku_tv
state: standby
sequence:
- service: media_player.turn_on
target:
entity_id: media_player.43_tcl_roku_tv
- wait_template: "{{ not is_state(\"media_player.43_tcl_roku_tv\", \"standby\") }}"
continue_on_timeout: true
timeout: "12"
# switch to the Plex app if it's not active
- choose:
- conditions:
- condition: template
value_template: "{{ not is_state_attr(\"media_player.43_tcl_roku_tv\", \"app_id\", \"13535\") }}"
sequence:
- service: media_player.select_source
target:
entity_id: media_player.43_tcl_roku_tv
data:
source: 13535
- wait_template: "{{ is_state_attr(\"media_player.43_tcl_roku_tv\", \"app_id\", \"13535\") }}"
continue_on_timeout: true
timeout: "15"
# play the playlist using the playlist_name that was passed in
- service: media_player.play_media
target:
entity_id: media_player.plex_plex_for_roku_43_tcl_roku_tv
data:
media_content_type: MUSIC
media_content_id: '{ "library_name": "Music", "album_name": "{{ album_name }}"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment