Unfortunately, on the latest router software (Merlin AsusWrt 380.66) the component does not work and displays every few seconds an error:
2017-05-16 10:24:53 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 698, in async_device_tracker_scan
found_devices = yield from scanner.async_scan_devices()
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 385, in scan_devices
self._update_info()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 303, in wrapper
result = method(*args, **kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 408, in _update_info
data = self.get_asuswrt_data()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 435, in get_asuswrt_data
r"fromNetworkmapd: '(.*?)'", data)[0].split('<')
IndexError: list index out of range
I can send you a update_clients.asp file if you want.
Had to increase the interval to 30. Anyway, I looked into the code of the component, and made the changes required to maintain the connection. PR (https://github.com/home-assistant/home-assistant/pull/7728) submitted, hopefully it’s accepted soon and the issue will be behind us.
I have tried the component with your changes and it works very well. Only during restart of the router generates a lot of errors in the HA log:
2017-05-23 19:29:40 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
result = coro.throw(exc)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 698, in async_device_tracker_scan
found_devices = yield from scanner.async_scan_devices()
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 154, in scan_devices
self._update_info()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 303, in wrapper
result = method(*args, **kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 177, in _update_info
data = self.get_asuswrt_data()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 191, in get_asuswrt_data
result = self.connection.get_result()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 321, in get_result
self.connect()
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 359, in connect
password=self._password, port=self._port)
File "/home/homeassistant/.homeassistant/deps/pexpect/pxssh.py", line 279, in login
spawn._spawn(self, cmd)
File "/home/homeassistant/.homeassistant/deps/pexpect/pty_spawn.py", line 273, in _spawn
assert self.pid is None, 'The pid member must be None.'
AssertionError: The pid member must be None.
@aronsky Yes, the connection after the restart was resumed and the component was still working properly. I just updated the router software so the restart took longer than usual and in the HA log there were several dozens of errors as in my previous post.
Thanks for the report! I tried handling the AssertionError, and it helps. However, there are a lot of other unhandled errors from various failing connections to sensors, etc. due to the network being down. So, not sure if it makes a lot of sense to fix this, but I made a pull request with the handled error, nonetheless.
Strange, indeed. I tested it at home, and it reconnected successfully once the router booted up. Let me know if anything changes, I’ll close the PR for now, until we know for sure it works properly.
EDIT: Can confirm, same thing happens here. Might be a statistical thing (sometimes happens, sometimes doesn’t). I’m trying out some changes to the code to make a consistent fix.
OK, I think I fixed it. I changed the way the pxssh object lifetime is handled, and now it seems to work properly, and the AssertionError handling is redundant (it never happens). I’ll leave the handling, just in case, but regardless, I’m pushing a PR with the fix (it’s the same PR from the previous message, you can get the updated version from there). Let me know if it works for you - I tried it several times in a row, and haven’t run into any problems.
make sure SSH is enable on your router sign in to your router click on the administration tab then click on system you will see SSH by default is set to NO change it to YES click on apply them restart homeassistant