Here is a blueprint to announce caller ID (name and number) on a Google Home media player device whenever a phone on port 1 of an Obihai device rings.
Requires Obihai integration, Google Home media player device (uses tts.google_translate_say service)
This will only announce calls on port 1 of the Obihai device!
You can specify the media player of a Google Home device (or a Google Home group) to play on.
Optionally, you can specify an entity name and condition in order to announce the caller id.
This can be used to only announce the caller ID when a person (or person group) is home, when a presence sensor detects someone in the room, or when a privacy mode or quiet mode input_boolean is off.
The phone number format announced is only for 10 digit North American phone numbers.
blueprint:
name: Obihai - Caller ID on Google Home
description: Announce incoming caller ID on Google Home
domain: automation
input:
media_player:
name: Google Home media player
description: Google Home media player device to announce caller ID on
selector:
entity:
domain: media_player
condition_entity:
name: Condition entity (optional)
description: |
Entity checked for condition in order to announce Caller ID. Examples:
person.person_name for person presence,
binary_sensor.presence_sensor for sensor presence,
input_boolean.privacy_mode for privacy or quiet mode, etc.
Leave blank for no conditions.
default:
selector:
entity:
condition_state:
name: Condition state (optional)
description: |
State that the above entity must be in order to announce Caller ID. Examples:
'home' for person entity, 'on' for presence sensor, 'off' for privacy or quiet mode
(don't enter the quotes). Leave blank for no conditions.
default:
mode: restart
max_exceeded: silent
variables:
condition_entity: !input condition_entity
condition_state: !input condition_state
trigger:
- entity_id: sensor.obihai_phone1_port
for: '1'
platform: state
to: Ringing
condition:
- condition: template
value_template: >
{{ (condition_entity == none) or (states[condition_entity].state == condition_state) }}
action:
- service: tts.google_translate_say
entity_id: !input media_player
data_template:
message: '{% set callerid = states(''sensor.obihai_phone1_port_last_caller_info'') %}
{% if callerid == ''--'' %}
{{ "Incoming call from unknown number" }}
{% else %}
{% set name = callerid[0:-12] %}
{% set num = callerid[-10:] %}
{% set numstring = num[0]+" "+num[1]+" "+num[2]+","+num[3]+" "+num[4]+" "+num[5]+","+num[6]+" "+num[7]+" "+num[8]+" "+num[9] %}
{{ "Incoming call from "+ name + "," + numstring }}
{% endif %}'
Example automation config: