jheling / freeathome

Free@Home component for Home Assistant
103 stars 37 forks source link

TypeError: 'NoneType' object is not an iterator #27

Closed bartdorlandt closed 4 years ago

bartdorlandt commented 4 years ago

Somewhere down the path the new version of HA is causing an issue. See the following from the log file.

The first part is just a warning that something could be improved (this is just a side note). If I find the time I can look into it and see if I can make the changes and send a pull request.

The latter part is the actual error where I noticed the slixmpp and thought of this plugin. This is the only custom_component that I'm using and of which I'm aware it is using slixmpp. So it could be this is nothing to do with the freeathome integration. But better safe than sorry I'm posting this here.

Hope you can replicate the issue or If I can assist in gathering some more details, than please let me know.

2019-12-13 23:02:58 WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.

2019-12-13 23:02:59 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 816, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received
    self._spawn_event(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__
    if self.setup(xml):
  File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values
    self[full_interface] = value
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__
    lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator
2019-12-13 23:03:08 WARNING (MainThread) [homeassistant.setup] Setup of freeathome is taking over 10 seconds.

Cheers.

bartdorlandt commented 4 years ago

Tested it with the new code updates and I still have the same issues. Before it was able to start up in some of the cases, now I just had a 1 time succes.

I enabled debug logs and got the following. I hope it can help you.

2019-12-26 21:45:02 INFO (MainThread) [custom_components.freeathome.pfreeathome] Connect Free@Home  cfd8a579-078b-4667-8b9b-98fdd9e82b28@busch-jaeger.de 
2019-12-26 21:45:02 INFO (MainThread) [custom_components.freeathome.pfreeathome]  version: 2.4.0
2019-12-26 21:45:02 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connecting
2019-12-26 21:45:02 INFO (MainThread) [custom_components.freeathome.pfreeathome] wait for connection

2019-12-26 21:45:03 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  A records: (1, 'DNS server returned answer with no data')
2019-12-26 21:45:03 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connected
 2019-12-26 21:45:03 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <stream:stream to='busch-jaeger.de' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
2019-12-26 21:45:03 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream id="tinyxmppd449377" from="busch-jaeger.de" xml:lang="en" version="1.0">
2019-12-26 21:45:03 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 816, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received
    self._spawn_event(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__
    if self.setup(xml):
  File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values
    self[full_interface] = value
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__
    lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator

I'm trying to see if there is a conflict somewhere. I'll keep you updated.

bartdorlandt commented 4 years ago

Below is some output when it is "good" and "fault".


GOOD:

2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connecting
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for AAAA records.
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  AAAA records: (1, 'DNS server returned answer with no data')
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for A records.
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  A records: (1, 'DNS server returned answer with no data')
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connected
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <stream:stream to='busch-jaeger.de' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream id="tinyxmppd449622" from="busch-jaeger.de" xml:lang="en" version="1.0">
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:features xmlns="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>SCRAM-SHA-256</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="SCRAM-SHA-1">biwsbj1jZmQ4YTU3OS0wNzhiLTQ2NjctOGI5Yi05OGZkZDllODJiMjgscj0zMTUwMDQ1Mzc3NjYyNzcx</auth>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cj0zMTUwMDQ1Mzc3NjYyNzcxSVVDK3N5SWZaQW89LHM9Y3A4N1hOV0RFejJjdnJ3a3pHcFIwY1EveFIrT1JJTWJ1cHlYUndHeTB4Yz0saT0xMDAwMA==</challenge>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">Yz1iaXdzLHI9MzE1MDA0NTM3NzY2Mjc3MUlVQytzeUlmWkFvPSxwPW14UHNGUUFUcXo2VkNvRW5VUnF0TnZubWdoMD0=</response>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dj1Ja1RpUGQ1MVlDemJVZi9maVlwWUlQeFlqNVU9</success>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: auth_success
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <stream:stream to='busch-jaeger.de' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream id="tinyxmppd449623" from="busch-jaeger.de" xml:lang="en" version="1.0">
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:features xmlns="http://etherx.jabber.org/streams"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><required /></bind></stream:features>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <iq id="890eba25-a8a3-464a-a854-03b753b3cc29-1" type="set"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>44100401</resource></bind></iq>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <iq id="890eba25-a8a3-464a-a854-03b753b3cc29-1" type="result"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>cfd8a579-078b-4667-8b9b-98fdd9e82b28@busch-jaeger.de/44100401</jid></bind></iq>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: session_bind
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: session_start
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: stream_negotiated
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <iq id="890eba25-a8a3-464a-a854-03b753b3cc29-2" type="set" to="mrha@busch-jaeger.de/rpc"><query xmlns="jabber:iq:rpc"><methodCall><methodName>RemoteInterface.cryptExchangeLocalKeys2</methodName><params><param><value><string>cfd8a579-078b-4667-8b9b-98fdd9e82b28@busch-jaeger.de</string></value></param><param><value><base64>gTqnnl9FDNAjUlaoVQdGC2bgpgmUS69/B5XnS/5FpFFmnplMePs8kTG+6oYM3dGAcb8qJzEmuEpwuwl8ebbAGA==</base64></value></param><param><value><string>SCRAM-SHA-256</string></value></param><param><value><i4>0</i4></value></param></params></methodCall></query></iq>
2019-12-26 22:07:24 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <iq from="mrha@busch-jaeger.de/rpc" id="890eba25-a8a3-464a-a854-03b753b3cc29-2" to="cfd8a579-078b-4667-8b9b-98fdd9e82b28@busch-jaeger.de/44100401" type="result"><query xmlns="jabber:iq:rpc"><methodResponse><params><param><value><base64>AgAAAAAAAADEnNJ+1EMOD2TfiqgznqaKjmkBI7TPiShCjOoFoxdtYCQAAABkYmFjNTI1Mi01MmM1LTRmNmItOTEzZi1iYjMyNWVlMWJkMGGDCQAAewogICJmbGFncyIgOiB7CiAgICJ2ZXJzaW9uIiA6IjIuNC4wIiwKICAgImJ1aWxkIiA6Ijc1ODYiLAogICAic2Vzc2lvbklkIiA6IjJiNGMwMTA2IiwKICAgImxvY2FsZSIgOiJlbiIsCiAgICJsb2dnaW5nIiA6ZmFsc2UsCiAgICJuYW1lIiA6IkRvcmxhbmR0IiwKICAgInNlcmlhbE51bWJlciIgOiJBQkI3MDBEMzdGRkEiLAogICAiYWJiIiA6ZmFsc2UsCiAgICJhdXRvUmVwb3J0IiA6dHJ1ZSwKICAgImhhcmR3YXJlVmVyc2lvbiIgOiI2NTUzNiIsCiAgICJzaG93V2l6YXJkIiA6ZmFsc2UKICB9LAoKICAiYmxhY2tsaXN0IiA6IHsKICAgICJtc2h0bWwiIDogWwogICAgICI7PD0xMSIKICAgIF0sCiAgICAiZ2Vja28iIDogWwogICAgICI+PTQxOzw0MyIKICAgIF0KICB9LAoKICAidXNlcnMiIDogWwogICAgewogICAgICJuYW1lIjogImFwaSIsCiAgICAgInJvbGUiOiAic3dpdGNoIiwKICAgICAiamlkIjogImNmZDhhNTc5LTA3OGItNDY2Ny04YjliLTk4ZmRkOWU4MmIyOEBidXNjaC1qYWVnZXIuZGUiLAogICAgICJpbml0aWFsIjogImZhbHNlIiwKICAgICAiZW5hYmxlZCI6ICJ0cnVlIiwKICAgICAiYXV0aG1ldGhvZHMiOiB7CiAgICAgICJTQ1JBTS1TSEEtMSI6IHsgIml0ZXJhdGlvbnMiOiAxMDAwMCwgInNhbHQiOiAiY3A4N1hOV0RFejJjdnJ3a3pHcFIwY1EveFIrT1JJTWJ1cHlYUndHeTB4Yz0iIH0sCiAgICAgICJTQ1JBTS1TSEEtMjU2IjogeyAiaXRlcmF0aW9ucyI6IDEwMDAwLCAic2FsdCI6ICJjcDg3WE5XREV6MmN2cndrekdwUjBjUS94UitPUklNYnVweVhSd0d5MHhjPSIgfQogICAgIH0KICAgIH0sCiAgICB7CiAgICAgIm5hbWUiOiAiamVubmlmZmVyIiwKICAgICAicm9sZSI6ICJpbnN0YWxsIiwKICAgICAiamlkIjogIjlkZjkyODZjLTI0YzItNDgwOC05ZDBiLWFjMjczMDc0ZmY3OEBidXNjaC1qYWVnZXIuZGUiLAogICAgICJpbml0aWFsIjogImZhbHNlIiwKICAgICAiZW5hYmxlZCI6ICJ0cnVlIiwKICAgICAiYXV0aG1ldGhvZHMiOiB7CiAgICAgICJTQ1JBTS1TSEEtMSI6IHsgIml0ZXJhdGlvbnMiOiAxMDAwMCwgInNhbHQiOiAiaElIbExLckpGbEE1RFh4VHRrSFVDNmZhaTJYdFVQSkVjVzczTXhFVEtEaz0iIH0sCiAgICAgICJTQ1JBTS1TSEEtMjU2IjogeyAiaXRlcmF0aW9ucyI6IDEwMDAwLCAic2FsdCI6ICJoSUhsTEtySkZsQTVEWHhUdGtIVUM2ZmFpMlh0VVBKRWNXNzNNeEVUS0RrPSIgfQogICAgIH0KICAgIH0sCiAgICB7CiAgICAgIm5hbWUiOiAiSW5zdGFsbGF0ZXVyIiwKICAgICAicm9sZSI6ICJpbnN0YWxsIiwKICAgICAiamlkIjogImluc3RhbGxlckBidXNjaC1qYWVnZXIuZGUiLAogICAgICJpbml0aWFsIjogImZhbHNlIiwKICAgICAiZW5hYmxlZCI6ICJ0cnVlIiwKICAgICAiYXV0aG1ldGhvZHMiOiB7CiAgICAgICJTQ1JBTS1TSEEtMSI6IHsgIml0ZXJhdGlvbnMiOiAxMDAwMCwgInNhbHQiOiAiSExqQXRNSit5ZUtaTXE1eVFRa0NpZnVLSTBhdlFxOHgxb2RhUnU5dmdmOD0iIH0sCiAgICAgICJTQ1JBTS1TSEEtMjU2IjogeyAiaXRlcmF0aW9ucyI6IDEwMDAwLCAic2FsdCI6ICJITGpBdE1KK3llS1pNcTV5UVFrQ2lmdUtJMGF2UXE4eDFvZGFSdTl2Z2Y4PSIgfQogICAgIH0KICAgIH0sCiAgICB7CiAgICAgIm5hbWUiOiAiYXBpX3Rlc3QiLAogICAgICJyb2xlIjogInN3aXRjaCIsCiAgICAgImppZCI6ICI3Zjk1YTQxZi1jN2Q0LTRmNTgtYmE2Ny1iYjYyMTYyYzgzYzZAYnVzY2gtamFlZ2VyLmRlIiwKICAgICAiaW5pdGlhbCI6ICJmYWxzZSIsCiAgICAgImVuYWJsZWQiOiAidHJ1ZSIsCiAgICAgImF1dGhtZXRob2RzIjogewogICAgICAiU0NSQU0tU0hBLTEiOiB7ICJpdGVyYXRpb25zIjogMTAwMDAsICJzYWx0IjogIndzVDRWYjlzWlJIdkNQclM1bFlWY3I3M1RUdktodHM0R2E2dnRwdUk5SWc9IiB9LAogICAgICAiU0NSQU0tU0hBLTI1NiI6IHsgIml0ZXJhdGlvbnMiOiAxMDAwMCwgInNhbHQiOiAid3NUNFZiOXNaUkh2Q1ByUzVsWVZjcjczVFR2S2h0czRHYTZ2dHB1STlJZz0iIH0KICAgICB9CiAgICB9LAogICAgewogICAgICJuYW1lIjogImJhcnQiLAogICAgICJyb2xlIjogImluc3RhbGwiLAogICAgICJqaWQiOiAiMWRiOTJiODUtYjQyNy00ZTc2LWFmOTktZmEzODczZGQ0NmZlQGJ1c2NoLWphZWdlci5kZSIsCiAgICAgImluaXRpYWwiOiAiZmFsc2UiLAogICAgICJlbmFibGVkIjogInRydWUiLAogICAgICJhdXRobWV0aG9kcyI6IHsKICAgICAgIlNDUkFNLVNIQS0xIjogeyAiaXRlcmF0aW9ucyI6IDEwMDAwLCAic2FsdCI6ICJqdkFOYnV1Q3ErN3NONEViT2hKeC9qbm5wbXF0Q3pKZnJRM2IrckVVclFFPSIgfSwKICAgICAgIlNDUkFNLVNIQS0yNTYiOiB7ICJpdGVyYXRpb25zIjogMTAwMDAsICJzYWx0IjogImp2QU5idXVDcSs3c040RWJPaEp4L2pubnBtcXRDekpmclEzYityRVVyUUU9IiB9CiAgICAgfQogICAgfQogIF0KfQrUXbNWjA/XRvrASZZ5jND6bFADivP9RoqE7kHgAHJxfg==</base64></value></param></params></methodResponse></query></iq>

FAULT:

2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connecting
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for AAAA records.
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  AAAA records: (1, 'DNS server returned answer with no data')
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for A records.
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  A records: (1, 'DNS server returned answer with no data')
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connected
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <stream:stream to='busch-jaeger.de' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream id="tinyxmppd449738" from="busch-jaeger.de" xml:lang="en" version="1.0">
2019-12-26 22:14:20 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 816, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received
    self._spawn_event(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__
    if self.setup(xml):
  File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values
    self[full_interface] = value
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__
    lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator
2019-12-26 22:14:20 INFO (MainThread) [slixmpp.xmlstream.xmlstream] connection_lost: (TypeError("'NoneType' object is not an iterator"),)
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: disconnected
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Tried to cancel unscheduled event: Whitespace Keepalive
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Tried to cancel unscheduled event: Disconnect wait
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: session_end
2019-12-26 22:14:20 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Tried to cancel unscheduled event: Ping keepalive
bartdorlandt commented 4 years ago

Could this be a race condition somewhere, since it is working sometimes? For what it's worth, I'm running HA inside a docker.

fotiDim commented 4 years ago

I am currently running Hassio under Hyper-V on Windows 10. I am having the same issue:

2019-12-27 11:21:48 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for freeathome which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-12-27 11:21:49 WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.
2019-12-27 11:21:50 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 816, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received
    self._spawn_event(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__
    if self.setup(xml):
  File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values
    self[full_interface] = value
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__
    lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator
jheling commented 4 years ago

When I Google on "TypeError: 'NoneType' object is not an iterator slixmpp" , I see more homeassistant slixmpp implementations with this error. I'm using two raspberry pi's , one for test and one for production and have not seen this error before. Maybe it happens on specific platforms.

fotiDim commented 4 years ago

I am currently running Hassio under Hyper-V on Windows 10. @bartdorlandt what is your setup?

jeroen84 commented 4 years ago

Having the same issue, seems to be occur at random moments during startup. Do not know how to reproduce this...

This happens in both of my setups: Hass.io on a RPI3, and using a Docker container.

miezie commented 4 years ago

This is an issue in a HomeAssistant core component. Nothing really to do with the component... and also not causing malfunctioning I guess?

dbrouwer1979 commented 4 years ago

It causes malfunctioning. As said, it happens at random. When it happens, frontpage of HA doesn't load on restart

miezie commented 4 years ago

It doesn't happen that random. Only during startup, a restart fixes it (or multiple).

One my way home today I will dive into the code at the moment where the component ends up in the 10 second loop during initialization. Then it just should start the init again. This should fix it.

jeroen84 commented 4 years ago

@miezie you are correct, this happens at startup and results in, what it seems like, an indefinite loop. This causes HA frontpage to not load.

Your approach seems to make sense. Hope this works.

dbrouwer1979 commented 4 years ago

@miezie First of all, thank you for working on a solution. I tried it, but it didn't work for me. In the log-files I see the reconnect attempts, but still does not connect. Maybe I did something wrong...

dbrouwer1979 commented 4 years ago

Hi @miezie I tried loading FAH with your forked component. Still no luck connecting, it keeps reconnecting. Strange thing is, it seems to connect at first as it return version number of my SysAp in the log. After that it tries to reconnect. I can send you my log file if needed. dbrouwer1979 google email

miezie commented 4 years ago

No worries, I can reproduce it.. will fix it. But can take a bit of time :).

miezie commented 4 years ago

Okay, did a deep dive... What happens after the error in the iterator is that the XMPP client disconnects. See the connection_lost info logging. I am trying quite a lot to fix it... but since Python is not my main programming language I'm not there yet :). If somebody knows how to implement a reconnect after a "disconnected" event in the XMPP client. Feel free.

jeroen84 commented 4 years ago

@miezie: I managed to get a reconnect after a 'disconnect' event, as a result of testing to get a workaround regarding an older issue (https://github.com/jheling/freeathome/issues/18). I have not pushed this further given that 'keepalive' ping resolved the issue.

However, I still have the code available in an old fork, see https://github.com/jeroen84/freeathome/blob/vsdev/custom_components/pfreeathome.py

Note that this is based on an older version of this repository. But perhaps that this could help you further.

In any case, if you need assistance, let me know.

miezie commented 4 years ago

Will implement and test it. Just the approach which I wanted to implement :-). Thanks.

miezie commented 4 years ago

Meh, it doesn't fix it. When I force the reconnecting the same stracktrace keeps popping up. Also some workarounds I bumped upon and tried are not working.

Several hard restarts seems to be the only work-around right now.

fotiDim commented 4 years ago

Hard restart is a bit hard for me and I bet for others as well. My machine is tucked away and I need to use another computer and remote desktop to it to be able to hard restart the VM. Is there a way at least to make only the Free@home integration fail and not the entire web GUI? That way we would still be able to restart as many times as needed through hass.io?

miezie commented 4 years ago

Yes, the blocking wait on connecting can be reconfigured. I will make a change and pull request for that.

For the rest it makes way more sense to wait for potential Hass core fixes.

jeroen84 commented 4 years ago

@miezie: how do you reproduce the error? I cannot manage to get the error each time I start home assistant (in a Docker environment); it sometimes does, sometimes does not...

miezie commented 4 years ago

Sometimes it reproduces, sometimes not... :-) the difference I think is the loading order per time

jheling commented 4 years ago

Looking at the Traceback of the error, the error seems to start with a xml message. I'm very curious if there is something wrong with the structure of this message. Is anybody able to put the following code in the source slimxmpp/xmlstream/xmlstream.py at line 965?

xmlmessage = ET.tostring(xml, encoding='unicode') log.info("xml message: %s", xmlmessage)

miezie commented 4 years ago

You can fork Slixmpp, make the change and put in all the components your version as requirement... see: https://developers.home-assistant.io/docs/en/0.81.0/creating_component_deps_and_reqs.html. Like this: REQUIREMENTS = ['https://github.com/jabesq/pybotvac/archive/v0.0.5.zip#pybotvac==0.0.5']

miezie commented 4 years ago

And the XML is in this reply of Bart: https://github.com/jheling/freeathome/issues/27#issuecomment-569134980

jheling commented 4 years ago

Looking at the code in xmlstream.py , the log.debug('RECV: that appears in Barts logging is orginating from the "if event == 'start':" part. In the " if event == 'end':" part you see the call of the self._spawn_event(xml) that is also in the traceback. There is some other xml that is causing the error.

jeroen84 commented 4 years ago

I managed to get the xml message suggested by @jheling. I did this at line 406 of slimxmpp/xmlstream/xmlstream.py; that seems to be the point right before the error occurs.

I have two logs: one with a successful connection, and one with a failed one. Can any of you make sense of the logs? It seems like the 'xml message' is identical in both situations.

Successful:

2020-01-07 13:43:52 INFO (MainThread) [custom_components.freeathome.pfreeathome] Connect Free@Home  583e9723-4a80-4747-b989-bb0b2de10121@busch-jaeger.de 
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6120: Stream Feature: STARTTLS
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6120: Stream Feature: Resource Binding
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 3920: Stream Feature: Start Session
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6121: Stream Feature: Roster Versioning
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6121: Stream Feature: Subscription Pre-Approval
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6120: Stream Feature: SASL
2020-01-07 13:43:52 INFO (MainThread) [custom_components.freeathome.pfreeathome]  version: 2.4.0
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0030: Service Discovery
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0131: Stanza Headers and Internet Metadata
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0082: XMPP Date and Time Profiles
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0004: Data Forms
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0060: Publish-Subscribe
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0199: XMPP Ping
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connecting
2020-01-07 13:43:52 INFO (MainThread) [custom_components.freeathome.pfreeathome] wait for connection
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for AAAA records.
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  AAAA records: (1, 'DNS server returned answer with no data')
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for A records.
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  A records: (1, 'DNS server returned answer with no data')
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connected
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <stream:stream to='busch-jaeger.de' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream id="tinyxmppd1918770" from="busch-jaeger.de" xml:lang="en" version="1.0">
2020-01-07 13:43:52 INFO (MainThread) [slixmpp.xmlstream.xmlstream] xml message: <ns0:features xmlns:ns0="http://etherx.jabber.org/streams" xmlns:ns1="urn:ietf:params:xml:ns:xmpp-sasl"><ns1:mechanisms><ns1:mechanism>SCRAM-SHA-256</ns1:mechanism><ns1:mechanism>SCRAM-SHA-1</ns1:mechanism><ns1:mechanism>DIGEST-MD5</ns1:mechanism></ns1:mechanisms></ns0:features>
2020-01-07 13:43:52 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:features xmlns="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>SCRAM-SHA-256</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms></stream:features>

Failed:

2020-01-07 13:38:28 WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.
2020-01-07 13:38:28 INFO (MainThread) [custom_components.freeathome.pfreeathome] Connect Free@Home  583e9723-4a80-4747-b989-bb0b2de10121@busch-jaeger.de 
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6120: Stream Feature: STARTTLS
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6120: Stream Feature: Resource Binding
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 3920: Stream Feature: Start Session
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6121: Stream Feature: Roster Versioning
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6121: Stream Feature: Subscription Pre-Approval
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: RFC 6120: Stream Feature: SASL
2020-01-07 13:38:28 INFO (MainThread) [custom_components.freeathome.pfreeathome]  version: 2.4.0
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0030: Service Discovery
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0082: XMPP Date and Time Profiles
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0004: Data Forms
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0131: Stanza Headers and Internet Metadata
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0060: Publish-Subscribe
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.plugins.base] Loaded Plugin: XEP-0199: XMPP Ping
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connecting
2020-01-07 13:38:28 INFO (MainThread) [custom_components.freeathome.pfreeathome] wait for connection
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for AAAA records.
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  AAAA records: (1, 'DNS server returned answer with no data')
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Querying  for A records.
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.resolver] DNS: Exception while querying for  A records: (1, 'DNS server returned answer with no data')
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: connected
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] SEND: <stream:stream to='busch-jaeger.de' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' xml:lang='en' version='1.0'>
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] RECV: <stream:stream id="tinyxmppd1918726" from="busch-jaeger.de" xml:lang="en" version="1.0">
2020-01-07 13:38:28 INFO (MainThread) [slixmpp.xmlstream.xmlstream] xml message: <ns0:features xmlns:ns0="http://etherx.jabber.org/streams" xmlns:ns1="urn:ietf:params:xml:ns:xmpp-sasl"><ns1:mechanisms><ns1:mechanism>SCRAM-SHA-256</ns1:mechanism><ns1:mechanism>SCRAM-SHA-1</ns1:mechanism><ns1:mechanism>DIGEST-MD5</ns1:mechanism></ns1:mechanisms></ns0:features>
2020-01-07 13:38:28 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 816, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 408, in data_received
    self._spawn_event(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 972, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 953, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__
    if self.setup(xml):
  File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values
    self[full_interface] = value
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__
    lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator
2020-01-07 13:38:28 INFO (MainThread) [slixmpp.xmlstream.xmlstream] connection_lost: (TypeError("'NoneType' object is not an iterator"),)
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: disconnected
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Tried to cancel unscheduled event: Whitespace Keepalive
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Tried to cancel unscheduled event: Disconnect wait
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Event triggered: session_end
2020-01-07 13:38:28 DEBUG (MainThread) [slixmpp.xmlstream.xmlstream] Tried to cancel unscheduled event: Ping keepalive
2020-01-07 13:38:29 INFO (MainThread) [custom_components.freeathome.pfreeathome] wait for connection
miezie commented 4 years ago

Looking at the fact that all data is valid (which is no surprise to me) I get the feeling that the processing is not thread safe. I will again dive into it. While looking in how other components work I noticed that the initialization could be matured a bit maybe.

Helldin commented 4 years ago

any news abaut this issue? I have the same errors on a fresh install of HA but on the old HA i have its working good so i import the old custum_componets of FH and i have the same issue.

2020-02-15 13:35:08 WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one. 2020-02-15 13:35:18 WARNING (MainThread) [homeassistant.setup] Setup of volvooncall is taking over 10 seconds. 2020-02-15 13:35:18 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed. Traceback (most recent call last): File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 826, in _read_ready__data_received self._protocol.data_received(data) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received self._spawn_event(xml) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event stanza = self._build_stanza(xml) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza stanza = stanza_type(self, xml) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__ ElementBase.__init__(self, xml, parent) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__ if self.setup(xml): File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup self.values = self.values File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values self[full_interface] = value File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__ lang=lang) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text return self._del_sub(name, lang=lang) File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub parent = self.xml.find(parent_path) File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find return ElementPath.find(self, path, namespaces) File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find return next(iterfind(elem, path, namespaces), None) TypeError: 'NoneType' object is not an iterator 2020-02-15 13:35:18 WARNING (MainThread) [homeassistant.setup] Setup of freeathome is taking over 10 seconds.

jheling commented 4 years ago

I recently googled on this error. It seems to happen when are more integrations in your HA environment that are using slixmpp. Does anybody know more integrations, besides the free@home integration, that is also using slixmpp? I know one , the ha-nefit-ng integration .

Some users added the slixmpp source tree to the custom_components, in some case this seems to help: https://github.com/home-assistant/home-assistant/issues/28611 There is a pull request in the slixmpp repository which could be the solution, but there are some doubts: https://github.com/poezio/slixmpp/pull/17

miezie commented 4 years ago

Some users added the slixmpp source tree to the custom_components, in some case this seems to help: [home-assistant/home-assistant#28611](https://github.com/home-assistant/home-assistant/issues/28611

This is not really a solution... duplicating libs etc

There is a pull request in the slixmpp repository which could be the solution, but there are some doubts: poezio/slixmpp#17

This doesn’t work. I tried it... it introduces other issues.

What we need to do (but haven’t had the time yet) is making this component more work like a normal ha component and use the component loading of ha with all the threading etc. Then it isn’t blocking anymore and... we can use the retry mechanisms from ha.

thundergreen commented 4 years ago

I hope we will find a solution for this xmpp component. maybe we can use another library to build this xmpp component new?

jheling commented 4 years ago

I am now also experiencing the Nonetype error. By placing log.info messages in slixmpp and patching some procedures, it looks like I have found a possible fix for the error.

First step was placing a copy of slixmpp on my raspberry pi. The custom_components directory did not work for me. By printing the sys.path in the freeathome/init.py, i got the following path:

['/config/deps/lib/python3.7/site-packages', '/config', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages', '/usr/src/homeassistant']

So I placed the slixmpp source tree in deps\lib\python3.7\site-packages, deps is at the same level as the configuration.yaml .

The first modification I made was in slixmpp/xmlstream/stanzabase.py. At line 1040 is the line:

parent = self.xml.find(parent_path)

I replaced it with this:

if parent_path == '':
   parent_path = None   
if parent_path is not None:     
    parent = self.xml.find(parent_path) 

After that the NoneType error was gone. But there appeared another error in the home-assistant.log: TypeError: append() argument must be xml.etree.ElementTree.Element, not Element

It took some googeling but I found the following: https://stackoverflow.com/questions/16467640/python-etree-parser-isnt-appending-an-element

In searching the slixmpp tree , I found two sources that where using the old cElementTree: slixmpp\plugins\xep_0009\stanza\RPC.py slixmpp\xmlstream\stanzabase.py

In both sources, I replaced 'from xml.etree import cElementTree as ET' with 'import xml.etree.ElementTree as ET'. After that everything was working well in home-assistant.

thundergreen commented 4 years ago

might this also fix xmpp platform in hass?

btw.. my xmpp component started working again this night .. out off sudden

jheling commented 4 years ago

I hope so. It was a bit strange that the problem was solved with a few lines of code. So I need some confirmation that it also works for other installations.

thundergreen commented 4 years ago

do u have a short wiki how-to .. how to setup the xmpp platform now? i still use custom_component for xmpp and it works from time to time ...

jheling commented 4 years ago

What is the platform you use for running homeassistant? In some configurations you can patch the original slixmpp sources. In my case I had to create a separate folder with the whole slixmpp source tree and the patches as I described above.

miezie commented 4 years ago

Is it possible to deliver it via a branch for testing? Then I can easily implement it... :)

And then you can create a request at the maintainers of the code to fix it :)

jheling commented 4 years ago

I have uploaded the modified sources to my fork of slixmpp:

thundergreen commented 4 years ago

So i use what as source? which link to put in my manifest file in hass?

thundergreen commented 4 years ago

like this:

{
  "domain": "xmpp",
  "name": "Jabber (XMPP)",
  "documentation": "https://www.home-assistant.io/integrations/xmpp",
  "requirements": ["https://github.com/jheling/slixmpp/archive/slix-1.4.2.zip"],
  "dependencies": [],
  "codeowners": ["@fabaff", "@flowolf"]
}
jheling commented 4 years ago

The requirements should probably be https://github.com/jheling/slixmpp/archive/master.zip as my changes are not yet in a release point. I have just uploaded slixmpp\xmlstream\stanzabase.py again because it contained a typo.

EnricoBilla commented 4 years ago

I am now also experiencing the Nonetype error. By placing log.info messages in slixmpp and patching some procedures, it looks like I have found a possible fix for the error.

First step was placing a copy of slixmpp on my raspberry pi. The custom_components directory did not work for me. By printing the sys.path in the freeathome/init.py, i got the following path:

['/config/deps/lib/python3.7/site-packages', '/config', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages', '/usr/src/homeassistant']

So I placed the slixmpp source tree in deps\lib\python3.7\site-packages, deps is at the same level as the configuration.yaml .

The first modification I made was in slixmpp/xmlstream/stanzabase.py. At line 1040 is the line:

parent = self.xml.find(parent_path)

I replaced it with this:

if parent_path == '':
   parent_path = None     
if parent_path is not None:     
    parent = self.xml.find(parent_path) 

After that the NoneType error was gone. But there appeared another error in the home-assistant.log: TypeError: append() argument must be xml.etree.ElementTree.Element, not Element

It took some googeling but I found the following: https://stackoverflow.com/questions/16467640/python-etree-parser-isnt-appending-an-element

In searching the slixmpp tree , I found two sources that where using the old cElementTree: slixmpp\plugins\xep_0009\stanza\RPC.py slixmpp\xmlstream\stanzabase.py

In both sources, I replaced 'from xml.etree import cElementTree as ET' with 'import xml.etree.ElementTree as ET'. After that everything was working well in home-assistant.

I'm using Home Assistant with Docker, I edited the files in /usr/local/lib/python3.7/site-packages/slixmpp as you've pointed out. I did some restarts and it worked perfectly all the times, the error never showed up! Now HA has been up and running for some hours and everything works fine, hope this could be the final solution.

jheling commented 4 years ago

@EnricoBilla Nice that it works for you. @thundergreen. Did you manage to get the patched slixmpp sources in your environment?

miezie commented 4 years ago

Merge request accepted. Now the adjusted lib is referenced from the component and editing manifests is not necessary. :)

thundergreen commented 4 years ago

@miezie what u mean? My xmpp still does not work after upgrading to latest relaese of hass

miezie commented 4 years ago

@miezie what u mean? My xmpp still does not work after upgrading to latest relaese of hass

Upgrade this component. Not hass. This component now imports the by @jheling modified xmpp library by default.

thundergreen commented 4 years ago

and i can use the xmpp platform then.. because i don't need your custom pomponent but xmpp :)

miezie commented 4 years ago

No. Here we only care about this specific free@home custom component.. Not your XMPP platform.

thundergreen commented 4 years ago

well u made a slixmpp change and added this in your init.py ... so i use this install of slixmpp but somehow xmpp does not fire at all :P manually send messages just won't do anything.. no error nothing in lgs but setting up platform is annoonced

talig about this https://github.com/jheling/slixmpp/archive/master.zip#slixmpp==1.4.2.1