Python plugin: Presence detection from wireless router

Python and python framework

Moderator: leecollings

Jilles
Posts: 5
Joined: Monday 03 April 2017 12:53
Target OS: NAS (Synology & others)
Domoticz version: 4.11337
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Jilles »

EscApe wrote: Sunday 20 October 2019 22:11
Forget about all that. I figured out how to install sshpass in my alpine based container. Now working with username:pass. Works like a charm!
Happy to hear you got it working!
If you ever want to (re)try key based authentication I think you can just copy the key files you created as root to the .ssh folder in the abc home directory and change ownership... not sure though :mrgreen:
I did just that. Checked the home of the user in /etc/passwd, moved them there, chown. Still nothing... Must still be doing something wrong. We pick it up later. First I'll enjoy this great plugin. Thanks again!
Hilly2003
Posts: 1
Joined: Saturday 17 March 2018 1:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: The Netherlands
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Hilly2003 »

Hi escApe,
I have an Asus RT-AC66U-B1 and it is working like a charm!

Domoticz Version 4.10717(2019-05-09)
dzVents Version 2.4.19
Python Version 3.7.3(03-4-2019)
Great work!
Thank you! :D
Michel1508
Posts: 1
Joined: Monday 04 November 2019 16:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Michel1508 »

Hi all,

I just started a week ago with Domoticz (and Dashticz) and wanted to use iDetect to see who's home. I have an Experia Box V10 provided by my internet provider and I can't get it to work. The installation works fine, I manage to see three devices (all switches): Anyone, Override and phone1. They are all on "off" and I would have expected phone1 to be "on" when it's connected to the WLAN. What am I missing here?

I read on a (Dutch) forum (https://forum.kpn.com/internet-9/experi ... ren-429818) that the information on this router cannot be accessed in any other way but through the web interface. Could that be a problem? Any suggestions on how to make this work are very much welcome!
EscApe
Posts: 535
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

Post by EscApe »

Hoi Michel1508,
this router cannot be accessed in any other way but through the web interface. Could that be a problem?
Short answer: yes

The plugin only supports querying the router through ssh. I have some ideas on making it more modular so other methods might be added. But to be honest, that would mean a massive rewrite and I don't have any need for that myself, so I'm spending most of my free time on other projects. No real plans for this rewrite in the near future.
fabstar81
Posts: 5
Joined: Saturday 27 April 2019 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by fabstar81 »

bkram wrote: Wednesday 27 June 2018 11:28 Hi,

Thanks for the plugin, I am using it with an Ziggo TP-Link Arcer C7 running Lede.

A request for the "Anyone" feature, I would like to blacklist some Wifi devices which are always online, so I can detect if there are any 'Guests' in the house.

Regards

bkram
Do you have a picture of the modem? I have a ziggo modem too and would like to know if and how you made this work.
EscApe
Posts: 535
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

Post by EscApe »

ONLY FOR THE BRAVE !!

I have (almost) completely rewritten the plugin to be more modular, so others methods beside ssh can be added (in the future).
It's in the 'modular' branch on GitHub.

It all seems to work just fine and it should even work without changing the configuration for most users. However! It must be considered an early beta. Chances are you will run into bugs or it might not work for your router (yet). Adding specific router types that use ssh is very easy now, so that can be quickly corrected. Adding other polling methods, like http pages should also be relatively easy, as long as the code to query the http page is available.

Any help in testen en perfecting this version is greatly appreciated!

EDIT: You might have to pip3 install some additional python modules. Please check the imports or trial and error... I will document these before the final version, but am calling it a night for now ;-)
EscApe
Posts: 535
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

Post by EscApe »

Things are moving along quickly with the (modular) beta version

I'm pretty excited about the new possibilities that this modular approach offers. Just added pinging as an option to monitor 'presence'. Not really the way a want to monitor the presence of wireless devices (will drain battery!), but it can be used to monitor other stuff, like: is my computer/router/tv etc online? In that case don't forget to add #ignore after the address, so it does not interfere with the 'Anyone home' status.
If someone still insist on using ping to monitor wireless devices .... now you can ;)

This is now a valid configuration :) :

Code: Select all

phone=44:cc:22:12:32:E2, phone2=21:33:e2:03:02:63, tv=192.168.1.11#ignore 
The ping module will only activate if there are any ip addresses to monitor. You don't have to enable/disable it.

Keep in mind that this is still an early beta. Bugs are to be expected. I am running it on my live system without problems (using Asus router and auto detection)
The code still needs cleaning up and some stuff is hardcoded (like the ping interval: 30 seconds). Will see if I can make that configurable somehow.
I would have preferred to use threading timers to initiate the polling, but they don't work in the plugin framework. At least threading is working now, so that's great! SSH polling now runs in the background.

I would appreciate feedback on this beta version. Especially on performance in more complicated setups. I just have one router to poll and that does not seem te impact performance at all.
maxtrash
Posts: 106
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by maxtrash »

Hi, how can I install the modular version?
EscApe
Posts: 535
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

Post by EscApe »

Remove the old version first and then:

Code: Select all

cd /home/pi/domoticz/plugins (or wherever you plugins directory resides)
git clone -b modular https://github.com/d-EScape/Domoticz_iDetect.git Presence
If you don't use/have git then download it as a zip from GitHub and place the files and folder manually in the domoticz/pliugins/Presence directory.
spider2
Posts: 13
Joined: Wednesday 21 November 2018 19:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by spider2 »

Hi,

I have Tplink Archer C9 and not have ssh. So I can't use this plugin?
drwurn
Posts: 68
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by drwurn »

Hi,

I've had the plugin running for 'ages' but yesterday I did a router firmware update but since then I get this error.

Code: Select all

2019-11-13 19:05:31.503 (iDetect) SSH subprocess for 192.168.3.1 failed with error (255):b''
2019-11-13 19:05:31.503 (iDetect) SSH command on 192.168.3.1 took 132 milliseconds.
2019-11-13 19:05:31.503 (iDetect) Could not retreive available commands on 192.168.3.1
SSH is enabled in my router.

Not sure what to do since it was sooo long ago I installed it.
EscApe
Posts: 535
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

Post by EscApe »

Try to ssh login to your router from the commandline under the user name that is running Domoticz... Router keys probably changed. The (error)message on the cli will explain what to do.
EscApe
Posts: 535
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

Post by EscApe »

The modular (beta) version just got even better. Lots of new settings to tweak individual trackers (eg. routers) and tags (eg. phones), while limiting the amount of breaking changes (for existing configurations).

Also added preliminary documentation on GitHub explaining the new features and settings.
drwurn
Posts: 68
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by drwurn »

Hi,

Presence detection is working on my asus ac68u on my normal network but when I go with my cell on the guest network it doens't detect my phone.

Is there anyone with a solution?
EscApe
Posts: 535
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

Post by EscApe »

Important announcement for 2.0 beta users:

The upcoming version will use Paramiko (native python ssh client) instead of calling the linux ssh client. I finally figured out why Paramiko and threading timers would crash Domoticz when the plugin was stopped, so I am incorporating both.

You will need to pip3 install paramiko

Your private ssh key file needs to be RSA compliant. Paramiko wilt tell you 'not a valid RSA private key' if it isn't. You can convert an existing key using

Code: Select all

ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
Another way to check: If the header of ~/.ssh/id_rsa says something with OPENSSH it will need conversion.


I expect to push the next version in 1-2 days, if it proofs reliable in my test setup.
EscApe
Posts: 535
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

Post by EscApe »

@drwurn
Presence detection is working on my asus ac68u on my normal network but when I go with my cell on the guest network it doens't detect my phone.

Is there anyone with a solution?
It seems the guest network on an Asus router is named 'wl1.0' (wl1.1 etc). The plugin would only auto detect interfaces starting with 'eth' or 'wlan'. I added these interfaces to the auto detection in the upcoming 2.0 beta version, which I will probably commit tomorrow.
EscApe
Posts: 535
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

Post by EscApe »

I just pushed the latest beta (2.0) to GitHub. Important changes:

- uses Paramiko as native python ssh client (install paramiko before starting the plugin)
- the plugin now supports Windows(!)
- uses timers instead of the plugins heartbeat for the poll interval
drwurn
Posts: 68
Joined: Sunday 10 June 2018 16:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by drwurn »

It seems the guest network on an Asus router is named 'wl1.0' (wl1.1 etc). The plugin would only auto detect interfaces starting with 'eth' or 'wlan'. I added these interfaces to the auto detection in the upcoming 2.0 beta version, which I will probably commit tomorrow.
When will the stable version be online?
EscApe
Posts: 535
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

Post by EscApe »

When will the stable version be online?
Getting feed back from some beta testers would speed things up.

I have recently added a timeout to the ssh session, because the plugin would sometimes just stop polling. That seems to be fixed now... At least in my single Asus router setup. Would love to hear how it performs in more complex setups and with other routers before calling it stable.
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Geitje »

I will certainly test it when I have some spare-time, I'm interested in this plugin. I have an Orbi router, so could be more complex...
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest