Hello. I’ve got the REST integration pulling some values off my Polycom VVX phone. My goal was to be able to stop the music, but then it occurred to me that my Ulanzi/awtrix display would be a good place to send the caller ID.
rest:
- authentication: basic
username: "Polycom"
password: 123456
scan_interval: 2
resource: http://192.168.1.99/api/v1/webCallControl/callStatus
sensor:
- name: "PolycomCallState"
value_template: "{{ value_json.data.CallState }}"
- name: "PolycomType"
value_template: "{{ value_json.data.Type }}"
- name: "PolycomRemotePartyName"
value_template: "{{ value_json.data.RemotePartyName }}"
- name: "PolycomCallType"
value_template: "{{ value_json.data.RemotePartyNumber }}"
- name: "PolycomRinging"
value_template: "{{ value_json.data.Ringing }}"
This works fine to bring the values I’m interested in into HA.
Sensor.polycomcalltype will ordinarily show sip:[phone number]@IP address. Ideally I’d like to show only that part rather than the whole value.
alias: Polycom Caller ID
description: ""
triggers:
- trigger: state
entity_id:
- sensor.polycomcallstate
for:
hours: 0
minutes: 0
seconds: 2
from: unknown
conditions: []
actions:
- action: mqtt.publish
metadata: {}
data:
evaluate_payload: true
qos: 0
retain: false
topic: awtrix_0c0dc8/notify
payload: >-
{"text": "{{states('sensor.polycomcalltype')}}","rainbow":
true,"duration": 10,"overlay": "drizzle"}
mode: single
The above works fine to send the whole value to the Ulanzi/Awtrix display. How can I manipulate the string to just be the value between the colon and the @ sign - ie the phone number.
This is the raw JSON from the phone:
{
"data": [
{
"Media Direction": "sendrecv",
"CallState": "Connected",
"Remote Connection IP": "1xx.xx.xxx.xx",
"Type": "Incoming",
"CallHandle": "ab8ea408",
"RTPPort": "2254",
"Ringing": "0",
"RemotePartyNumber": "sip:[email protected]",
"Muted": "0",
"RTCPPort": "2255",
"Protocol": "SIP",
"RemotePartyName": "xxxxxxx xxxxxxx",
"StartTime": "2025-01-30T16:58:37",
"UIAppearanceIndex": "1*",
"CallSequence": "1",
"LineID": "1",
"DurationSeconds": "3"
}
],
"Status": "2000"
}
Anyway, I’ll be thrilled if I can get just the text. I read this article that maybe gets me close with the split command, but when I try to split on @ I get a null string. Not sure if I can get crazy and include the for loop described in the stackoverflow article linked.
Right now my Ulanzi shows sip:[email protected] but I really just want +1aaabbbcccc.