Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 21 February 2018 15:00
by EscApe
@Innovator
That's odd. The ac86u is still broadcom based, so i would expect the wl command to work. Are you getting any error messages? Or is it just not returning any data on the wireless interfaces?
I have tried the arp approach in the past and noticed it is not as 'realtime' as the wl info. It can take a while until a disconnected device dissapears from the arp table, whilst they instantly disappear from the wl info. The same goes for a snmp approach. I could get the info that way, but it is just not reliable enough (for me).
I'm considering the ac86u myself and hope the wl will still be usable.
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 21 February 2018 16:18
by Innovator
The command 'wl -i eth1 assoclist;wl -i eth2 assoclist: gives this output:
wl: wl driver adapter not found
wl: wl driver adapter not found
My router fimrware : Asus Merlin version 384.3
Before the AC86U i had a AC68U; with that hardware the "wl commandline works fine" with your python script.
So i was also very dissapointed that this specific broadcom chip from this AC86U router not was supported.
I agree with you that the wl command responds better, but in practice my adjustment works well enough. It takes about 30 seconds for a device to be detected. That is fast enough for me.
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 21 February 2018 16:31
by EscApe
Found some info. The interfaces to look for might no longer be eth1 and eth2. Could you have a look at the output of ifconfig and try some other interfaces with the original wl command? I think you need wlx.x instead of ethx. Not sure about the exact names (wl0.1, wl1.1????)
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 21 February 2018 17:11
by Innovator
wl -i wl0.1 assoclist
wl -i wl.1 assoclist
wl -i wl1.1 assoclist
gives wl driver adapter not found
I would not know how I should read the name of the interfaces. But if you give one or more commands as an example, I want to try it
Re: Python plugin: Presence detection from wireless router
Posted: Thursday 22 February 2018 21:18
by EscApe
I have ordered the ac86u. Will have a look this weekend.
Re: Python plugin: Presence detection from wireless router
Posted: Friday 23 February 2018 18:16
by EscApe
@Innovator
Just tested the wl command on the ac86u. If you replace eth1 and eth2 with eth5 and eth6 you'll get the correct association lists.
I found the available network interfaces using ifconfig (from the routers command line) and just tried them all.
For now you will have to change the plugin code. A future version of the plugin will get a selection list of popular methods (/commands) for router based presence detection. Unfortunately i do not have time for this now.
Re: Python plugin: Presence detection from wireless router
Posted: Saturday 24 February 2018 11:31
by Innovator
@EscApe ; Script just adapted, now works even better. Time indication about 15 seconds ... Thank you very much for your advice and have fun with your new AC86U!
Re: Python plugin: Presence detection from wireless router
Posted: Saturday 24 February 2018 12:03
by Innovator
@Escape Apologies, I was a bit over-enthusiastic. No, it does not work. Unfortunately, nothing is detected on eth5 and eth6. Have to decide to put "arp -a | grep br0 | awk '{print $ 4}'" back again. It is working well now. Think back to the drawing board.....
Re: Python plugin: Presence detection from wireless router
Posted: Sunday 04 March 2018 12:07
by EscApe
Strange... eth5 and eth6 return the correct info for me on my ac86u. I have been running the plugin for over a week now and it hasn't failed me once.
Your arp solution is also very elegant. It might even be better because it's less router/chipset/firmware specific, even if it takes some time to detect that a device has left. I will include it as an option in a future version. Unfortunately i don't really have time for that right now.
Re: Python plugin: Presence detection from wireless router
Posted: Tuesday 06 March 2018 18:57
by vulbas
hello,
do you think your plugin is compatible with AC88U ?
I have a problem of identification, I do not understand.
can you help me ?
Re: Python plugin: Presence detection from wireless router
Posted: Saturday 14 April 2018 0:09
by Btje
Why use the key solution and risk the wear you mention. HomeAssiatant has a working method with authentication
This is working great, i have tested it. It is uptill now my downfall of domoticz. everything is easier to configure but presence detection is off.
Until I saw your idea and this is I think the way o go. Would be nice to see it without using the key though.
In the mean time I'm starting with the keygen but go this:
ASUSWRT-Merlin RT-N66U 380.69-2 Sun Jan 28 06:07:49 UTC 2018
admin@RT-N66U:/tmp/home/root# ssh-keygen -t rsa
-sh: ssh-keygen: not found
admin@RT-N66U:/tmp/home/root#
Do I need to create user a?
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 18 April 2018 19:21
by EscApe
@Btje
I would have preferred to use a more advanced python ssh implementation like paramiko. That would make a password login instead of key login possible. Unfortunately just loading that module would crash domoticz. Be aware that the python plugin system is still a beta.
The key approach is a workaround since I am forced to use the shell ssh client. Setting it up can be a pain, but it works very well.
You should generate a key on the domoticz system, not on the router.
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 02 May 2018 20:46
by EscApe
Some major changes. See the top post for a description and the updated version.
Re: Python plugin: Presence detection from wireless router
Posted: Friday 04 May 2018 11:35
by EscApe
Some changes under the hood to improve error handling. Eg. when the router is offline.
Top post contains the most recent version.
Also rewrote the top post because the forum system kept messing it up (attachments all over the place except where i thought i put them)
Re: Python plugin: Presence detection from wireless router
Posted: Tuesday 08 May 2018 19:42
by mrkrabs
hi and thanks for the great script, however, i am struggling to get it working. i am running latest domoticz beta on a raspberry pi zero, and this is what i get in the log:
2018-05-08 19:39:54.966 Error: (Presence detection) SSH subprocess timed out
2018-05-08 19:39:54.968 Error: (Presence detection) Could not determine router capabilities
I can obviously ssh from pi to the router. i have also tried both password and keys and both end up with the same error. is there anything that i am missing? thanks!
ok, my bad, figured out this is all for the wireless clients, and wireless is disabled on my router, only wired connections. is there a way to get presence detection to work for the wired clients?
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 09 May 2018 12:02
by EscApe
@mrkrabs
The plugin is intended for the detection of presence/absence of people, based on the mobile devices they carry. Detecting wired connections is not within its scope. Maybe one of the many ping-based approaches would suit you?
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 09 May 2018 12:06
by EscApe
Updated to plugin to make use of the password field specification added bij Dnpwwo.
Password will now be hidden on the hardware configuration page Still stored in plain text (by Domoticz design) though.
I'm nog really bothered by that, but it's a security risk you should be aware of.
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 09 May 2018 12:23
by mrkrabs
EscApe wrote: ↑Wednesday 09 May 2018 12:02
@mrkrabs
The plugin is intended for the detection of presence/absence of people, based on the mobile devices they carry. Detecting wired connections is not within its scope. Maybe one of the many ping-based approaches would suit you?
Thanks, i totally understand the scope of the plugin, it's just my home network is designed the way that my main router that has all the MACs and IPs connected to it - does not have wifi. i have another router that servers wifi - but it doesn't have ssh (it's a time capsule from apple).
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 09 May 2018 12:44
by EscApe
Unfortunately i don't know how to get information from a setup like that. The same goes for mesh networks that are al the rage right now. Only someone who owns such as setup could determine (mostly thru trial and error) how to get real-time presence info. On some setups snmp might work. Really closed systems, without standard protocols like snmp, could be next to impossible.
If your skilled in python programming you could just try to modify the 'routercommand' and 'activemacs' functions of the plugin to suit your needs. Those are the only sections provide the real router communication. Maybe you can hardcode some router command lines in there.
The wl command is unlikely to work since it directly communicates with the wireless interface of the router
The arp command would be my first try, but i suspect it will only return mac addresses from devices that are directly attached to the same network.
The same goes for the snmp approach. I also abandoned the snmp approach because it would take a long time to detect devices leaving the network and sometimes even fail to do so.
As soon as any kind of routing/bridging is involved (between the wireless and wired connections of your second router or accesspoint) you will probably need a detection method that will route its investigation as well.... Ping would do the trick, but requires a response from the device itself.
Maybe someone else has a suggestion for (battery-friendly) detection methods?
Re: Python plugin: Presence detection from wireless router
Posted: Wednesday 09 May 2018 12:45
by mrkrabs
decided to use another router, that has OpenWRT installed on it, but there is no 'wl' command in my install, but a similar one - 'iwinfo'.
@EscApe = do you think it's possible to use iwinfo instead of wl?