4 m
I still have a landline at home. I use this landline only for people who must be able to reach me, even when I am asleep, like close relatives. When they call me at night, which doesn’t happen very often, I wanted to know who is calling before answering the phone. So, what’s better than a Google Home speaker which announces the identity of the caller when the phone rings? … 😉 Exactly! So I created just that.

My automation does two things. First, it checks if the number from the incoming call is in the address book of the Fritz!Box. If so, it announces the name. If not, it reads out ‘unknown number’ and the actual number from the caller when available. The video on top shows both situations.

For this to work you need the following things:

  • A phone on a landline using SIP (It can be a subscription of your local ISP or a SIP-account from a provider like VoipBuster)
  • An AVM Fritz!Box on which your landline is configured
  • A Google Cast device(e.g. a Google Nest Mini)

* Note that I use the AVM Fritz!Box. I didn’t check if there are other devices. You can still use this guide, script and automation if the devices you are using have an integration for Home Assistant with access to the call log of your router.

Furthermore, I am using the Cloud TTS service by Nabu Casa for more natural sounding voices. You may prefer another TTS integration, or maybe you are using the default Google Translate TTS, which is activated by default. If so, you can change the service and parameters in the script below.

First, the Fritz!Box need to be configured properly. Use the AVM Fritz!Box Call Monitor integration to give Home Assistant access to the call logs of your Fritz!Box router. Please make sure that the access of the phonebook must be included; otherwise Home Assistant can’t get data about corresponding names from your address book. After setup, the yaml configuration for Home Assistant will look like the following:

# Example Fritz!Box Call Monitor configuration
sensor:
  - platform: fritzbox_callmonitor
    name: Phone
    username: !secret fb_user
    password: !secret fb_password
    phonebook: 0

After restarting Home Assistant, you should have a sensor called ‘sensor.phone’. If your sensor has a different name, you need to change the name in the example configuration below.

Second, it’s time to create a script to get the caller’s identity announced on the Google Cast device. The best way to do this is by creating a script, since the tts-platform requires a data_template, which needs to be added directly into the configuration file. After doing this, the automation or script can no longer be edited through the user interface. The entire script is shown below. After you’ve checked and/or changed the landline sensor and Google Cast entity id’s, you can copy and paste this script directly into your script.yaml file and reload the scripts on the service control page within Home Assistant.

# Caller ID announcement script
announce_caller_id_on_nest_mini:
  alias: Announce caller ID on nest mini
  sequence:
  - service: tts.cloud_say
    entity_id: media_player.YOUR_MEDIA_PLAYER
    data_template:
      message: "{% if is_state_attr('sensor.phone', 'from_name', 'unknown') -%}Incoming call from an unknown person with number {{ state_attr('sensor.phone', 'from',) }}. {%- else -%}Incoming call from {{ state_attr('sensor.phone', 'from_name',) }}.{%- endif %}"
      language: en-US
      options:
        gender: male
  mode: single

After reloading the scripts, you can run the script to see if it’s working. Your Google Cast device should say: ‘None is calling’.

The only thing that’s left is an automation which triggers the script as soon as there is an incoming call. This can easy be done by looking for a state change on the ‘sensor.phone’ entity. Personally, I wanted the caller’s id announced repeatedly as long as the phone is ringing and only when I am at home. My automation looks as follows:

# Get caller id announced repeatedly when landline rings example
- alias: Land line - announce caller ID on nest mini
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.phone
    to: ringing
  - platform: state
    entity_id: media_player.YOUR_MEDIA_PLAYER
    from: playing
    to: idle
    for: 00:00:06
  condition:
  - condition: template
    value_template: '{{ not is_state("alarm_control_panel.barking_jane", "armed_away") }}'
  - condition: state
    entity_id: sensor.phone
    state: ringing
  action:
  - service: script.announce_caller_id_on_nest_mini
    data: {}
  mode: single

And that’s it! Now, your Google Cast device will announce who is calling so you can decide to answer or let it ring. 😉 You can do more fun things with this sensor, since it also tells you when someone is talking on the phone or making a call. You can create an automation which make your Google Cast also announcing outgoing calls, so your child can’t make a call without you noticing. 😉 (I will be a bad parent.. Haha)

What are you going to make with this phone sensor? Let me know! 🙂