Python plugin: Presence detection from wireless router
Moderator: leecollings
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
@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.
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.
- Innovator
- Posts: 16
- Joined: Tuesday 20 February 2018 12:33
- Target OS: NAS (Synology & others)
- Domoticz version: 8924
- Location: Amsterdam
- Contact:
Re: Python plugin: Presence detection from wireless router
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.
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.
Synology DS918+ /DS412+
ASUS BRT-AC828, RT-AC86U, RT-AC68U
ASUS BRT-AC828, RT-AC86U, RT-AC68U
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
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????)
- Innovator
- Posts: 16
- Joined: Tuesday 20 February 2018 12:33
- Target OS: NAS (Synology & others)
- Domoticz version: 8924
- Location: Amsterdam
- Contact:
Re: Python plugin: Presence detection from wireless router
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
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
Synology DS918+ /DS412+
ASUS BRT-AC828, RT-AC86U, RT-AC68U
ASUS BRT-AC828, RT-AC86U, RT-AC68U
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
I have ordered the ac86u. Will have a look this weekend.
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
@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.
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.
- Innovator
- Posts: 16
- Joined: Tuesday 20 February 2018 12:33
- Target OS: NAS (Synology & others)
- Domoticz version: 8924
- Location: Amsterdam
- Contact:
Re: Python plugin: Presence detection from wireless router
@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!
Synology DS918+ /DS412+
ASUS BRT-AC828, RT-AC86U, RT-AC68U
ASUS BRT-AC828, RT-AC86U, RT-AC68U
- Innovator
- Posts: 16
- Joined: Tuesday 20 February 2018 12:33
- Target OS: NAS (Synology & others)
- Domoticz version: 8924
- Location: Amsterdam
- Contact:
Re: Python plugin: Presence detection from wireless router
@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.....
Synology DS918+ /DS412+
ASUS BRT-AC828, RT-AC86U, RT-AC68U
ASUS BRT-AC828, RT-AC86U, RT-AC68U
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
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.
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.
-
- Posts: 37
- Joined: Tuesday 20 February 2018 17:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Presence detection from wireless router
hello,
do you think your plugin is compatible with AC88U ?
I have a problem of identification, I do not understand.
can you help me ?
do you think your plugin is compatible with AC88U ?
I have a problem of identification, I do not understand.
can you help me ?
-
- Posts: 22
- Joined: Wednesday 05 October 2016 7:46
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Python plugin: Presence detection from wireless router
Why use the key solution and risk the wear you mention. HomeAssiatant has a working method with authentication
https://www.home-assistant.io/component ... e_tracker/
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?
https://www.home-assistant.io/component ... e_tracker/
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?
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
@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.
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.
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
Some major changes. See the top post for a description and the updated version.
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
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)
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)
-
- Posts: 21
- Joined: Sunday 12 March 2017 14:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9589
- Contact:
Re: Python plugin: Presence detection from wireless router
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:
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?
Code: Select all
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
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?
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
@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?
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?
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
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.
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.
-
- Posts: 21
- Joined: Sunday 12 March 2017 14:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9589
- Contact:
Re: Python plugin: Presence detection from wireless router
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).
Last edited by mrkrabs on Wednesday 09 May 2018 12:45, edited 2 times in total.
-
- Posts: 528
- Joined: Thursday 02 April 2015 8:46
- Target OS: Linux
- Domoticz version: 2020+
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
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?
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?
-
- Posts: 21
- Joined: Sunday 12 March 2017 14:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9589
- Contact:
Re: Python plugin: Presence detection from wireless router
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?
@EscApe = do you think it's possible to use iwinfo instead of wl?
Who is online
Users browsing this forum: Google [Bot] and 1 guest