I have created the following template sensor, which takes the cid_name
attribute from sensor.phone_modem
and makes it its own entity while leaving the other two attributes in place. It works great, but I would really like to format the number
attribute like a US telephone number: (xxx) xxx-xxxx
Can someone help me with this, please?
- sensor:
- name: phone_call
icon: mdi:phone-classic
state: >
{% if is_state('sensor.phone_modem', 'callerid') %}
{{ state_attr('sensor.phone_modem', 'cid_name') }}
{% else %}
idle
{% endif %}
attributes:
number: "{{ state_attr('sensor.phone_modem', 'cid_number') }}"
time: "{{ state_attr('sensor.phone_modem', 'cid_time') }}"