Media Player - Volume limit

Tags: #<Tag:0x00007fc400ceb758> #<Tag:0x00007fc400ceb640>

Hello HA-community

I like to share my first blueprint with you.
This blueprint limits/reduce the volume of any media_player entity. It detects the current volume of the specified media_player, if this value exceeds the limit value its reset the volume to the default volume.

This blueprint can be useful if your children maximise the volume by accident. I’m using it for my alexa speaker, because there is currently no volume limit build in.

Sadly you have to type the media_player entities manually. At the moment the selector doesn’t allow multiple entities, so this is the workaround.

Prerequisites
Have a least one media_player configured. Multiple entities also work with comma separated.

Blueprint:

blueprint:
  name: Media Player - Volume limit
  description: Reduce the volume of media player to the default level, if limit is
    exceeded
  domain: automation
  input:
    media_player:
      name: Media Player
      description: 'Specify which media_player should trigger this automation. Comma
        seperated list is possible. For example: media_player.bathroom, media_player.kitchen'
    volume_limit:
      name: Volume limit
      description: Select the volume limit which should trigger this automation. For
        example "0.7"
      default: 0.7
      selector:
        number:
          min: 0.1
          max: 1.0
          mode: slider
          step: 0.05
    default_volume:
      name: Default volume
      description: Select the default volume level. For example "0.2"
      default: 0.2
      selector:
        number:
          min: 0.1
          max: 1.0
          mode: slider
          step: 0.05
  source_url: https://community.home-assistant.io/t/media-player-volume-limit/261229
mode: parallel
max: 10
trigger:
  platform: numeric_state
  entity_id: !input 'media_player'
  attribute: volume_level
  above: !input 'volume_limit'
action:
- service: media_player.volume_set
  data:
    volume_level: !input 'default_volume'
    entity_id: '{{ trigger.entity_id }}'

I hope you like it. Any feedback is welcome :slight_smile:

you can use a target selector, so you can use multiple entities

  • all the media_players has to have the attribute volume_level << with this specific name
    can be a problem

Thank you, for your feedback :+1:

Sadly the target selector doesn’t work for triggers, it’s only made for service calls , see: https://www.home-assistant.io/docs/blueprint/selectors/#target-selector.
Hopefully there will be a solution for it in the future.

Isn’t the attribute volume_level the same on every media_player? I thought it will be the same on every integration, because the attribute at the service media_player.volume_set is also volume_level see: https://www.home-assistant.io/integrations/media_player/

1 Like

Great idea - could be improved by allowing time of day this applies. (during day, kids can play louder, at night it needs to be low).