Page 28 of 56

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 20 October 2019 22:21
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!

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 02 November 2019 9:44
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

Re: Python plugin: Presence detection from wireless router

Posted: Tuesday 05 November 2019 21:17
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!

Re: Python plugin: Presence detection from wireless router

Posted: Tuesday 05 November 2019 23:18
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.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 06 November 2019 8:38
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.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 10 November 2019 20:49
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 ;-)

Re: Python plugin: Presence detection from wireless router

Posted: Monday 11 November 2019 19:51
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.

Re: Python plugin: Presence detection from wireless router

Posted: Monday 11 November 2019 20:43
by maxtrash
Hi, how can I install the modular version?

Re: Python plugin: Presence detection from wireless router

Posted: Monday 11 November 2019 20:46
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.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 13 November 2019 13:48
by spider2
Hi,

I have Tplink Archer C9 and not have ssh. So I can't use this plugin?

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 13 November 2019 19:42
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.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 13 November 2019 19:59
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.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 13 November 2019 20:46
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.

Re: Python plugin: Presence detection from wireless router

Posted: Monday 18 November 2019 19:53
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?

Re: Python plugin: Presence detection from wireless router

Posted: Monday 18 November 2019 21:55
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.

Re: Python plugin: Presence detection from wireless router

Posted: Tuesday 19 November 2019 22:38
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.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 20 November 2019 17:52
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

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 24 November 2019 20:53
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?

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 24 November 2019 22:18
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.

Re: Python plugin: Presence detection from wireless router

Posted: Tuesday 26 November 2019 20:34
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...