home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.61k stars 29.92k forks source link

Asuswrt Not Loading #607

Closed slamanna212 closed 8 years ago

slamanna212 commented 8 years ago

I have all my info in and even tested the telnet connection to my router (RT-N66U running Asus Merlin) and was able to log into it but it is not working for me

error in log:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 139, in setup_platform
    scanner = platform.get_scanner(hass, {DOMAIN: p_config})
  File "/usr/local/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 72, in get_scanner
    scanner = AsusWrtDeviceScanner(config[DOMAIN])
  File "/usr/local/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 93, in __init__
    data = self.get_asuswrt_data()
  File "/usr/local/lib/python3.4/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 172, in get_asuswrt_data
    'ip': match.group('ip'),
AttributeError: 'NoneType' object has no attribute 'group'
balloob commented 8 years ago

@persandstrom could you take a look at this one?

persandstrom commented 8 years ago

Sure

persandstrom commented 8 years ago

@slamanna212 Could you please log in to your router using telnet and give me the output of the following commands.

ip neigh

cat /var/lib/misc/dnsmasq.leases

slamanna212 commented 8 years ago

IP neigh lists devices ip addresses, their mac addresses and weather they are reachable or not

and the second one lists mac address, ip address, devices names and their dns lease time

persandstrom commented 8 years ago

Sound like the output is what it should be.

I can't solve the bug without more information so I have created a pull request with more logging, it is also more robust and will not fail if one line can't be parsed.

persandstrom commented 8 years ago

any news on this bug?

jonology commented 8 years ago

I'm having issues with mine. not sure if its to do with this or not, I'm also running lastest firmware on mine v1.1.0.4 on a DSL-N55U_C1

test.txt

persandstrom commented 8 years ago

@Jonology that might actually be the same issue. One question. Does it ever work for you or is the error constant?

jonology commented 8 years ago

never worked, but I've only installed it today Home Assistant today so could be a config issue maybe :)

persandstrom commented 8 years ago

@jonology Are you using asuswrt-merlin? I'm currently running v.3.0.0.4 of stock firmware on an N66U.

persandstrom commented 8 years ago

I'm not sure but I think that this is an issue with the custom firmware asuswrt-merlin, or rather that we don't support asuswrt-merlin. Would be nice if we could confirm that somehow and change this from a bug to an enhancement.

emilhetty commented 8 years ago

I have 2 Asus RT-AC66U routers and on both of them have the same error as @jonology did. Hass shows the following: WARNING:homeassistant.components.device_tracker.asuswrt:Could not parse lease row: b"cat: can't open '/var/lib/misc/dnsmasq.leases': No such file or directory\r"

Connected with telnet to my router shows the following: admin@RT-AC66U:/tmp/home/root# cat /var/lib/misc/dnsmasq.leases cat: can't open '/var/lib/misc/dnsmasq.leases': No such file or directory

I'm running stock and newest Asus firmware, currently 3.0.0.4.378.

emilhetty commented 8 years ago

I think I found the reason why it is not working for me, the function is based on the DHCP leases and since I'm not using my routers as a router but only as a access point and therefore the DHCP is disablet in my routers.

But it must be somewhere else to get the information from, in the webpage for my router I can have a list of all connected equipment. I have changed the name and added picture to the equipment so the information must be stored somewhere in the router.

persandstrom commented 8 years ago

Great,finally a clue to the mystery! Thanks @emilhetty I'll try to figure something out in the near future, if nobody beats me to it :)

jonology commented 8 years ago

@emilhetty @persandstrom I was using DHCP on mine. Sadly mine is unplugged atm

persandstrom commented 8 years ago

can anyone that experience this problem run the command find / -name *.leases after connecting to it using telnet. I would like to see if the file is located somewhere else.

emilhetty commented 8 years ago

I got nothing: admin@RT-AC66U:/tmp/home/root# find / -name *.leases admin@RT-AC66U:/tmp/home/root#

slamanna212 commented 8 years ago

admin@WOPR:/tmp/home/root# find / -name *.leases /tmp/var/lib/misc/upnp.leases /tmp/var/lib/misc/dnsmasq.leases admin@WOPR:/tmp/home/root#

Running the latest AsusWrt Merlin Firmware

emilhetty commented 8 years ago

I just changed mode from AP to router mode for one of my router to verify that it is working when it is in router mode and it did. cat /var/lib/misc/dnsmasq.leases gave me a list of connected devices.

persandstrom commented 8 years ago

I have been looking around a bit and I can't find a solution 😐. Would be good if someone that has the problem could try to solve it.

infamy commented 8 years ago

Documentation needs tp warn of this shortfall and it will just be a know limitation for this platform for now.

linjef commented 8 years ago

Hi all,

I have a dirty fix (same setup, with an RT-AC68U using access point and not DHCP on the router), and I hope I can put in a pull request some time later this week. But in case I forget (!) or if anyone wants to fiddle with this beforehand, see below.

The general idea is to gather the authenticated MAC addresses, and if necessary (depending on platform), cross-reference them with the arp table's IP addresses (e.g. from arp-n).

_WL_CMD = '{ wl -i eth2 authe_sta_list & wl -i eth1 authe_sta_list ; }'

will give you the currently authenticated MAC addresses (I believe), but I am not yet sure if this generalizes to all Asus WRT routers (in fact, I believe it doesn't--some routers use Quantenna and I think you'd need qcsapi or something like that... this is part of the reason I am hesitant to put in a PR right now, since I have no other routers to test with). Further, eth2/eth1 might vary with router (mine correspond to 5GHz and 2.4GHz, but wl0/wl1 might just as well apply).

If any other users could run the WL_CMD (emilhetty?) and corroborate these results, that'd be really appreciated! Thanks!

(update: assoclist or autho_sta_list probably work better than authe_sta_list; they seem more real-time).

emilhetty commented 8 years ago

Great work @linjef! Just found the assoclist and then I saw you edited your post. I agree with you that assoclist should work, I will test it on my router.

If all the commands I found on this webpage works, we could collect a lot more cool stuff than only the list with MAC addresses. For example the RSSI could be collected and used to calculate the position if you have more than one router.

Updated: forgot that this was wifi and not BT, you will only get the RSSI from one router that you are connected to and not several. Anyhow the RSSI is nice to collect anyway, it could be combined with BT RSSI to calculate the location of your device.

emilhetty commented 8 years ago

Just tested the wl assoclist command and it works on both my AC66U routers in AP mode. image

john-ruddy commented 8 years ago

I know it's not a proper fix and I don't know how long it will last but I found a .leases file in /tmp and created a symbolic link: ln -s /tmp/dnsmasq.leases /var/lib/misc/dnsmasq.leases I'm now able to track devices. Hope this helps someone else trying to set up for now.

edit: this is not persistent after a power outage, I got a lot of these lines in my log after a lightning storm yesterday homeassistant.components.device_tracker.asuswrt: Could not parse lease row: b"cat: can't open '/var/lib/misc/dnsmasq.leases': No such file or directory\r" Re-adding the symbolic link fixed it right away. I'll try to experiment with restricting write permissions to see if that will keep it from disappearing again.