mattlward
(Matt Ward)
March 2, 2020, 5:26pm
1
The following automation sets the volume up on my alexa’s, makes an announcement and sets the volume back down.
I am using the Alexa Media integration installed via HACS. There is a media_player.everywhere , but in operation it caused all of my original Dots not to speak. So, I had to set volume on each device and change it again on each device.
There has to be a way to clean this up, I tried 1 media_player.volume_set with multiple entity_id’s but I could not get it formatted to pass muster on the automation verify.
Any help would be appreciated as this all slows down the entire automation.
Thanks Matt
- alias: Announce Input to all alexa
trigger:
- platform: state
entity_id: input_text.alexa_tts
action:
- service: media_player.volume_set
data:
entity_id: media_player.work
volume_level: '0.9'
- service: media_player.volume_set
data:
entity_id: media_player.kids
volume_level: '0.9'
- service: media_player.volume_set
data:
entity_id: media_player.kitchen
volume_level: '0.9'
- service: media_player.volume_set
data:
entity_id: media_player.bedroom
volume_level: '0.9'
- service: notify.alexa_media
data:
target:
- media_player.living_room
- media_player.work
- media_player.kids
- media_player.bedroom
- media_player.echo
- media_player.kitchen
#title: "My title for Echo show"
data:
type: announce
#method: all
message: '{{ states.input_text.alexa_tts.state }}'
- service: media_player.volume_set
data:
entity_id: media_player.work
volume_level: '0.5'
- service: media_player.volume_set
data:
entity_id: media_player.kids
volume_level: '0.5'
- service: media_player.volume_set
data:
entity_id: media_player.kitchen
volume_level: '0.5'
- service: media_player.volume_set
data:
entity_id: media_player.bedroom
volume_level: '0.5'
AhmadK
(akasma74)
March 2, 2020, 6:24pm
2
How about
- service: media_player.volume_set
data:
volume_level: '0.9'
entity_id:
- media_player.living_room
- media_player.work
- media_player.kids
- media_player.bedroom
- media_player.echo
- media_player.kitchen
cannot test it as don’t have any media players but it should accept a list.
mattlward
(Matt Ward)
March 2, 2020, 6:48pm
3
AhmadK:
service: media_player.volume_set data: volume_level: ‘0.9’ entity_id: - media_player.living_room - media_player.work - media_player.kids - media_player.bedroom - media_player.echo - media_player.kitchen
That did it… I could not get the format nailed to save my soul earlier today.
Thanks Matt
AhmadK
(akasma74)
March 2, 2020, 7:36pm
4
Cool.
Just for fun, try this as well (untested but passes config checks)
- alias: Announce Input to all alexa
trigger:
- platform: state
entity_id: input_text.alexa_tts
action:
- service: &volume_set media_player.volume_set
data:
volume_level: '0.9'
<<: &entities
entity_id: &all_players
- media_player.living_room
- media_player.work
- media_player.kids
- media_player.bedroom
- media_player.echo
- media_player.kitchen
- service: notify.alexa_media
data:
target: *all_players
#title: "My title for Echo show"
data:
type: announce
#method: all
message: '{{ trigger.to_state.state }}'
- service: *volume_set
data:
volume_level: '0.5'
<<: *entities
Here and here is to do that.
mattlward
(Matt Ward)
March 2, 2020, 8:50pm
5
I tried it… It appears to set the volume the first time and then never announces and does not lower the volume. That is an interesting approach!
AhmadK
(akasma74)
March 2, 2020, 8:55pm
6
hm… cannot comment further but you have some fresh ideas/docs to digest
mattlward
(Matt Ward)
March 2, 2020, 8:57pm
7
Yes, every time I try something… I learn something. Have been running this instance for years and still consider myself a newb.
AhmadK
(akasma74)
March 2, 2020, 9:00pm
8
That’s because it’s still changing rapidly, not surprised… “Use” != “know everything about it”. Think smartphones
1 Like
AhmadK
(akasma74)
March 2, 2020, 10:43pm
9
Did this ever work? As you use template for your message
, it should be data_template
below service
.
AhmadK
(akasma74)
March 2, 2020, 10:53pm
10
How about this - requires a script:
script:
set_volume_media_players:
sequence:
service: media_player.volume_set
data_template:
volume_level: "{{ volume_level }}"
entity_id: "{{ entity_id }}"
- alias: Announce Input to all alexa
trigger:
- platform: state
entity_id: input_text.alexa_tts
action:
- service: script.set_volume_media_players
data:
volume_level: '0.9'
entity_id: &all_players
- media_player.living_room
- media_player.work
- media_player.kids
- media_player.bedroom
- media_player.echo
- media_player.kitchen
- service: notify.alexa_media
data_template:
message: '{{ trigger.to_state.state }}'
target: *all_players
data:
type: announce
- service: script.set_volume_media_players
data:
volume_level: '0.5'
entity_id: *all_players
mattlward
(Matt Ward)
March 4, 2020, 1:37pm
11
Yes… that worked well. The automation is smaller and faster now. Have not tried the last one.
1 Like