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

Added support for AP mode in asuswrt #2263

Merged
merged 2 commits into from
Jun 10, 2016
Merged

Conversation

linjef
Copy link
Contributor

@linjef linjef commented Jun 9, 2016

Description: Uses wl command to get associated clients (instead of relying on DHCP leases). This allows AP operating mode users to also be able to use presence tracking. Default is set to router mode, the original method of detecting connected users. However, it is likely (but untested by me) that wl assoclist should work for router mode as well.

Related issue (if applicable): fixes #607

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#545

# Example configuration.yaml entry
device_tracker:
  platform: asuswrt
  host: YOUR_ROUTER_IP
  protocol: telnet
  mode: ap
  username: YOUR_ADMIN_USERNAME
  password: YOUR_ADMIN_PASSWORD

Checklist:

If user exposed functionality or configuration variables are added/changed:

If code communicates with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

telnet.write('exit\n'.encode('ascii'))
return (neighbors, leases_result)
return (neighbors, leases_result, arp_result)
except EOFError:
_LOGGER.exception("Unexpected response from router")
return ('', '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return three values, just as the exception below it.

@linjef
Copy link
Contributor Author

linjef commented Jun 10, 2016

Hey @balloob ,

Sorry about that--corrected. Thank you for your work on home-assistant; I'm only just getting started figuring out my setup, and it's been really great.

@balloob
Copy link
Member

balloob commented Jun 10, 2016

Thanks 👍 Glad you like it.

PR looks good, merging it 🐬 . I'll be getting my ASUSWRT router next week so I'll make sure to test it in router mode.

@balloob balloob merged commit 30f5727 into home-assistant:dev Jun 10, 2016
@linjef linjef deleted the asuswrt-ap-fix branch June 10, 2016 06:40
@persandstrom
Copy link
Contributor

Great work @linjef !

I tried this and the 'ap' mode does not seem to work when the router is configured as "router".

You might want to remove the line _LOGGER.info("Wireless AP does not have DHCP leases; using wl") since it will fill the logs :)

@linjef
Copy link
Contributor Author

linjef commented Jun 10, 2016

@persandstrom : hm... two questions, if you have the time: 1) what router model do you have, 2) if you can ssh/telnet into your router, can you run these commands and let me know what happens (if anything)? Please do anonymize the output; I just want to know if anything works.

{ wl -i eth2 assoclist & wl -i eth1 assoclist ; }
{ wl -i eth2 autho_sta_list & wl -i eth1 autho_sta_list ; }
ifconfig or ifconfig -a | sed 's/[ \t].*//;/^$/d' for a sanitized output; I'm not sure what to expect from this (mine has additional wl interfaces because of a guest SSID)

I kept that in there partly because I didn't know what the convention for _LOGGER.info might be. My logs are 99% Z-Wave updates, so I thought being a bit more verbose is maybe better. :p It can certainly be removed.

@balloob
Copy link
Member

balloob commented Jun 10, 2016

We should remove the info. More stuff should move to debug reporting

On Fri, Jun 10, 2016, 13:39 Jeffrey Lin [email protected] wrote:

@persandstrom https://github.com/persandstrom : hm... two questions, if
you have the time: 1) what router model do you have, 2) if you can
ssh/telnet into your router, can you run these commands and let me know
what happens (if anything)? Please do anonymize the output; I just want to
know if anything works.

{ wl -i eth2 assoclist & wl -i eth1 assoclist ; }
{ wl -i eth2 autho_sta_list& wl -i eth1 autho_sta_list; }
ifconfig or ifconfig -a | sed 's/[ \t].*//;/^$/d' for a sanitized output;
I'm not sure what to expect from this (mine has additional wl interfaces
because of a guest SSID)

I kept that in there partly because I didn't know what the convention for
_LOGGER.info might be. My logs are 99% Z-Wave updates, so I thought being
a bit more verbose is maybe better. :p It can certainly be removed.


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#2263 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABYJ2n3XhrNsDYxo8XzYpuWDTR-OFFaaks5qKcuVgaJpZM4Iyf-S
.

@balloob
Copy link
Member

balloob commented Jun 11, 2016

Removed the log entry

@persandstrom
Copy link
Contributor

router: RT-N66U

assoclist
assoclist BC:8C:CD:23:D5:1F
assoclist C4:85:08:47:C3:AE
assoclist 6C:8D:C1:9D:1F:A2
assoclist EC:1F:72:1D:8C:B9
assoclist 54:60:09:2A:34:22
assoclist 54:60:09:F9:7D:9A
assoclist F4:8E:92:27:69:36
assoclist 84:B1:53:99:40:50

autho_sta_list
autho_sta_list BC:8C:CD:23:D5:1F
autho_sta_list C4:85:08:47:C3:AE
autho_sta_list 6C:8D:C1:9D:1F:A2
autho_sta_list EC:1F:72:1D:8C:B9
autho_sta_list 54:60:09:2A:34:22
autho_sta_list 54:60:09:F9:7D:9A
autho_sta_list F4:8E:92:27:69:36
autho_sta_list 84:B1:53:99:40:50

devices
br0
eth0
eth1
eth2
lo
vlan1
vlan2

It might actually be possible to get information from the router which mode it is in, and thus get rid of the configuration parameter in the yaml. The command nvram show will give us a lot of information about the router settings. I just don't know which parameter to look at. Of course this is not needed if the same method can be used regardless of mode.

@balloob
Copy link
Member

balloob commented Jun 11, 2016

Yeah would be great if we can be smart about it. On boot determine if we need to use telnet or ssh, if we are dealing with a router or an ap and go from there.

@kellerza
Copy link
Member

Is the wl assoclist list the same as the results returned by url from this post https://community.home-assistant.io/t/alternate-device-tracker-component-for-asuswrt/979 ?

@kellerza
Copy link
Member

http://192.168.88.2/update_clients.asp and wl assoclist seems similar

I'm in router mode

RT-AC66U-1D68:/tmp/home/root# nvram show | grep _mode=a
wl0.2_mode=ap
wl0_mode=ap
wl1.2_mode=ap
wl_mode=ap
wl0.3_mode=ap
wl0.1_mode=ap
wl1_mode=ap
wl1.3_mode=ap
wl1.1_mode=ap
wps_wer_mode=allow

@persandstrom
Copy link
Contributor

Maybe someone can do a diff between the output in router and in ap mode? I don't have any other router so I don't know if it's possible for me to run it in ap mode.

@persandstrom
Copy link
Contributor

BTW. Maybe this discussion should move to a new issue instead. This PR is finished 😀

@EricReiche
Copy link

If you come here from a search engine, check #4305

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

Successfully merging this pull request may close these issues.

Asuswrt Not Loading
5 participants