jheling / freeathome

Free@Home component for Home Assistant
112 stars 41 forks source link

debugging got stuck at rpc #24

Closed bartdorlandt closed 4 years ago

bartdorlandt commented 4 years ago

Hi Johan,

I was looking/learning/debugging some of your code and ran into the following:

INFO     Rpc callback jhe 
DEBUG    SEND: <iq id="b40ab916-62ec-4a9a-bb77-7ecff1df7e71-3" to="mrha@busch-jaeger.de/rpc" type="error"><error type="cancel"><undefined-condition xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Slixmpp got into trouble.</text></error></iq>
ERROR    Error handling {jabber:client}iq stanza
Traceback (most recent call last):
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/xmlstream/xmlstream.py", line 987, in _spawn_event
    handler.run(stanza)
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/xmlstream/handler/callback.py", line 76, in run
    self._pointer(payload)
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/stanza/iq.py", line 212, in callback_success
    callback(result)
  File "/home/bart/git/custom_components/get-master-message.py", line 162, in rpc_callback
    args = xml2py(iq['rpc_query']['method_response']['params'])
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/plugins/xep_0009/binding.py", line 95, in xml2py
    for param in params.findall('{%s}param' % namespace):
AttributeError: 'NoneType' object has no attribute 'findall'
ERROR    'NoneType' object has no attribute 'findall'
Traceback (most recent call last):
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/xmlstream/xmlstream.py", line 987, in _spawn_event
    handler.run(stanza)
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/xmlstream/handler/callback.py", line 76, in run
    self._pointer(payload)
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/stanza/iq.py", line 212, in callback_success
    callback(result)
  File "/home/bart/git/custom_components/get-master-message.py", line 162, in rpc_callback
    args = xml2py(iq['rpc_query']['method_response']['params'])
  File "/home/bart/git/custom_components/venv/lib/python3.6/site-packages/slixmpp/plugins/xep_0009/binding.py", line 95, in xml2py
    for param in params.findall('{%s}param' % namespace):
AttributeError: 'NoneType' object has no attribute 'findall'
ERROR    not-allowed: 
WARNING  You should catch IqError exceptions

This is part of the "def rpc_callback(self, iq):" method.

It seems your code is always expecting values to return in the 'iq', but apparently this is not the case for me. Both the 'fault' and 'params' dicts are empty, which is causing the issue.

Any ideas why this could happen?

jheling commented 4 years ago

Maybe the structure of the xml files have changed. I use Wireshark to see the Xmpp network messages. Or it is just a bug in the code ;-) I'm not yet a python expert.

bartdorlandt commented 4 years ago

You did quite the job for someone who isn't an expert. Thumbs up! I'm no expert either and I'm trying to get better using your project, therefor also learning xmpp. (I come from networking)

I'll have a more in depth look this weekend to see if I can understand what is going on. Thanks for all your effort thus far.

jheling commented 4 years ago

Closing some older issues ;-)