Polycom Telephony Event Notification XML format?

Tags: #<Tag:0x00007f173b4d26b0> #<Tag:0x00007f173b4d25c0> #<Tag:0x00007f173b4d24f8>

I hope this is the right location for this Topic if not please let me know.
We are currently using a python script (outside of openHAB) to receive XML phone state changes, and post MQTT messages to a subscribed ESP8266 to sound a buzzer and flash a light when the phone rings.
I’m sure it’s possible to do this using openHAB but I don’t see a binding or any other method to make OH subscribe to XML notifications. Here is the python script we are using if it helps.
Anyone have any advice on how to do this in openHAB?

from waitress import serve
from pyramid.config import Configurator
from pyramid.response import Response
import xml.etree.ElementTree as ElementTree
import paho.mqtt.client as mqtt

def ip2ext(ip):
    return {'10.240.196.86': '2445',      # user
           }[ip]


def offHookHandler(elem):
    phoneip = elem.find('PhoneIP')
    try:
        ext = ip2ext(phoneip.text)
        return ext
    except KeyError:
        return None


def onHookHandler(elem):
    phoneip = elem.find('PhoneIP')
    try:
        ext = ip2ext(phoneip.text)
        return ext
    except KeyError:
        return None


def incomingCallHandler(elem):
    phoneip = elem.find('PhoneIP')
    try:
        ext = ip2ext(phoneip.text)
        return ext
    except KeyError:
        return None


def callStateChangeHandler(elem):
    phoneip = elem.find('PhoneIP')
    try:
        ext = ip2ext(phoneip.text)
        return ext
    except KeyError:
        return None


def catcher(request):
    # parse the XML sent by the phone
    root = ElementTree.fromstring(request.body)
    msg = ''
    # start the remote ringer if there is an IncomingCallEvent
    elem = root.find('IncomingCallEvent')
    if elem is not None:
        ext = incomingCallHandler(elem)
        if ext:
            msg = '1'
    # stop it if the phone is picked up
    elem = root.find('OffHookEvent')
    if elem is not None:
        ext = offHookHandler(elem)
        if ext:
            msg = '0'
    # alternatively stop it if the dialing party hangs up,
    elem = root.find('CallStateChangeEvent')
    state = ''
    if elem is not None:
        for child in root:
            state = child.attrib['CallState']
        if state == 'Disconnected':
            ext = callStateChangeHandler(elem)
            # ext is returned only if the state is 'Disconnected'
            if ext:
                msg = '0'
    # build a new MQTT Client (for each request)
    # This is not efficeint, but, over localhost and for a low demand
    # service, it should be fine
    if msg:
        client = mqtt.Client('Ringer')
        client.connect('127.0.0.1')
        client.loop()
        client.publish('ringer/' + ext, msg)
        client.disconnect()
    return Response('')

if __name__ == '__main__':
    with Configurator() as config:
        config.add_route('catcher', '/')
        config.add_view(catcher, route_name='catcher')
        app = config.make_wsgi_app()
    serve(app, host='0.0.0.0', port=8081)

There is an HTTP binding that allow to make http calls to retreive your XML, then there is a transformation service called XPATH to extract info from the XML then there is an MQTT binding that act as an MQTT client to send and received MQTT messages.

Welcome to OH!

Hi Vincent
Thanks for the response but the phone is sending the XML state of the phone. (onhook offhook statechange) The phone won’t provide XML state via HTTP calls. And I’m not sure how OH would know to make the http call to retrieve the XML when the phone rings. I did look into XPath and I think we are onto something their.
Can XPath be configured to receive XML then send the results to MQTT? I should probably mention I’ve been using OH as a security system for a couple years now so I do have some basic knowledge of OH but I’ve not tried using it as a XML decoder. Here is the setup on the Polycom phone explaining event notifications.

I don’t think OH can subscribe to urls like that but I may be wrong
There seem to a solution there:

But they are using python and scripting too…