Obihai - Announce caller ID on google home (confirmed working 2024)

This is an update of Xelloss99’s Obihai announce caller id (which no longer works due to changes in tts)

From original post (Obihai - Announce caller id on Google Home): 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
          multiple: false
    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:
  source_url: https://community.home-assistant.io/t/obihai-announce-caller-id-on-google-home/259564
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.speak
  target:
    entity_id: tts.google_en_com
  data_template:
    language: en
    #you can put more than one media player below with a comma and space
    media_player_entity_id: media_player.kitchen_speaker
    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 %}'

First, let me start by saying I don’t have a clue what I’m doing, or what I’m talking about, so I’m almost guaranteed to use the wrong terminology, or ask a REALLY stupid question. (This is my first posting).

I downloaded this Blueprint, and created an Automation based on it. However, I initially got no audio. I noticed that the media player is hard coded into the blueprint - “media_player.kitchen_speaker” . I manually changed that to my media player (MPD running on a RasPi Zero W) in the blueprint and it works well.

I should also mention, I noticed the requirement for a Google Home Media Player Device, which I DO NOT have, and I assume it’s the basic cause of my issue. However, it Does work fine with MPD if I hard code it in.

Now for the stupid questions:

  1. The method I used to change the blueprint was to manually change the player name in the file in the Blueprints directory, then rename the file and save it to a new directory (so it wouldn’t get overwritten if it was ever revised online). This doesn’t seem to be the best way to handle a blueprint modification. Is there a generally accepted method to handle blueprint mods?

  2. Is it possible to modify the blueprint to make the media player name changeable? The Automation DOES offer my existing media players in the setup for the automation, but ignores my inputs (Perhaps because they aren’t Google Home Media Player devices?)

Forgive my ignorance, but every time I hit a wall I learn something from it, and I’ve hit quite a few walls in my path from HomeSeer HS4 to Home Assistant. :slight_smile: