Get caller ID’s announced on Google Nest speakers
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 multiple 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.
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. This cannot be an automation, 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 from the user interface, so a script is the most convenient method. 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.nest_mini data_template: message: '{% if is_state_attr(''sensor.phone'', ''from_name'', ''unknown'') -%}Incoming call from {{ state_attr(''sensor.phone'', ''from'',) }}. {%- else -%}{{ state_attr(''sensor.phone'', ''from_name'',) }} is calling.{%- endif %}' 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 for: 00:00:05 - platform: state entity_id: media_player.nest_mini 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! 🙂
Questions? Or how did you do it?