EPMatt / awesome-ha-blueprints

A curated collection of automation blueprints for Home Assistant.
https://epmatt.github.io/awesome-ha-blueprints
GNU General Public License v3.0
845 stars 248 forks source link

Enhancement - media_player-hook - (Optional setting) only allow volume-changes if media_player. is playing #186

Open smathev opened 2 years ago

smathev commented 2 years ago

Blueprint name

media_player / ikea_e1744

Description

Hi.

So, I'm using the media_player Hook with an ikea E1744 symfonisk remote. It is working wonderfully, and it was easy to set up the blueprints and automation.

However, I've noticed that I can change volume when the music isn't playing. That isn't really a bad thing in itself, but without feedback as to how much the volume has changed it would mean I could (potentially) turn it from easy-listening at 5% volume to 100% volume while paused and only know it when I turned the music back on.

So, my suggestion is that there should be an option in the media_player-Hook as to whether volume-changes could happen when the media_player is paused.

Automation YAML config

conditions:
      - condition: state
        entity_id: media_player.XXXXX-NameOfMediaPlayerThatTheHookIsControlling
        state: 'playing'
      - condition: state
        state: '{{ action == volume_up_repeat }}'

I'm fairly certain that something along these lines would mean that volume-changes wouldn't happen when the music is paused, and would ensure that you get feedback

Implementation

A toggle in the media_player implementation whether volume changes should only be made when the media_player.XXXX is playing music.

Additional Details

Useful resources

No response

Additional context

No response

EPMatt commented 2 years ago

Hi @smathev,

thank you so much for the suggestion, I think this might be a great addition to the Media Player hook. Do you think you could submit a Pull Request for this? :)

smathev commented 2 years ago

Hi @EPMatt Thank you for the quick reply. I'm afraid my code-knowledge is not up to par to ensure this is working, neither would I know how to implement it into a blueprint.

I'm merely hoping that you would have the time to implement it at some point - and I would love to help troubleshoot/test it when it's ready.

EPMatt commented 2 years ago

Hi @smathev,

Thank you for your quick feedback. Don't worry, I'll take a look at this. :)

I'll let you know as soon as the blueprint Is ready. Changes will be included in a Pull Request which will be linked to this issue. We could then continue our conversation for proper testing and feedback there.

Thanks again for your great suggestion! :)

habitoti commented 2 years ago

It's been a while for this one, however I believe it's really important! The Symfonisk lying around in the living room tends to attract people to just turn the knob w/o any music playing, and a Sonos system can get REALLY loud that way. Once you switch it then on, a heart attack is almost a sure thing then... I worked around that so far by creating separate volume-up and volume-down scripts that have a media player state "playing" as a precondition. However having those scripts being executed within the looped vol-up/down hooks seems to make the whole experience quite laggy. Maybe for the time being there are some suggestions to improve performance of such a workaround?