Fix cold-start play_media failure and swap reversed room IDs
The Spotify integration only exposes the media_player.play_media service once it has an active playback context, which doesn't exist yet on a cold start; the fixed 2s delay after select_source wasn't long enough in that case even though it always worked once something had already played. Poll supported_features for the PLAY_MEDIA bit (up to 8s) before calling play_media instead of guessing a fixed delay. Also swap the Living Room/Bedroom source_list ID mapping in both the prompt (for display) and the functions (for select_source) -- it was backwards. Adds a test-harness regression case exercising the opaque Spotify Connect device IDs the source_list actually reports. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7249919006
commit
2ed1ca1e99
3 files changed
+65
-22
No files matched your search
+20
-4
@@ -94,8 +94,16 @@
|
||||
target:
|
||||
entity_id: media_player.spotify_bhetherman
|
||||
data:
|
||||
source: "{{ room }}"
|
||||
- delay: "00:00:02"
|
||||
source: "{{ room | replace('Living Room', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') | replace('Bedroom', 'a334c8ba989367b52303eaa9dbc424cdd83012b5') }}"
|
||||
- repeat:
|
||||
while:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ repeat.index <= 8 and
|
||||
(state_attr('media_player.spotify_bhetherman', 'supported_features') | int(0)
|
||||
| bitwise_and(512)) != 512 }}
|
||||
sequence:
|
||||
- delay: "00:00:01"
|
||||
- service: media_player.play_media
|
||||
target:
|
||||
entity_id: media_player.spotify_bhetherman
|
||||
@@ -137,8 +145,16 @@
|
||||
target:
|
||||
entity_id: media_player.spotify_bhetherman
|
||||
data:
|
||||
source: "{{ room }}"
|
||||
- delay: "00:00:02"
|
||||
source: "{{ room | replace('Living Room', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') | replace('Bedroom', 'a334c8ba989367b52303eaa9dbc424cdd83012b5') }}"
|
||||
- repeat:
|
||||
while:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ repeat.index <= 8 and
|
||||
(state_attr('media_player.spotify_bhetherman', 'supported_features') | int(0)
|
||||
| bitwise_and(512)) != 512 }}
|
||||
sequence:
|
||||
- delay: "00:00:01"
|
||||
- service: media_player.play_media
|
||||
target:
|
||||
entity_id: media_player.spotify_bhetherman
|
||||
|
||||
Reference in new issue
Block a user