I'm trying to set the point called "Preset001" with a well-defined Speed but I can't as I get the following error on console:
My camera's hostname: MYCAM
gotoPreset:
{
'ProfileToken': 'MainStreamProfileToken',
'PresetToken': 'Preset001',
'Speed': 0.1
}
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 140, in call
ret = func(**params)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/proxy.py", line 46, in __call__
return self._proxy._binding.send(
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 123, in send
envelope, http_headers = self._create(
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 73, in _create
serialized = operation_obj.create(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/definitions.py", line 222, in create
return self.input.serialize(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/messages/soap.py", line 79, in serialize
self.body.render(body, body_value)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
self._render_value_item(parent, value, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
return self.type.render(node, value, None, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 295, in render
element.render(node, element_value, child_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/indicators.py", line 251, in render
element.render(parent, element_value, child_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
self._render_value_item(parent, value, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
return self.type.render(node, value, None, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 295, in render
element.render(node, element_value, child_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/indicators.py", line 251, in render
element.render(parent, element_value, child_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
self._render_value_item(parent, value, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
return self.type.render(node, value, None, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 266, in render
attr_value = value[name] if name in value else NotSet
TypeError: argument of type 'float' is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 23, in wrapped
return func(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 153, in wrapped
return call(params, callback)
File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 143, in call
ret = func(params)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/proxy.py", line 46, in __call__
return self._proxy._binding.send(
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 123, in send
envelope, http_headers = self._create(
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 73, in _create
serialized = operation_obj.create(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/definitions.py", line 222, in create
return self.input.serialize(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/wsdl/messages/soap.py", line 79, in serialize
self.body.render(body, body_value)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
self._render_value_item(parent, value, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
return self.type.render(node, value, None, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/complex.py", line 295, in render
element.render(node, element_value, child_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/indicators.py", line 251, in render
element.render(parent, element_value, child_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 232, in render
self._render_value_item(parent, value, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/elements/element.py", line 256, in _render_value_item
return self.type.render(node, value, None, render_path)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/simple.py", line 96, in render
node.text = self.xmlvalue(value)
File "/home/pi/.local/lib/python3.9/site-packages/zeep/xsd/types/builtins.py", line 27, in _wrapper
raise ValueError(
ValueError: The ReferenceToken type doesn't accept collections as value
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/Script/onvif_test.py", line 35, in <module>
print(ptz.GotoPreset(request))
File "/home/pi/.local/lib/python3.9/site-packages/onvif/client.py", line 26, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: The ReferenceToken type doesn't accept collections as value
This is the Script that executes the Preset command (without setting the speed, this one command works perfectly):
#!/usr/bin/python3
from functions import *
from onvif import ONVIFCamera
mycam = ONVIFCamera('xxx.xxx.xxx.xxx', 8080, 'admin', 'password', '/home/pi/.local/lib/python3.4/site-packages/wsdl/')
# Get Hostname
resp = mycam.devicemgmt.GetHostname()
print("My camera's hostname: " str(resp.Name))
# Create media service object
media = mycam.create_media_service()
# Get target profile
media_profile = media.GetProfiles()[0]
#print(media_profile)
# Create ptz service object
ptz = mycam.create_ptz_service()
request = ptz.create_type('GotoPreset')
request.ProfileToken = media_profile.token
request.PresetToken = "Preset001"
request.Speed = 0.1
print("gotoPreset:")
print(request)
print(ptz.GotoPreset(request))
I am using the following "ONVIF Python LIbrary" on RaspberryPi 4.
- Would anyone know how to give me some advice?
- Where am I wrong?
Thanks to anyone!
CodePudding user response:
I have found the solution. The correct way to pass data is:
request.Speed = {'PanTilt': {'x': 0.1, 'y': 0.1}, 'Zoom': 0.1} # The camera seems to ignore the PanTilt and Zoom speeds I give it
Even if unfortunately my ptz does not go to the speed cge I tell him to go .. So this thing is useless .. : '(
Thanks anyway