diff --git a/packages/media/media.yaml b/packages/media/media.yaml index 7271eef..1a3905b 100644 --- a/packages/media/media.yaml +++ b/packages/media/media.yaml @@ -12,6 +12,7 @@ input_select: - Stopped - System - Offline + - Unknown initial: Idle # ----------------------------------------------------------------------------- @@ -26,13 +27,8 @@ script: mode: restart sequence: - choose: - # Receiver Off (prevents error with source attribute not available - # when receiver is off; normally this is set directly by the Turn-Off - # to Idle automation) - - conditions: - - condition: state - entity_id: media_player.living_room_receiver - state: 'off' + # Receiver Off + - conditions: "{{ is_state('media_player.living_room_receiver', 'off') }}" sequence: - service: input_select.select_option target: @@ -61,13 +57,12 @@ script: option: Paused - conditions: - - condition: or + - condition: and conditions: - # Not sure why this doesn't work with shorthand notation? - condition: template - value_template: "{{ is_state('media_player.living_room_roku', 'stopped') }}" + value_template: "{{ is_state('media_player.living_room_roku', 'on') }}" - condition: template - value_template: "{{ is_state('media_player.living_room_roku', 'idle') }}" + value_template: "{{ not is_state('input_select.ht_player_state', 'Idle') }}" sequence: - service: input_select.select_option target: @@ -75,6 +70,22 @@ script: data: option: Stopped + - conditions: "{{ is_state('media_player.living_room_roku', 'off') }}" + sequence: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Idle + + # Fallback to Unknown State + default: + - service: input_select.select_option + target: + entity_id: input_select.ht_player_state + data: + option: Unknown + # ----------------------------------------------------------------------------- # Media Player Automations automation: