FalkTannhaeuser / python-onvif-zeep

ONVIF Client Implementation in Python 2+3 (using https://github.com/mvantellingen/python-zeep instead of suds as SOAP client)
MIT License
424 stars 138 forks source link

create_type() doesn't return correct data structure #36

Open pitfisher opened 5 years ago

pitfisher commented 5 years ago

The following code is supposed to set parameters of RelayOutput:

params = mycam.devicemgmt.create_type('SetRelayOutputSettings')
params.RelayOutputToken = 'AlarmOut_0'
\# params.Properties.Mode = 'Bistable'
\# params.Properties.DelayTime = 'PT1S'
\# params.Properties.IdleState = 'closed'
params.Properties = {'Mode':'Bistable','DelayTime':'PT1S','IdleState':'closed'} this way doesn't work too
mycam.devicemgmt.SetRelayOutputSettings(params)
mycam.devicemgmt.SetRelayOutputState({'RelayOutputToken':'AlarmOut_0','LogicalState':'active'})

But it fails:

raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: Validation constraint violation: data type mismatch  in element 'ns2:DelayTime'

If I try explicit definition of SetRelayOutputSettings fields another error returned:

\>\>\> params.Properties.Mode = 'Bistable'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'Mode'
\>\>\> params.Properties.DelayTime = 'PT1S'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'DelayTime'
\>\>\> params.Properties.IdleState = 'closed'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'IdleState'

print(params) returns following:

\>\>\> print(params)
{
    'RelayOutputToken': None,
    'Properties': None
}

Which is pretty much different from what is returned by Python 2.7 version of library:

\>\>\> params = mycam.devicemgmt.create_type('SetRelayOutputSettings')
\>\>\> print(params)
(SetRelayOutputSettings){
   RelayOutputToken = None
   Properties =
      (RelayOutputSettings){
         Mode =
            (RelayMode){
               value = None
            }
         DelayTime = None
         IdleState =
            (RelayIdleState){
               value = None
            }
      }
 }

Also I tried to execute example with mycam.devicemgmt.create_type('SetSystemDateAndTime') and got the same kind of error. So I assume something is wrong with implementation of .create_type() function. Am I missing some difference between libraries for Python 2.7 and Python 3 or it's an error that should be fixed?