TheFes
(The Fes)
February 25, 2022, 8:15am
89
markdavidoff:
alias: Google Speaker Play
mode: parallel
icon: mdi:cast-audio
description: >-
Plays media (on Google Speakers) at the specified volume without the extra
bleeps and bloops. Restores the state back after it is done.
fields:
playback_entity:
name: Playback Entity
description: The entity that will play the sound
required: true
selector:
entity:
domain: media_player
playback_volume:
name: Volume
description: Volume to play the sound at
required: false
selector:
number:
min: 0
max: 100
step: 10
unit_of_measurement: percent
mode: slider
media_location:
name: Content ID
description: The ID of the content to play. Platform dependent.
example: media-source://media_source/local/folder_name/file.wav
required: true
selector:
text: null
media_type:
name: Content type
description: >-
The type of the content to play. Like image, music, tvshow, video,
episode, channel or playlist.
example: media-source://media_source/local/folder_name/file.wav
required: true
default: music
selector:
text: null
sequence:
- service: scene.create
data:
scene_id: before_state_{{ playback_entity|replace(".", "_") }}
snapshot_entities: '{{ playback_entity }}'
- service: media_player.volume_mute
data:
is_volume_muted: true
target:
entity_id: '{{ playback_entity }}'
- service: media_player.play_media
data:
media_content_id: '{{ media_location }}'
media_content_type: '{{ media_type }}'
target:
entity_id: '{{ playback_entity }}'
- wait_template: '{% if states(playback_entity) == ''playing'' %}true{% endif %}'
timeout: '00:00:02'
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ playback_volume is number and playback_volume > -1 }}'
sequence:
- service: media_player.volume_set
data:
volume_level: ' {{ playback_volume / 100 }} '
target:
entity_id: '{{ playback_entity }}'
- service: media_player.volume_mute
data:
is_volume_muted: false
target:
entity_id: '{{ playback_entity }}'
- wait_template: '{% if states(playback_entity) == ''idle'' %}true{% endif %}'
timeout: '00:05:00'
continue_on_timeout: false
- service: scene.turn_on
data: {}
target:
entity_id: scene.before_state_{{ playback_entity|replace(".", "_") }}
@markdavidoff I also don’t see why this would help not getting the cast sound. While testing it myself, I also still get the sound.
Resume of media also does not work by use of scenes with Google Home, becuase of that I have created a script which does work, but which is almost 1000 lines long (also because I try to incorporate all use cases, and it works differently for Spotify, TuneIn, Youtube Music.
Here is a link to my script: Script to resume Google Cast devices after they have been interrupted by any action
I think to not get the cast sound, the approach above in the first post will work best. I do see some room for improvement though, maybe I will look into it in the near future.
1 Like