BnMcG / HomeAssistant-RoboVac

Component to implement Eufy RoboVac support in Home Assistant
Apache License 2.0
45 stars 14 forks source link

HA 0.96 - No module named 'robovac' #5

Closed JXGA closed 5 years ago

JXGA commented 5 years ago

Hey,

I have a new issue after updating to 0.96;

Error while setting up platform eufyrobovac Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/config/custom_components/eufyrobovac/vacuum.py", line 42, in async_setup_platform from robovac import Robovac, get_local_code ModuleNotFoundError: No module named 'robovac'

It was working fine before the update. I think there's a new Vacuum template in 0.96, so maybe that's interfering? https://www.home-assistant.io/components/vacuum.template/

BnMcG commented 5 years ago

Thanks, I'll take a look at the changes in 0.96 and see if that's the problem. My own Home Assistant instance recently stopped working after upgrading so once I get it working again I'll investigate.

BnMcG commented 5 years ago

Just gotten HA up and running again, I'll upgrade to 0.96 and see what the damage is.

BnMcG commented 5 years ago

Replicated on my local instance.

BnMcG commented 5 years ago

As a workaround, manually installing the Python module with pip3 install robovac will get you going again. Still looking into why Home Assistant has stopped doing this automatically. This issue doesn't seem to be present in 0.95.4, so downgrading may also help you.

JXGA commented 5 years ago

This did the trick...

edit: remove email footer rubbish

BnMcG commented 5 years ago

Good to hear. I'm still comparing what's changed between 0.95.4 and 0.96.0 to work out why HA stopped auto-installing the package, will update here when I figure it out.

BnMcG commented 5 years ago

I've identified the issue with the help of some of the folks on the Home Assistant Discord server - I'll push out the fix tomorrow morning.

JXGA commented 5 years ago

Thanks for your time on this...

Picked up another error, but I don't think it relates to this one...; Failed to call service vacuum/return_to_base. [Errno 106] Socket is connected

So the status of the vac is detected and correct on HA first startup, then it does not update status (until HA restart) and I can not control the vac from HA.

[Errno 106] Socket is connected
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/robovac/robovac.py", line 316, in _send_packet
    self.s.send(encrypted_packet_data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
    connection.context(msg))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service
    required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 337, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/config/custom_components/eufyrobovac/vacuum.py", line 140, in async_stop
    await self.hass.async_add_job(self.vacuum.stop)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/robovac/robovac.py", line 204, in stop
    message = self._build_command_user_data_message(command)
  File "/usr/local/lib/python3.7/site-packages/robovac/robovac.py", line 273, in _build_command_user_data_message
    magic_number = self._get_magic_number()
  File "/usr/local/lib/python3.7/site-packages/robovac/robovac.py", line 300, in _get_magic_number
    pong = self._send_packet(ping, True)
  File "/usr/local/lib/python3.7/site-packages/robovac/robovac.py", line 318, in _send_packet
    self.connect()
  File "/usr/local/lib/python3.7/site-packages/robovac/robovac.py", line 153, in connect
    self.s.connect((self.ip, self.port))
OSError: [Errno 106] Socket is connected
BnMcG commented 5 years ago

That error looks super similar to #3 - I think I've previously worked around it by restarting HA and the Robovac, and my best guess at the moment is it's something to do with the update code not letting go of something it's supposed to.

Once I've pushed the fix that allows the component to properly install on 0.96 I'm going to dig into why sometimes the transport endpoint remains connected / why HA tries to open a new connection when one already exists. It seems intermittent and I know on my local installation I can go for days/weeks without this error popping up.

Thanks for your patience!

BnMcG commented 5 years ago

I've tagged v0.1.1 that contains the fix for the dependencies not being correctly downloaded. The issue was the domain listed in the custom component's manifest.json wasn't correct ("robovac" instead of "eufyrobovac").

You should be able to drop-in the new files, restart Home Assistant and be good to go. You probably won't see any actual changes on your instance as you manually installed the dependency earlier, but from this point onwards if a new version is released with updated dependencies they will be downloaded automatically.

I'll take a look at the transport issue today.