With the latest release of the Android companion app (v2.2.0) there is a new sensor for telephony, which is awesome!
This is my new automation to mute the livingroom AVR if somebody calls and unmutes it two seconds after the call has ended.
Of course the AVR is only muted if the person that is called & calling is at home and the AVR is on
I created the automation through the GUI but it heavily relies on templates. Sorry for the mess.
- id: 63151a43-f930-4680-a6f8-cc288014c81c
alias: Mute audio on phone call
description: ''
trigger:
- entity_id: sensor.android_1_phone_state
from: idle
platform: state
- entity_id: sensor.android_2_phone_state
from: idle
platform: state
condition:
- condition: and
conditions:
- condition: state
entity_id: media_player.livingroom_avr
state: 'on'
- condition: template
value_template: "{%- if trigger.entity_id == 'sensor.android_1_phone_state' -%}\n\
\ {{is_state('person.robot_2', 'home')}}\n{%- elif trigger.entity_id == 'sensor.android_2_phone_state'\
\ -%}\n {{is_state('person.robot_1', 'home')}}\n{%- else -%}\n {{false}}\n\
{%- endif -%}"
action:
- data:
is_volume_muted: true
entity_id: media_player.livingroom_avr
service: media_player.volume_mute
mode: single
- id: 730b23de-6fbe-4213-8aa3-5a8cb4e1241c
alias: Unmute audio after phone call
description: ''
trigger:
- entity_id: sensor.android_1_phone_state
for: 00:00:02
platform: state
to: idle
- entity_id: sensor.android_2_phone_state
for: 00:00:02
platform: state
to: idle
condition:
- condition: and
conditions:
- condition: state
entity_id: media_player.livingroom_avr
state: 'on'
- condition: template
value_template: "{%- if trigger.entity_id == 'sensor.android_1_phone_state' -%}\n\
\ {{is_state('person.robot_2', 'home')}}\n{%- elif trigger.entity_id == 'sensor.android_2_phone_state'\
\ -%}\n {{is_state('person.robot_1', 'home')}}\n{%- else -%}\n {{false}}\n\
{%- endif -%}"
- condition: template
value_template: '{%- if state_attr("media_player.livingroom_avr", "is_volume_muted")
-%}
{{ true }}
{%- else -%}
{{ false }}
{%- endif -%}'
action:
- data:
is_volume_muted: false
entity_id: media_player.livingroom_avr
service: media_player.volume_mute
mode: single