From 0e6b76e35afeed73aa407480a34a4d7f15872ad1 Mon Sep 17 00:00:00 2001 From: "J.P. Krauss" Date: Mon, 30 Dec 2024 10:28:47 -0800 Subject: [PATCH] feat: Add Shield TV to Media Package --- packages/media/media.yaml | 91 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/packages/media/media.yaml b/packages/media/media.yaml index 27f83d3..6b477ec 100644 --- a/packages/media/media.yaml +++ b/packages/media/media.yaml @@ -45,6 +45,91 @@ script: data: option: Idle + # Shield TV Input + # + # Very annoying since apps don't necessarily tell Android if they are playing + # (looking at you, Jellyfin) and we need two integrations to even get the full + # story for the Android TV base status. + # + # ATV (app ID) | Cast | JF | State + # ----------------------------|---------|---------|-------------------- + # off (XX) | XX | XX | Idle (system off) + # on (com.spocky.projengmenu) | XX | XX | Idle (Projectivity Launcher) + # on (org.jellyfin.androidtv) | XX | idle | Stopped (Jellyfin Home) + # on (org.jellyfin.androidtv) | XX | playing | Playing (Jellyfin) + # on (org.jellyfin.androidtv) | XX | paused | Paused (Jellyfin) + # on (others) | idle | XX | Stopped (App Home) + # on (others) | playing | XX | Playing (App) + # on (others) | paused | XX | Paused (App) + # + - condition: "{{ state_attr('media_player.living_room_receiver', 'source') == 'SHIELD' }}" + sequence: + - choose: + - conditions: + - condition: or + conditions: + - condition: template + value_template: "{{ is_state('media_player.shield_tv_living_room_atv', 'off') }}" + - condition: template + value_template: "{{ state_attr('media_player.shield_tv_living_room_atv', 'app_id') == 'com.spocky.projengmenu' }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Idle + + - conditions: "{{ state_attr('media_player.shield_tv_living_room_atv', 'app_id') == 'org.jellyfin.androidtv' }}" + sequence: + - choose: + - conditions: "{{ is_state('media_player.shield_tv_living_room_jellyfin', 'playing') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Playing + + - conditions: "{{ is_state('media_player.shield_tv_living_room_jellyfin', 'paused') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Paused + + - conditions: "{{ is_state('media_player.shield_tv_living_room_jellyfin', 'idle') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Stopped + + - conditions: "{{ is_state('media_player.shield_tv_living_room_cast', 'playing') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Playing + + - conditions: "{{ is_state('media_player.shield_tv_living_room_cast', 'paused') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Paused + + - conditions: "{{ is_state('media_player.shield_tv_living_room_cast', 'idle') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Stopped + # Roku Input - conditions: "{{ state_attr('media_player.living_room_receiver', 'source') == 'Roku Ultra' }}" sequence: @@ -120,6 +205,12 @@ automation: entity_id: media_player.living_room_receiver - platform: state entity_id: media_player.living_room_roku + - platform: state + entity_id: media_player.shield_tv_living_room_atv + - platform: state + entity_id: media_player.shield_tv_living_room_cast + - platform: state + entity_id: media_player.shield_tv_living_room_jellyfin action: - service: script.ht_player_state_update