sequence:
- service: notify.alexa_media_echo_spot
data:
message: This is my message
data:
type: tts
to which I would like to set the volume to maximum, and at the end return to the previous setting that I don’t know. I need it to send a warning to the maximum volume and then reset the volume previously existing in the device. It’s possible to do it?
Also, if I wanted to send a message to a whole group managing the volume, like
Hello @anon63427907 ,
Thank you for your answer. Theoretically this is correct, but how can I manage the volume of multiple devices with a message sent to a group?
You can get benefit of scenes but not sure if scenes will support groups.
You can create a scene on the fly and save the current state of defined entities into a scene, which will not be saved to db but will be available until restart. At the beginning, create scene and store the state of group (or each entities under group), send your notification and apply scene. Just a thought experiment.
Hi @anon63427907 ,
the solution would seem excellent, but putting it into practice is far from simple. I should
- know all the alexa_media entities (the group is everyone)
- extract the volume value individually
- change the volume at all
- send the message
- set the old volume of the single entities
I don’t know if such a complex scene like this is achievable, I need to study it.
Anyway thanks for the idea.
i am also interested in this and have a possible way to start from. I think it’s not possible to notify all echo devices at once but with a delay this is working: (you need to create a group with all echo devices mine is group.all_media_players)
Wow. Fantastic! It is practically the code of what first @anon63427907 and then I have expressed schematically. Something will certainly need to be adapted (I don’t know if Alexa’s everyone group is accessible), but it’s definitely a big job ready and well done. Tomorrow I will try to adapt and modify it for my environment, but apparently the most is done.
Thanks @florian.ec, really very useful.
however, i have an idea to get all media_player entities from the alexa_media integration.
This will match only media_player entities (cause there is a chance that sensors are created from the integration Home · custom-components/alexa_media_player Wiki · GitHub )
{% set alexa_media_entities = integration_entities("alexa_media") | select('match', "media_player") | list | join('|') %}
{% set x = states.media_player | select("search", alexa_media_entities) | list %}
and only the entity_id’s as list for the notify target
{% set alexa_media_entities = integration_entities("alexa_media") | select('match', "media_player") | list | join(',') %}
so my previous sequence would be
sequence:
- variables:
players_and_volume: >
{% set alexa_media_entities = integration_entities("alexa_media") | select('match', "media_player") | list | join('|') %}
{% set x = states.media_player | select("search", alexa_media_entities) | list %}
{% set ns = namespace(result=[]) %}
{% for s in x %}
{% set ns.result = ns.result + [ [s.entity_id, s.attributes.volume_level] ] %}
{% endfor %}
{{ ns.result }}
- repeat:
count: '{{ players_and_volume | count }}'
sequence:
- delay: "00:00:02"
- variables:
player_and_volume: '{{ players_and_volume[repeat.index - 1] }}'
- service: media_player.volume_set
data_template:
entity_id: "{{ player_and_volume | first }}"
volume_level: "0.5"
- delay: "00:00:02"
- service: notify.alexa_media
data_template:
target: >
{% set alexa_media_entities = integration_entities("alexa_media") | select('match', "media_player") | list | join(',') %}
{{alexa_media_entities}}
data:
type: tts
message: "Test"
- delay: "00:00:02"
- repeat:
count: '{{ players_and_volume | count }}'
sequence:
- delay: "00:00:02"
- variables:
player_and_volume: '{{ players_and_volume[repeat.index - 1] }}'
- service: media_player.volume_set
data_template:
entity_id: "{{ player_and_volume | first }}"
volume_level: "{{ player_and_volume | last }}"
With this there is no need to create an additional group.
Hi Florian!
Thanks for the script! Works very well.
I just change the select(‘match’, “media_player”) to select(‘match’, “media_player.echo”), because I have other devices that match, and had “Undefined” values that broke the script later.
Just a question, why the delays?
The prosody amazon polly ssml tags work for me to change the volume of tts notifications.
Here’s an example of my tts message with volume lowered by 5 db. Range is -6 to +6 db.
<prosody volume="-5dB">Hey bill, there's an animal in the back yard</prosody>
If you are talking about where to use the prosody tags.
I put <prosody volume=\"-5dB\">Hey bill, there's an animal in the back yard</prosody>
as the message entry.
Here’s the yaml result
service: notify.alexa_media
data:
message: "<prosody volume=\"-5dB\">Hey bill, there's an animal in the back yard</prosody> "
target: media_player.bill_s_echo_dot