Template sensor for caller id

Setting up my obi202 google voice adapter to provide caller id announcement through
alexa. All works great with an automation triggered by the phone ringing status, and alexa
tells me by notification who is calling. But I want to remove the phone number
from the announcement and just hear the callers name announced by alexa.

The obihai integration in home assistant provides me the caller id information
coming into my obi202 phone in the form of
‘callers name’ XXXXXXXXXXX
where XXX… is their phone number. The information is stored in the
entity sensor.obihai_phone1_port_last_caller_info. To strip the phone number
i use the template as follows:

value_template: {{ states(‘sensor.obihai_phone1_port_last_caller_info’).split(‘backslash’’)[1] }}

which in the developers tools provides me what I want, the resulting string is the callers name without the phone number. But when I try to make a template sensor for the callers name as follows:

  • platform: template
    sensors:
    caller_id:
    friendly_name: “Who is calling”
    value_template: {{ states(‘sensor.obihai_phone1_port_last_caller_info’).split(‘backslash’’)[1] }}

I get an error code when trying to save configuration.yaml:
missed comma between flow collection entries at line 203, column 92:
… t_last_caller_info’).split(’’’)[1] }}

Adding quotes before and after {{ }} does not fix. Any ideas, I am using
an escape to interpret the single quote between the caller id and phone number
as the split and that backslash escape seems to be the problem

Mine does not have single quotes around the caller’s name. I was able to use a regular expression to remove the phone number and trailing space

{{states('sensor.obihai_phone1_port_last_caller_info') | regex_replace(' \\d+', '') }}