Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecovacs authentification and device registry issues #16186

Closed
bartvm opened this issue Aug 25, 2018 · 17 comments
Closed

Ecovacs authentification and device registry issues #16186

bartvm opened this issue Aug 25, 2018 · 17 comments

Comments

@bartvm
Copy link

bartvm commented Aug 25, 2018

Home Assistant release with the issue: 0.77.0b0

Last working Home Assistant release (if known): n/a

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

Component/platform: https://rc--home-assistant-docs.netlify.com/components/ecovacs/

Description of problem: I installed the pre-release of 0.77 to test with my Deebot N79S. I ran into the following errors:

I got authentication errors like those reported in wpietri/sucks#34 and had to apply the fix from that unmerged PR to continue.

Secondly, #15980 turned device into a read-only property but seems to have failed to update the Ecovacs code (that was added the day before) which tries to write to the self.device attribute. Replacing self.device with self._device everywhere in https://github.com/home-assistant/home-assistant/blob/0.77.0b0/homeassistant/components/vacuum/ecovacs.py seems to fix it.

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

ecovacs:
  username: !secret ecovacs_username
  password: !secret ecovacs_password
  country: ca
  continent: na

Traceback (if applicable):

Aug 24 23:58:19 ailurus hass[32698]: Traceback (most recent call last):
Aug 24 23:58:19 ailurus hass[32698]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
Aug 24 23:58:19 ailurus hass[32698]:     component.setup, hass, processed_config)  # type: ignore
Aug 24 23:58:19 ailurus hass[32698]:   File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Aug 24 23:58:19 ailurus hass[32698]:     result = self.fn(*self.args, **self.kwargs)
Aug 24 23:58:19 ailurus hass[32698]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/ecovacs.py", line 58, in setup
Aug 24 23:58:19 ailurus hass[32698]:     devices = ecovacs_api.devices()
Aug 24 23:58:19 ailurus hass[32698]:   File "/srv/homeassistant/lib/python3.6/site-packages/sucks/__init__.py", line 194, in devices
Aug 24 23:58:19 ailurus hass[32698]:     'resource': self.resource
Aug 24 23:58:19 ailurus hass[32698]:   File "/srv/homeassistant/lib/python3.6/site-packages/sucks/__init__.py", line 175, in __call_user_api
Aug 24 23:58:19 ailurus hass[32698]:     "failure {} ({}) for call {} and parameters {}".format(json['error'], json['errno'], function, params))
Aug 24 23:58:19 ailurus hass[32698]: RuntimeError: failure auth error (1004) for call GetDeviceList and parameters {'todo': 'GetDeviceList', 'userid': 'xxx', 'auth': {'with': 'users', 'userid':
'xxx', 'realm': 'ecouser.net', 'token': 'xxx', 'resource': 'XSRCDP0W'}}
Aug 24 23:57:32 ailurus hass[32587]: Traceback (most recent call last):
Aug 24 23:57:32 ailurus hass[32587]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
Aug 24 23:57:32 ailurus hass[32587]:     SLOW_SETUP_MAX_WAIT, loop=hass.loop)
Aug 24 23:57:32 ailurus hass[32587]:   File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
Aug 24 23:57:32 ailurus hass[32587]:     return fut.result()
Aug 24 23:57:32 ailurus hass[32587]:   File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
Aug 24 23:57:32 ailurus hass[32587]:     result = self.fn(*self.args, **self.kwargs)
Aug 24 23:57:32 ailurus hass[32587]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/vacuum/ecovacs.py", line 34, in setup_platform
Aug 24 23:57:32 ailurus hass[32587]:     vacuums.append(EcovacsVacuum(device))
Aug 24 23:57:32 ailurus hass[32587]:   File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/vacuum/ecovacs.py", line 44, in __init__
Aug 24 23:57:32 ailurus hass[32587]:     self.device = device
Aug 24 23:57:32 ailurus hass[32587]: AttributeError: can't set attribute

Additional information: n/a

@Kane610
Copy link
Member

Kane610 commented Aug 25, 2018

Self.device is now allocated for device registry information in entity component.

@bartvm
Copy link
Author

bartvm commented Aug 27, 2018

But the Ecovacs code doesn't seem to respect that and currently crashes.

@Kane610
Copy link
Member

Kane610 commented Aug 27, 2018

have you tried the latest beta? we have changed device registry to use device_info to clarify what it does

@Kane610
Copy link
Member

Kane610 commented Aug 27, 2018

I understand why I missed it originally, the component was merged around the same time as device registry so it didn't get picked up by my grep for components using self.device. So there shouldn't be an issue any more

bartvm added a commit to bartvm/home-assistant that referenced this issue Aug 27, 2018
@bartvm
Copy link
Author

bartvm commented Aug 27, 2018

I am not sure I am following. Yes, as I mentioned the PRs were merged around the same time and hence the Ecovacs code wasn't updated appropriately. Why do you say there shouldn't be an issue anymore? The latest beta still has Ecovacs trying to assign to self.device: https://github.com/home-assistant/home-assistant/blob/0.77.0b2/homeassistant/components/vacuum/ecovacs.py#L44

@leofuscaldi
Copy link

Just downloaded the latest beta version (0.77.0b2) but I'm having errors, which I think are the same (1004). I've set mine configuration as BR / WW.

Got the logs copied here: https://pastebin.com/F9zuBAch

@Kane610
Copy link
Member

Kane610 commented Aug 27, 2018

@bartvm yes the issue is gone, the previous usage of self.device with device registry has moved to self.device_info.

@Kane610
Copy link
Member

Kane610 commented Aug 27, 2018

The issue pasted by @leofuscaldi looks more like an authentication issue than with overridden methods

@bartvm
Copy link
Author

bartvm commented Aug 27, 2018

@leofuscaldi's issue seems to be the one from wpietri/sucks#34

@bartvm
Copy link
Author

bartvm commented Aug 27, 2018

@Kane610 Got it! I didn't understand what you meant at first with device_info, but I get it now, thanks!

@leofuscaldi
Copy link

@bartvm I think so.. but how do I fix the line? What is the sucks/init.py location?

@bartvm
Copy link
Author

bartvm commented Aug 27, 2018

It's in your traceback: /srv/homeassistant/lib/python3.5/site-packages/sucks/__init__.py. Note that if you make changes to it though, they will be overwritten whenever the sucks library gets updated. (The permanent solution is that wpietri/sucks#34 should be merged.)

@leofuscaldi
Copy link

@bartvm exactly. Thanks for the help, it works now!

@TonyFeestneus
Copy link

TonyFeestneus commented Aug 30, 2018

Changing the self.uid to the uid that is given by ecovac is working (with debug you can see which userid you are given).

But, then it gives the following errors:

sleekxmpp.basexmpp WARNING  fulljid property deprecated. Use boundjid.resource
sleekxmpp.xmlstream.cert WARNING  Could not find pyasn1 and pyasn1_modules. SSL certificate COULD NOT BE VERIFIED.
sleekxmpp.features.feature_mechanisms.mechanisms ERROR    No appropriate login method.
sleekxmpp.xmlstream.xmlstream ERROR    Can not read from closed socket.

Anyone knows how to fix this? EDIT: Fix it like this, by updating those modules:
pip3 install --ignore-installed pyasn1 pyasn1-modules

But then this problem pops up:

sleekxmpp.basexmpp ERROR    day is out of range for month
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1492, in _process
    if not self.__read_xml():
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1564, in __read_xml
    self.__spawn_event(xml)
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 1632, in __spawn_event
    handler.prerun(stanza_copy)
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/handler/callback.py", line 64, in prerun
    self.run(payload, True)
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/handler/callback.py", line 76, in run
    self._pointer(payload)
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/features/feature_starttls/starttls.py", line 64, in _handle_starttls_proceed
    if self.xmpp.start_tls():
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/xmlstream.py", line 889, in start_tls
    cert.verify(self._expected_server_name, self._der_cert)
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/cert.py", line 133, in verify
    not_before, not_after = extract_dates(raw_cert)
  File "/usr/local/lib/python3.5/dist-packages/sleekxmpp/xmlstream/cert.py", line 111, in extract_dates
    not_before = datetime.strptime(not_before, '%Y%m%d%H%M%SZ')
  File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/lib/python3.5/_strptime.py", line 475, in _strptime
    datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month

Fixed that by editing cert.py according to this post: fritzy/SleekXMPP#478
Resulting in yet another error.

Should i have another version of xmlstream or what is causing all this?

@TonyFeestneus
Copy link

With other versions I am back to this error:

sleekxmpp.basexmpp WARNING  fulljid property deprecated. Use boundjid.resource
sleekxmpp.features.feature_mechanisms.mechanisms ERROR    No appropriate login method.
sleekxmpp.xmlstream.xmlstream ERROR    Can not read from closed socket.

@OverloadUT
Copy link
Contributor

Tony, I think it'd be best to create that one as a new issue so we can keep the issues separate. The previous two issues in this thread are different.

@OverloadUT
Copy link
Contributor

I am closing this issue, as the original problem related to self.device was fixed. If anyone watching this issue is looking for fixes for any of the other problems that were discussed in this thread, please log a new issue so we can have a clean discussion about that specific issue. Thanks!

@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants