Ive done something with node red insted for my cisco phone spa525g2
[
{
"id": "df7cc7040f418ad7",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "3c5063f9e0ced665",
"type": "inject",
"z": "df7cc7040f418ad7",
"name": "Every 5sec",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Init",
"payloadType": "str",
"x": 480,
"y": 240,
"wires": [
[
"02407f719ab1c167"
]
]
},
{
"id": "212edf7c8190a22d",
"type": "xml",
"z": "df7cc7040f418ad7",
"name": "Covert the xml into an array",
"property": "payload",
"attr": "",
"chr": "",
"x": 1100,
"y": 240,
"wires": [
[
"7cd6d8f0448711ec"
]
]
},
{
"id": "7cd6d8f0448711ec",
"type": "change",
"z": "df7cc7040f418ad7",
"name": "",
"rules": [
{
"t": "set",
"p": "conditions",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1370,
"y": 240,
"wires": [
[
"328a807d4769cd70"
]
]
},
{
"id": "bfe23bc7151217d6",
"type": "function",
"z": "df7cc7040f418ad7",
"name": "is it ringing ?",
"func": "\n\n\n var findWhat = msg.payload;\n var conditions = msg.conditions;\n var callstate = msg.conditions.Status.Info[0].Line_1_Call_1_Status[0].Call_State[0];\n if (callstate != \"\")\n {\n msg.payload = callstate;\n\n return msg;\n \n }\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "// Code added here will be run once\n// whenever the node is started.\nvar loop_count=flow.get('loop') || {};\nif (loop_count==undefined)\n{\n loop_count=0;\n}",
"finalize": "",
"libs": [],
"x": 750,
"y": 380,
"wires": [
[
"e6fe5907d63c72bd"
]
]
},
{
"id": "328a807d4769cd70",
"type": "change",
"z": "df7cc7040f418ad7",
"name": "",
"rules": [
{
"t": "set",
"p": "conditions",
"pt": "msg",
"to": "conditions",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 380,
"wires": [
[
"bfe23bc7151217d6"
]
]
},
{
"id": "02407f719ab1c167",
"type": "http request",
"z": "df7cc7040f418ad7",
"name": "Read status page from the phone",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://192.168.21.101/admin/status.xml",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 780,
"y": 240,
"wires": [
[
"212edf7c8190a22d"
]
]
},
{
"id": "e6fe5907d63c72bd",
"type": "function",
"z": "df7cc7040f418ad7",
"name": "wich number is callilng",
"func": "var state = msg.payload\nloop_count = flow.get(\"loop\") || 0;\nnode.status({fill:\"red\",shape:\"ring\",text:loop_count});\nif (loop_count != 1)\n{\n if (state == \"Ringing\")\n {\n var conditions = msg.conditions;\n callerid = msg.conditions.Status.Info[0].Line_1_Call_1_Status[0].Peer_Phone[0];\n calleridname = msg.conditions.Status.Info[0].Line_1_Call_1_Status[0].Peer_Name[0]\n if (calleridname != \"\" )\n {\n if (calleridname != \"MONTREAL QC\")\n {\n msg.payload = calleridname\n flow.set(\"loop\",1);\n return msg;\n }\n else\n {\n callerid = callerid.split('').join(' ');\n msg.payload = callerid;\n flow.set(\"loop\",1);\n return msg;\n }\n }\n else if (callerid != \"\")\n {\n callerid = callerid.split('').join(' ');\n msg.payload = callerid;\n flow.set(\"loop\",1);\n return msg;\n }\n }\n} \n",
"outputs": 1,
"noerr": 0,
"initialize": "// Code added here will be run once\n// whenever the node is started.\nvar loop_count=flow.get('loop') || {};\nif (loop_count==undefined)\n{\n loop_count=0;\n}",
"finalize": "",
"libs": [],
"x": 1180,
"y": 380,
"wires": [
[
"cc9393475fddc11d"
]
]
},
{
"id": "cc9393475fddc11d",
"type": "api-call-service",
"z": "df7cc7040f418ad7",
"name": "",
"server": "92e9f953.cc4ed8",
"version": 3,
"debugenabled": true,
"service_domain": "tts",
"service": "cloud_say",
"entityId": "media_player.annonce_telephone",
"data": "{\"message\":\"Vous avez un appel de {{payload}}\"}",
"dataType": "json",
"mergecontext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"queue": "none",
"x": 1530,
"y": 360,
"wires": [
[
"9621e506944a98b1"
]
]
},
{
"id": "35c35e9bdb6335df",
"type": "function",
"z": "df7cc7040f418ad7",
"name": "Ré-initialiser Loop count a 0",
"func": "\nflow.set(\"loop\",0);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 480,
"wires": [
[]
]
},
{
"id": "9621e506944a98b1",
"type": "delay",
"z": "df7cc7040f418ad7",
"name": "",
"pauseType": "delay",
"timeout": "7",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 500,
"y": 480,
"wires": [
[
"35c35e9bdb6335df"
]
]
},
{
"id": "92e9f953.cc4ed8",
"type": "server",
"name": "Home Assistant 2020",
"version": 2,
"addon": false,
"rejectUnauthorizedCerts": false,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30"
}
]