Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change and restore volume for announcements #2735

Open
StefanW86 opened this issue Dec 9, 2024 · 11 comments
Open

Change and restore volume for announcements #2735

StefanW86 opened this issue Dec 9, 2024 · 11 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@StefanW86
Copy link

NOTE: For a feature to be created it has to be doable in the Amazon app because we are basically replicating the app for HA. If you can't find it in the app, we probably can't create it here.

Is your feature request related to a problem? Please describe.
no

Describe the solution you'd like
I often use my echos for TTS announcements, e.g. the doorbell rang, washing machine ready.
However, my echos are often set to volume 1.

It would therefore be great if there was a parameter that could be added to a TTS announcement that raises the volume to a defined value, executes the TTS announcement and then resets the volume to the old value.

With Sonos integration, this is possible via the “announce” parameter.

Describe alternatives you've considered
i dont know any alternative

Additional context

@sayam93
Copy link
Contributor

sayam93 commented Dec 9, 2024

NOTE: For a feature to be created it has to be doable in the Amazon app because we are basically replicating the app for HA. If you can't find it in the app, we probably can't create it here.

Is your feature request related to a problem? Please describe. no

Describe the solution you'd like I often use my echos for TTS announcements, e.g. the doorbell rang, washing machine ready. However, my echos are often set to volume 1.

It would therefore be great if there was a parameter that could be added to a TTS announcement that raises the volume to a defined value, executes the TTS announcement and then resets the volume to the old value.

With Sonos integration, this is possible via the “announce” parameter.

Describe alternatives you've considered i dont know any alternative

Additional context

This can be done within the automation itself.

You can add something like the below both before and after the tts announce action:

action: media_player.volume_set
metadata: {}
data:
  volume_level: 0.7
target:
  entity_id: media_player.echo

Let me know if it works.

@StefanW86
Copy link
Author

I'm not quite sure if I've understood you correctly.
With your snippet I change the volume.

My problem is that I don't know what the current volume is to go back to it after the tts.

Example:
Music is playing at volume 1. Now I set the volume to 3 as you described, play the TTS and set it back to 1.
That would work.

However, if the music is now playing at level 3, I would set it back to 1 after the TTS and it would be too quiet.

It would therefore be great if there was an announce feature that remembers the original volume, plays TTS or other at the desired volume and then jumps back to the original volume.

@sayam93
Copy link
Contributor

sayam93 commented Dec 9, 2024

I'm not quite sure if I've understood you correctly. With your snippet I change the volume.

My problem is that I don't know what the current volume is to go back to it after the tts.

Example: Music is playing at volume 1. Now I set the volume to 3 as you described, play the TTS and set it back to 1. That would work.

However, if the music is now playing at level 3, I would set it back to 1 after the TTS and it would be too quiet.

It would therefore be great if there was an announce feature that remembers the original volume, plays TTS or other at the desired volume and then jumps back to the original volume.

For this, you could refer to https://community.home-assistant.io/t/turn-back-previous-volume-state-of-media-player/233396/

Specifically https://community.home-assistant.io/t/turn-back-previous-volume-state-of-media-player/233396/16

@StefanW86
Copy link
Author

Great, that works.
It's a bit more work in automation, but it's a solution.

So do you think the feature request is unnecessary? The Sonos integration offers such a parameter and does the work.

@sayam93
Copy link
Contributor

sayam93 commented Dec 9, 2024

Great, that works. It's a bit more work in automation, but it's a solution.

So do you think the feature request is unnecessary? The Sonos integration offers such a parameter and does the work.

The feature request is definitely a good idea. This is just a stopgap solution.

@StefanW86
Copy link
Author

I'm glad to hear that. Many thanks for the quick help

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Dec 9, 2024

Perhaps another contributor might have an idea on how to do this and run with it.

@sayam93
Copy link
Contributor

sayam93 commented Dec 9, 2024

Perhaps another contributor might have an idea on how to do this and run with it.

I believe the stopgap solution provided above should work for most people.

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Dec 10, 2024

That is the easiest for everyone to use. And if you need to determine how long the announcement is going to take before you restore the volume level, you can calculate a delay based on the word count in the message. I use this technique in my central Alexa: Notify Alexa Media Last Called script:

alias: "Alexa: Notify Alexa Media Last Called"
description: Send notification to sensor.last_alexa
fields:
  message:
    description: The message content
    example: I am notifying you
sequence:
  - action: python_script.notify_alexa_media_last_called
    data:
      message: "{{ message }}"
  - delay:
      seconds: >-
        {{ (message.split(' ') | count *
        states('input_number.alexa_word_duration')|float ) | round(0, 'floor',
        default) }}
    alias: Delay for word count * 0.55s
  - if:
      - condition: template
        value_template: "{{ states('sensor.last_alexa') != 'unknown'}}"
        enabled: false
      - condition: state
        entity_id: input_boolean.alexa_media_notify_service_registered
        state: "on"
        enabled: true
    then:
      - action: notify.alexa_media_last_called
        data:
          message: "{{ message }}"
        enabled: true
    enabled: false
  - action: notify.alexa_media_last_called
    data:
      message: "{{ message }}"
    enabled: false
mode: queued
icon: mdi:account-voice
max: 10

input_number.alexa_word_duration is use to fine tune the delay for your needs. Mine is 0.55s.

@alandtse
Copy link
Owner

alandtse commented Dec 10, 2024

@danielbrunt57 It's been tagged as help wanted. who knows, random people do submit enhancements if they want.

@alandtse alandtse added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Dec 10, 2024
@alandtse alandtse changed the title Announce a TTS Change and restore volume for announcements Dec 10, 2024
@alandtse
Copy link
Owner

#1792 for historical info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants