OK - I’m going slightly nuts on this because I don’t know what’s wrong.
The function of this is to transfer the player queue to a “parked” queue, then play radio 4 for 3 minutes and then restore the queue back again, and restore it to its previous state.
After two MA updates ago, it’s started failing.
The failure is that when the player is “idle” before running, it does its job but after restoring the queue, it starts playing and doesn’t stop despite the specific commands telling it to pause (which I have inserted as troubleshooting, because I shouldn’t have to tell it to stop… it should have carried its current state)
It knows that the player is “idle” as that is in the logic, and the logic for the end condition is executing as it should … ie. != playing, and thus doesn’t execute.
So I’m completely stumped as to what’s going on and I’d be grateful for any help because I’m exasperated over this.
sequence:
- variables:
player: media_player.office_music_player
dummyplayer: media_player.office_home_assistant_media_player_2
is_playing: "{{ states(player) }}"
volume_level: "{{ state_attr(player, 'volume_level') | float(default=1.0) }}"
- target:
entity_id: "{{ player }}"
action: media_player.media_pause
- delay: "00:00:01"
- if:
- condition: template
value_template: >
{{ player == 'media_player.office_music_player' and
is_state('switch.teac_ai_301da', 'off') }}
then:
- target:
entity_id:
- switch.teac_ai_301da
action: switch.turn_on
- variables:
current_pos: "{{ state_attr(player, 'media_position') }}"
- data:
entity_id: "{{ player }}"
response_variable: queue_info
action: music_assistant.get_queue
- variables:
q_items: "{{ queue_info[player]['items'] | int(0) }}"
- target:
entity_id: "{{ dummyplayer }}"
data:
source_player: "{{ player }}"
action: music_assistant.transfer_queue
- action: media_player.volume_set
metadata: {}
target:
entity_id: "{{ player }}"
data:
volume_level: 1
- target:
entity_id: "{{ player }}"
data:
media:
media_content_id: >-
http://as-hls-ww-live.akamaized.net/pool_55057080/live/ww/bbc_radio_fourfm/bbc_radio_fourfm.isml/bbc_radio_fourfm-audio=96000.norewind.m3u8
media_content_type: R
action: media_player.play_media
- delay: "00:03:00"
- target:
entity_id: "{{ player }}"
action: media_player.clear_playlist
- target:
entity_id: "{{ player }}"
data:
source_player: "{{ dummyplayer }}"
action: music_assistant.transfer_queue
- target:
entity_id: "{{ player }}"
data:
seek_position: "{{ current_pos | float(0) }}"
action: media_player.media_seek
- if:
- condition: template
value_template: "{{ is_playing != 'playing' }}"
then:
- target:
entity_id: "{{ player }}"
action: media_player.media_pause
- delay: "00:00:01"
- if:
- condition: template
value_template: "{{ is_playing != 'playing' }}"
then:
- target:
entity_id: "{{ player }}"
action: media_player.media_pause
- target:
entity_id: "{{ player }}"
data:
volume_level: "{{ volume_level }}"
action: media_player.volume_set
- if:
- condition: template
value_template: "{{ q_items > 0 }}"
then:
- delay: "00:00:02"
- if:
- condition: template
value_template: "{{ is_playing == 'playing' }}"
then:
- target:
entity_id: "{{ player }}"
action: media_player.media_play
alias: Inject Radio 4 News into Office Player Queue
description: ""
mode: restart