core: XMPP component not working after upgrading to 0.87

Home Assistant release with the issue:

0.87

Last working Home Assistant release (if known): 0.86.4

Operating environment (Hass.io/Docker/Windows/etc.):

venv install

Component/platform:

https://www.home-assistant.io/components/notify.xmpp/

Description of problem:

notify XMPP not longer working after upgrading from 0.86.4 to 0.87–> See Traceback attached

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

notify:
  - name: thorsten
    platform: xmpp 
    host: 192.168.1.100
    port: 5222
    sender: home-assistant@emevth.no-ip.biz 
    password: xxxxxxxxxxxxxxxxxxxxxx
    recipient: thorsten@emevth.no-ip.biz
    tls: true

Traceback (if applicable):

2019-02-08 10:41:01 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _SelectorSocketTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/usr/lib/python3.6/asyncio/selector_events.py", line 732, in _read_ready
    self._protocol.data_received(data)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received
    self._spawn_event(xml)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/stanzabase.py", line 1389, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/stanzabase.py", line 415, in __init__
    if self.setup(xml):
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/stanzabase.py", line 614, in _set_stanza_values
    self[full_interface] = value
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/stanzabase.py", line 752, in __setitem__
    lang=lang)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/stanzabase.py", line 958, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/stanzabase.py", line 1039, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/lib/python3.6/xml/etree/ElementTree.py", line 298, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/lib/python3.6/xml/etree/ElementPath.py", line 298, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator

Additional information:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 72 (24 by maintainers)

Commits related to this issue

Most upvoted comments

@thundergreen Just tested your custom_component approach and it is working without any problems. The same code starts working, when beeing used in a custom component …really weird and I guess @mariohock’s race condition assumption could be correct.

slixmpp has been updated recently (now at 1.5.1), and now includes a fix that should take care of this problem.

Here is a potential workaround:

I implemented a proof-of-concept app for Home-Assistant’s AppDaemon that allows bidirectional XMPP communications. It can also work as a replacement for the notify/jabber service of Home-Assistant discussed above.

https://github.com/mariohock/Chatty

Advantages:

  • Works with unpatched slixmpp library (at least for me…?)
  • Allows bidirectional communications. Chat with your home automation!
  • Faster message delivery, since it establishes a permanent connection to the XMPP server, instead of logging in and out for every single message
  • Works as drop-in replacement for the original notify/jabber service for AppDaemon apps
  • Simple: below 100 lines of code

[Potential] Disadvantages:

  • Needs AppDaemon (version 4!) (no issue, if you use it anyway)
  • Only proof-of-concept implementation, lacks some features from the original notify/jabber service
  • Cannot be called as a service from Home-Assistant (only from within AppDaemon), but from Home-Assistant can be called by a custom event

I dunno why this always appears… for me almost each upgrade of homeassistant will break the component. Then… all of sudden and after multiple restarts and longer times of running home assistant it works again. But i fear that some messages won’t be sent from time to time. I am missing some messages… Unfortunately nothing moves here in this threat and also on xmpp dev site nothing moves really forward. IT’s a bit a pity as i thought home assistant i privacy orientated and i refuse using whatsapp telegram and co for my sensitive data sent by a notifier.

Would be really awesome not only to library issue threats but also get in contact with them and try solving this issue together.

You could copy the original component and install it as a custom_component. The documentation says, that that is supported: https://developers.home-assistant.io/docs/en/creating_component_loading.html

Of course that is a terrible hack and it would be better to find the real cause of the problem…

I’ve opened a bug report at slixmpp: https://lab.louiz.org/poezio/slixmpp/issues/3429

So, I modified slixmpp to use lxml instead of xml. In stanzabase.py and xmlstream.py replace from xml.etree import cElementTree as ET with from lxml import etree as ET and added a try/catch block to stanzabase.py around the line from the stacktrace.

            try:
                parent = self.xml.find(parent_path)
            except:
                parent = None

This seems to works all the time… (just adding the try/catch block without switching to lxml leads to other errors)