Mute media player when on phone, only when home

Hi, I have tried this blueprint; I can confirm the state is changing to offhook; also my person is in the correct zone. I also checked if the media player is “playing”

When manually triggering the service it works; also when I manually trigger the automation it also works but the phone doesn’t seem to trigger it for some reason.

Could you help with this one?

@TychoWerner Thanks for pointing out. I made the zone variable without testing because of my holiday. @thomasloven pointed out on discord that templates don’t work for state conditions. He suggested to change it to a template condition. That works! I’ve updated the gist and fist post.

@Adrian_Stanciu This might also solve your problem, please test the new version.

Just tested the new version, indeed it works now as intended. Thanks bud! :smiley:

1 Like

unistalled previous version, installed new version…still nothing.
Only noticed my phone sensor changed for incoming calls to ringing and outcoming calls webhook…and the tv is still with sound (restarted automations, i am home)

Sound like there is something wrong with your Phone State sensor since webhook is not a valid option (according to the docs).

The Android doc’s also list the idle, ringing, offhook as only valid states.

If you think this is a bug in the Android companion app I’d suggest you to report it there.

weel, sorry for confussion. it’s “offhook” when i make calls

The plan works fine, but I have a question. Why does the warning Mute mediaplayer when calling .: Already running appear in the log

I guess it’s causing calling the media_player.volume_mute service twice will cause a warning in the log that the service is already running.
It can be removed somehow. I can’t figure it out.

The running twice seems te come from the automation itself, not the mute service. It could be triggered twice if you receive and take a call. It triggers on ringing and offhook. When you make call it only fires on offhook, when you receive a call it first fires ringing and when you take the call its offhook. But the automation runs in single mode so it runs only once and you get the message in the logs file.

About the mute, it needs to call the service twice to mute and to un-mute it after the call.

Thanks, I’ll take another look at it. So far, I’ve solved it play and pause

I have a problem
I have 2 sensors that when sensor 1 switches state, it reports to the google home speaker. But the problem is that these 2 sensors are at the same time, so the google speaker overlap the signal. How to solve this problem?

So this blueprint is awesome and works great… except when the call is longer than 5 minutes the google home speaker just unmutes. While still on a call. Does anyone know how this is possible?

Edit: nvm Looking at the blueprint, there is a timeout of 300 seconds

@Do_Manh_Truong his blueprint is not build for multiple people. However, I use it for 2 people. In my case it’s rare both people are on the phone the same time. It’s possible to build one for 2 people, but that’s much more complex.

@At3 That’s the build-in timeout for unmuting. It’s a safety thing for when the mobile app doesn’t report the correct phone state. For me most calls don’t take that long. If you want you can change the timeout to something longer than 5 minutes. It’s located at the action part in the wait_for_trigger.

Hi,

I just ran the check for the new 2021.1.0 and it throws up an error before installing; hope you can do something with it :slight_smile:

Kind regards,
Tycho

ERROR:homeassistant.config:Invalid config for [automation]: Failed to load blueprint: Unable to find JackPoint/mute-media-player-when-on-phone-only-when-home.yaml (See /tmp/config/configuration.yaml, line 15). 
ERROR:homeassistant:Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/homeassistant/core.py", line 1395, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service persistent_notification.create

For me, the same version of HA works well without errors.

I just did the check before upgrading and no errors. After upgrading no errors on start and the blueprint works just fine when I make a call.

Since you also have an other error about the persistent_notification.create service that could not be found, it might be something else thats wrong with your installation.

Play/Pause would work better for multi-room configurations. Mute only mutes the master speaker.