Restore correct room ID mapping, fix select_source race in wait guard
Confirmed by direct hardware check: a334c8ba...=Bedroom, d0166d6f...= Living Room -- the swap from two commits ago was right, my revert of it was wrong. The actual bug behind the last "Living Room played in Bedroom" report was that the wait loop before play_media only checked supported_features (is play_media possible at all), not whether select_source's target had actually taken effect -- so if some other device was already active from earlier testing, the feature-gate could pass immediately while Spotify was still routing to that old device. Now the loop also waits for the source attribute to match the requested room's ID before proceeding. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+14
-8
@@ -94,14 +94,17 @@
|
|||||||
target:
|
target:
|
||||||
entity_id: media_player.spotify_bhetherman
|
entity_id: media_player.spotify_bhetherman
|
||||||
data:
|
data:
|
||||||
source: "{{ room | replace('Living Room', 'a334c8ba989367b52303eaa9dbc424cdd83012b5') | replace('Bedroom', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') }}"
|
source: "{{ room | replace('Living Room', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') | replace('Bedroom', 'a334c8ba989367b52303eaa9dbc424cdd83012b5') }}"
|
||||||
- repeat:
|
- repeat:
|
||||||
while:
|
while:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{{ repeat.index <= 8 and
|
{{ repeat.index <= 8 and (
|
||||||
(state_attr('media_player.spotify_bhetherman', 'supported_features') | int(0)
|
state_attr('media_player.spotify_bhetherman', 'source') !=
|
||||||
| bitwise_and(512)) != 512 }}
|
(room | replace('Living Room', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') | replace('Bedroom', 'a334c8ba989367b52303eaa9dbc424cdd83012b5'))
|
||||||
|
or (state_attr('media_player.spotify_bhetherman', 'supported_features') | int(0)
|
||||||
|
| bitwise_and(512)) != 512
|
||||||
|
) }}
|
||||||
sequence:
|
sequence:
|
||||||
- delay: "00:00:01"
|
- delay: "00:00:01"
|
||||||
- service: media_player.play_media
|
- service: media_player.play_media
|
||||||
@@ -145,14 +148,17 @@
|
|||||||
target:
|
target:
|
||||||
entity_id: media_player.spotify_bhetherman
|
entity_id: media_player.spotify_bhetherman
|
||||||
data:
|
data:
|
||||||
source: "{{ room | replace('Living Room', 'a334c8ba989367b52303eaa9dbc424cdd83012b5') | replace('Bedroom', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') }}"
|
source: "{{ room | replace('Living Room', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') | replace('Bedroom', 'a334c8ba989367b52303eaa9dbc424cdd83012b5') }}"
|
||||||
- repeat:
|
- repeat:
|
||||||
while:
|
while:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: >-
|
value_template: >-
|
||||||
{{ repeat.index <= 8 and
|
{{ repeat.index <= 8 and (
|
||||||
(state_attr('media_player.spotify_bhetherman', 'supported_features') | int(0)
|
state_attr('media_player.spotify_bhetherman', 'source') !=
|
||||||
| bitwise_and(512)) != 512 }}
|
(room | replace('Living Room', 'd0166d6f83796b0f9059b0adf0f6cb0d81fa6376') | replace('Bedroom', 'a334c8ba989367b52303eaa9dbc424cdd83012b5'))
|
||||||
|
or (state_attr('media_player.spotify_bhetherman', 'supported_features') | int(0)
|
||||||
|
| bitwise_and(512)) != 512
|
||||||
|
) }}
|
||||||
sequence:
|
sequence:
|
||||||
- delay: "00:00:01"
|
- delay: "00:00:01"
|
||||||
- service: media_player.play_media
|
- service: media_player.play_media
|
||||||
|
|||||||
+1
-1
@@ -64,4 +64,4 @@ entity_id,name,state,aliases
|
|||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
```
|
```
|
||||||
|
|
||||||
Available Spotify Connect rooms (valid values for the "room" parameter): {{ state_attr('media_player.spotify_bhetherman', 'source_list') | join(', ') | replace('a334c8ba989367b52303eaa9dbc424cdd83012b5', 'Living Room') | replace('d0166d6f83796b0f9059b0adf0f6cb0d81fa6376', 'Bedroom') }}
|
Available Spotify Connect rooms (valid values for the "room" parameter): {{ state_attr('media_player.spotify_bhetherman', 'source_list') | join(', ') | replace('d0166d6f83796b0f9059b0adf0f6cb0d81fa6376', 'Living Room') | replace('a334c8ba989367b52303eaa9dbc424cdd83012b5', 'Bedroom') }}
|
||||||
Reference in New Issue
Block a user