Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
blueprint:
name: Mute mediaplayer when calling.
description: >
Mute a mediaplayer when phone rings or is calling.
Only when person is home and the mediaplayer is playing.
domain: automation
input:
phone_state:
name: Phone State sensor
description: All sensors form the mobile app. Select the phone state sensor here.
selector:
entity:
integration: mobile_app
domain: sensor
person:
name: Person
description: Select the person that needs to be at the zone selected.
selector:
entity:
domain: person
zone:
name: Zone
description: Select the Zone the person needs to be in.
default: zone.home
selector:
entity:
domain: zone
media_player:
name: Media Player
description: Select the media player that needs to be muted.
selector:
entity:
domain: media_player
trigger:
- platform: state
entity_id: !input phone_state
to: "ringing"
- platform: state
entity_id: !input phone_state
to: "offhook"
variables:
zone: !input zone
zone_name: "{{ zone[5:] }}"
entity: !input person
condition:
- "{{is_state(entity, zone_name)}}"
- condition: state
entity_id: !input media_player
state: playing
action:
- service: media_player.volume_mute
entity_id: !input media_player
data:
is_volume_muted: true
- wait_for_trigger:
- platform: state
entity_id: !input phone_state
to: "idle"
timeout:
seconds: 300
- service: media_player.volume_mute
entity_id: !input media_player
data:
is_volume_muted: false
I converted my “Mute media player when on phone, only when home” to a blue print so its available for everyone to use or get inspiration.
Inputs:
Phone State sensor from Android app
Person to check if zone is home
Media player to mute
I choose mute instead of play/pause. This might work better in some cases when streaming.
Hello, great idea and it even works right away.
It would be nice if you could still adjust the zone.
At home is okay, but far better if you could use smaller zones
Hmm, problem is, the zone is an input now, so the value is zone.home. But the condition uses the platform state, and there the value is home. Any one here an idea how to add the zone as a condition? If there is no solution, I can use a template thingy to remove the zone. part, but I hope there is a more elegant solution.
Can you advise how to rewrite it to play/pause instead of mute?
BTW! maybe it would be good idea to make user be able to choose between pause and mute while creating automation from the blueprint?
Nice Blueprint. This was the first one I tried . You’re a natural. Using your inspiration I tried to make a blueprint with volume.set instead of mute but it didn’t work. Do you have the time to add another one with a volume set?
tried many times, but no luck.
My media is TV samsung (integrated).
phone is set up in integration and has sensor.state active. I’m seen as home since 4 hours. I tried to call and to be called, nothing. My phone state is going from idle to webhook
What should i check ?
@CAHTA You can replace the media_player.volume_mute service calls with media_player.media_play_pause.
@Quasimodo Thanks! At first I build one with a volume.set but that’s a bit more complex because you need to remember the volume level before turning it down. That’s why I decided to use mute instead.
@Adrian_Stanciu You need to select the phone state sensor. Check the state of the sensor when making a call, it should change from idle to offhook. If that works, check if your media player supports muting. You can try it with the developer tools. (service: media_player.volume_mute fill it with the example data and change it to your media player. If that works, check if the person you selected is in the zone you selected. The developer tools list it without the zone. part. If this all works, but the media player doesn’t mute on a call, check your logs.
According to the docs, webhook isn’t a valid state for that sensor. This blueprint/automation isn’t listing to that event change, only to ringing and offhook.