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

Use /tmp/clientlist.json in async_get_connected_devices #36

Open
rkkoszewski opened this issue Apr 17, 2020 · 18 comments
Open

Use /tmp/clientlist.json in async_get_connected_devices #36

rkkoszewski opened this issue Apr 17, 2020 · 18 comments

Comments

@rkkoszewski
Copy link

Hi,

I just noticed that the function async_get_connected_devices shows disconnected devices as present, even if they're not. This is probably due to using the dnsmasq.leases file, which keeps the device record till the dns lease is expired.

I noticed there is a file /tmp/clientlist.json that basically shows the same information, but shows disconnected devices much quicker. In that file it also shows the clients separated by wifi "2G", "5G" and "wired_mac", which could also be used in async_get_wl to avoid the loops and multiple calls.

Is there any reason why that file has not been used for this cases?

From my tests, that file was kept updated even when no client was connected to the web admin of the router (Unless I missed out something).

@kennedyshead
Copy link
Owner

Looks like a very interesting thing to explore! I'll setup some experimental tests

@rkkoszewski
Copy link
Author

rkkoszewski commented Apr 22, 2020

I actually have it already running at home and it seems to work much faster, at least to identify devices that left. You can test if it works for you from my branches here

Using Native Python JSON (Preferred by me):
https://github.com/rkkoszewski/aioasuswrt/tree/feat/clientlistjson/json

Or using ORJSON (Requires ORJSON dependency installed, is slightly faster than the native version):
https://github.com/rkkoszewski/aioasuswrt/tree/feat/clientlistjson/orjson

I can open a PR if you want, or just take what you need from the changes.

@kennedyshead
Copy link
Owner

Yes, I think it should be added as an alternative though, there are like 1mil different versions of asuswrt and I'm not 100 that the file exists in all of these systems ;)
Let's try to open that file and if it does not exists fall back to the old listing.

@dejablue79
Copy link

Hi,
I have also found the same file while look a better way for looking up devices.
Is there anything i can do to help?

@kennedyshead
Copy link
Owner

I' working on this, will probably be added in next version

@PeteRager
Copy link

I’m having the same issue, RT-AC86U, current firmware 3.0.0.4.386_40451. Turning off wireless on iPhone that has a manual DHCP IP assigned, causes the device to continue to be reported back active for >12 hours (I didn’t wait longer so I do not know if it is ever removed)

However the /tmp/clients.json does get updated within a few seconds on disconnect and almost immediately on connect. For my router this looks like a better solution.

It’d be good to get this library updated, so that it can get pulled into Home Assistant, and all those users get the benefit of this working better.

@niklerus
Copy link

Hi,
Is there any activity around this?
I opened an issue relating to this some time ago but it got closed https://github.com/home-assistant/core/issues/41538 due to inactivity.

@imdunne8
Copy link

I've been using the clientlistjson/json branch from @rkkoszewski for over a month now through Home Assistant and it has been completely stable, runs faster, and picks up devices on my AiMesh extender by default. It certainly seems that this solution holds some nice benefits for many users, even if it isn't set as the default device polling method.

@kennedyshead
Copy link
Owner

I have tested it to and it is as you say more stable and faster. I'd be open to a PR if anyone have the time to put in some effort? I have to much daytime work and no time to play :(

@rkkoszewski
Copy link
Author

I could give it a shot. I might have some spare time today after work and could create the PR.

@fcastilloec
Copy link

I've been using the clientlistjson/json branch from @rkkoszewski for over a month now through Home Assistant and it has been completely stable, runs faster, and picks up devices on my AiMesh extender by default. It certainly seems that this solution holds some nice benefits for many users, even if it isn't set as the default device polling method.

@imdunne8 how did you manage to use that branch with the Home Assistant integration? I'm having some problems where none of my wireless devices get reported, only wired ones, probably because my RT-AC68U is running in AP mode, so the dnsmasq.leases file is empty. I have no idea where the info is being pulled from to get the wired device's data. Nonetheless, I would love to use the mentioned branch to fix my issues.

@imdunne8
Copy link

@fcastilloec The easy way to test it (which will likely have to be done again if you update HA) is to:

pip uninstall aioasuswrt
pip install git+https://github.com/rkkoszewski/aioasuswrt.git@f29071c5b532436f000e5151ae0a5b2a68040541

If you run HA through Docker you will have to run these commands from inside the container.

@niklerus
Copy link

thanks @imdunne8 !
Tried it as well and worked great. Good job @rkkoszewski !
@imdunne8 , short question, how did you get that https adress?
Howcome it's not the adress stated by rkkoszewski (https://github.com/rkkoszewski/aioasuswrt/tree/feat/clientlistjson/json)
Obviously your adress works, just curious how it works, couldn't find your your adress anywhere on rkkoszewski's github page

@imdunne8
Copy link

@niklerus That's just the git commit ID for the latest commit on that branch. Doing a pip install pointing at a github repository with the ID will mean it will always install that particular commit. You can find the ID if you look at the git history.

@dpembo
Copy link

dpembo commented May 3, 2021

thanks @imdunne8 !
Tried it as well and worked great. Good job @rkkoszewski !
@imdunne8 , short question, how did you get that https adress?
Howcome it's not the adress stated by rkkoszewski (https://github.com/rkkoszewski/aioasuswrt/tree/feat/clientlistjson/json)
Obviously your adress works, just curious how it works, couldn't find your your adress anywhere on rkkoszewski's github page

Just to say thanks to all involved! This has solved my issues also.
Much more stable and consistent! Hopefully this can be merged
👍

__

@fsecko1
Copy link

fsecko1 commented Sep 8, 2021

Hi, I´m newbie, so sorry for my questions, but could someone help me with step by step how to install this to home assistant? I´m using native integration asuswrt in HA, but in Aimesh is not working correctly (devices stays still "home"). Thank you.

@TwoD
Copy link

TwoD commented Sep 23, 2021

Is this file new? I don't seem to have it in MerlinWRT 384.13_2 on my RT-AC87U.

@pannal
Copy link

pannal commented Oct 20, 2021

I see the clientlist.json fork/feature branch is quite old. Will this ever get incorporated into this repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests