'Get Onvif events with Python from IP camera

I have an IP camera that sends motion events. With the Onvif Device Manager I can also see these events. However, I am failing to get these events with a Python script. Starting point is the Github project: https://github.com/FalkTannhaeuser/python-onvif-zeep

If I read it correctly from the documentation, first you have to execute a function called 'CreatePullPointSubscriptionRequest'. As a response you get 'CreatePullPointSubscriptionResponse'. Then you can execute the function 'PullMessagesRequest'.

Can someone send me a code snippet to register for an event (all or filtered) and then read the events?

This is what I have so far:

from onvif import ONVIFCamera
mycam = ONVIFCamera('192.168.0.2', 80, 'user', 'passwd', '/etc/onvif/wsdl/')

resp = mycam.devicemgmt.GetHostname()
print('My camera`s hostname: ' + str(resp.Name))

event_service = mycam.create_events_service()
print(event_service.GetEventProperties())

subscription = event_service.CreatePullPointSubscription()

pullpoint = mycam.create_pullpoint_service()
req = pullpoint.create_type('PullMessages') # Exception: No element 'PullMessages' in namespace http://docs.oasis-open.org/wsrf/rw-2. Available elements are:  - 
req.MessageLimit=100
print(pullpoint.PullMessages(req))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source