Media Player - Volume limit

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.

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

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Blueprint:

blueprint:
  name: Media Player - Volume limit
  description: Reduce the volume of media player to the default level, if limit is
    exceeded
  domain: automation
  author: N1c093
  input:
    media_player:
      name: Media Player
      description: 'Specify which media_player should trigger this automation. Multiple Media Player also work'
      selector:
        entity:
          domain: media_player
          multiple: true
    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
    condition:
      name: (optional) Automation condition
      default:
      description: You can configure an optional condition for this automation.
      selector:
        condition:
          
  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'
condition: !input 'condition'
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:

3 Likes

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).

Hello,

When I try to add this I get Unresolved tag: !input errors.

Thanks

I just setup a new Home Assistant installation. The import and the creation of an automation with this blue print worked without any problem.

Can you check one more time. If it still doesn’t work, can you describe the problem more detailed?

Ahh I was trying to manually add it as I did not see that import blueprint button that you see on some blueprint web pages. I didn’t realize you could just copy and paste this web url. Imported fine.

Thank you!

Thank you for the hint.
I just added the import button.

1 Like

Hey there. This is a really useful blueprint. Would you mind adding the newly introduced option for conditions to it? Or add an option to select a “kill switch” as I would like to disable the limiter somehow. I created a helper switch called binary_sensor.party_mode.

Thank you for your comment. I just updated the blueprint with the condition.
You have to reimport the blueprint.

I am getting Message malformed: Missing input condition when I am trying to use this blueprint. Here is the YAML:

description: ""
alias: Media Player - Volume limit
use_blueprint:
  path: N1c093/media-player-volume-limit.yaml
  input:
    media_player:
      - media_player.google_in_kitchen
    volume_limit: 0.65
    default_volume: 0.25
1 Like

Me too for Samsung LED40

Can you reimport the blueprint and check it again?
The issue should be fixed now.

1 Like

It works now.

1 Like