Page 24 of 56

Re: Python plugin: Presence detection from wireless router

Posted: Monday 17 December 2018 13:41
by allinvisible
@ EscApe, thanks for this plugin. I have implement it to my configuration.
Cool.

Kind regards

Re: Python plugin: Presence detection from wireless router

Posted: Monday 17 December 2018 20:12
by EscApe
Looks like plug-in is not connecting. Are you sure you tried it from the command line with the same user profile that is running Domoticz? (Root by default).
The starting part of the log is missing. It might include some extra info,

Are you running Domoticz on linux?

Re: Python plugin: Presence detection from wireless router

Posted: Monday 17 December 2018 20:39
by tomaforn
EscApe wrote: Monday 17 December 2018 20:12 Looks like plug-in is not connecting. Are you sure you tried it from the command line with the same user profile that is running Domoticz? (Root by default).
The starting part of the log is missing. It might include some extra info,

Are you running Domoticz on linux?
That was it! I had created keys for the "pi" user, while the Domoticz daemon is running as root. So it was a connection issue all along.
Now it's working as a charm, thanks for your help and for this awesome plugin!

/Tomas

Re: Python plugin: Presence detection from wireless router

Posted: Monday 04 February 2019 20:20
by Franzie
Can someone acknowledge that iDetect is working with Ubiquiti AmpliFi AFi-HD Multiroom wifi. If not I have to make other choices :)

Thanks


=====
Frans

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 06 February 2019 14:37
by EscApe
@Franzie,

Seems like no one folowing this thread can confirm. Did you try it yourself? As long as the amplifi supports ssh access it might just work or you could search for a amplifi specific command I can add to the plugin.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 13 February 2019 21:46
by Mrrodz
Hi, I have a unifi network. USG, UniFi AP-AC-LR and UniFi AP-AC-Lite.

I followed mikeoo tutorial, but it still wouldn't work with my USG.
Screen Shot 2019-02-13 at 20.22.01.png
Screen Shot 2019-02-13 at 20.22.01.png (56.89 KiB) Viewed 2621 times
and it will not discover my device

then i added the =unifiusg-arp
Screen Shot 2019-02-13 at 20.24.05.png
Screen Shot 2019-02-13 at 20.24.05.png (24.56 KiB) Viewed 2621 times
and get these errors.
Screen Shot 2019-02-13 at 20.26.13.png
Screen Shot 2019-02-13 at 20.26.13.png (75.66 KiB) Viewed 2621 times
any ideas? im not sure what i would achieve off the USG tbh, i don't know if i would be able to detect when wired devices are detected?

on a plus note i did notice that if i put the ip addresses of both my access points into the router section (with out =unifi bit) that the system seemed to work.

many thanks

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 13 February 2019 22:19
by EscApe
Looks like you are using ssh key based login, but it does not appear to be working. Please make sure key based ssh login is possible from the command line under the same user account that is running Domoticz. Even if it is configured for the correct user (root?) trying key based login from the command line will probably return some more info about the login proces (like key mismatches).

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 24 February 2019 7:43
by Number8
Hi
I'm trying to get the plugin working on a RaspPI Jessie with Python 3.4.2 installed (unifi AP's). Domoticz version is V3.9139
As we can see in the log file SSH with public key to all AP's is working. However the plugin reports some errors. How can I get it working?
Is it a matter og Python version? Something else?
Thank you
EDIT : plugin has been installed under root. Plugin has execution rights
Spoiler: show
2019-02-24 07:31:35.746 (idetect) Started.
2019-02-24 07:31:36.042 (idetect) Entering work loop.
2019-02-24 07:31:36.043 (idetect) Initialized version 0.7.7, author 'ESCape'
2019-02-24 07:31:36.098 (idetect) Debug logging mask set to: PYTHON
2019-02-24 07:31:36.099 (idetect) Not running on Windows
2019-02-24 07:31:36.119 (idetect) The OS user profile running domoticz is: root
2019-02-24 07:31:36.141 (idetect) Checking if [ssh -V] will run: OK
2019-02-24 07:31:36.141 (idetect) Parsing user and optional keyfile from:it
2019-02-24 07:31:36.141 (idetect) Monitoring {'Nicolas': {'ignore': False, 'lastseen': None, 'mac': '94:65:2D:A5:C9:C2'}} for presence.
2019-02-24 07:31:36.141 (idetect) 1 of them will control the Anyone home switch
2019-02-24 07:31:36.141 (idetect) Router configuration:192.168.21.19
2019-02-24 07:31:36.141 (idetect) Fetching data from 192.168.21.19 using: ssh -i -o ConnectTimeout=3 -p22 [email protected]
#!/bin/sh
export PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH
type wl > /dev/null 2>&1 && printf "~wl"
type iwinfo > /dev/null 2>&1 && printf "~iwinfo"
type wlanconfig > /dev/null 2>&1 && printf "~wlanconfig"
type qcsapi_sockrpc > /dev/null 2>&1 && printf "~qcsapi_sockrpc"
type brctl > /dev/null 2>&1 && printf "~brctl"
type arp > /dev/null 2>&1 && printf "~arp"
[ -f /proc/net/arp ] && printf "~procarp"
exit
2019-02-24 07:31:36.527 (idetect) ssh command on 192.168.21.19 returned:b'~wlanconfig~brctl~arp~procarp'
2019-02-24 07:31:36.527 (idetect) SSH command on 192.168.21.19 took 385 milliseconds.
2019-02-24 07:31:36.528 (idetect) Available commands on 192.168.21.19:['wlanconfig', 'brctl', 'arp', 'procarp']
2019-02-24 07:31:36.528 (idetect) Fetching data from 192.168.21.19 using: ssh -i -o ConnectTimeout=3 -p22 [email protected]
#!/bin/sh
export PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH
for iface in $(ifconfig | cut -d ' ' -f1| tr ':' '
' | grep -E '^eth|^wlan|^ath');do
wlanconfig $iface list > /dev/null 2>&1 && printf "~$iface"
done
exit
2019-02-24 07:31:36.945 (idetect) ssh command on 192.168.21.19 returned:b'~ath0~ath1~eth0~eth0.40'
2019-02-24 07:31:36.945 (idetect) SSH command on 192.168.21.19 took 417 milliseconds.
2019-02-24 07:31:36.945 (idetect) Found suitable command (and interfaces) for router 192.168.21.19:{'wlanconfig': ['ath0', 'ath1', 'eth0', 'eth0.40']}
2019-02-24 07:31:36.946 Error: (idetect) 'onStart' failed 'AttributeError':''module' object has no attribute 'Status''.
2019-02-24 07:31:36.946 Error: (idetect) ----> Line 677 in /home/pi/domoticz/plugins/Domoticz_iDetect/plugin.py, function onStart
2019-02-24 07:31:36.946 Error: (idetect) ----> Line 489 in /home/pi/domoticz/plugins/Domoticz_iDetect/plugin.py, function onStart
2019-02-24 07:31:36.946 Error: (idetect) ----> Line 279 in /home/pi/domoticz/plugins/Domoticz_iDetect/plugin.py, function getrouter
2019-02-24 07:31:44.391 (RFXCOM) Temp + Humidity (Fond salle cinéma)
2019-02-24 07:31:45.568 Error: (idetect) Plugin initialization did not complete successfully. Check the (debug) log for startup errors.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 24 February 2019 20:10
by EscApe
@number8,

It looks like the Domoticz.Status (logging) method was not available in your version of Domoticz. It should work if you update, but if you want to stay with that Domoticz version there might also be a solution: replace every ‘Domoticz.Status’ with ‘Domoticz.Log’ in plugin.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 24 February 2019 20:47
by Number8
Thanks EscApe.
You have guessed well. I don't want to update now, rather complex setup, I'll wait spring time when there is no needed for heating.
I tried what you suggested. Unfortunately I get new errors
2019-02-24 20:41:17.567 Error: (idetect) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz_iDetect/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2019-02-24 20:41:17.567 Error: (SalleàManger) Module Import failed, exception: 'SyntaxError'
2019-02-24 20:41:17.567 Error: (SalleàManger) Import detail: File: /home/pi/domoticz/plugins/Domoticz_iDetect/plugin.py, Line: 213, offset: 13
2019-02-24 20:41:17.567 Error: (SalleàManger) Error Line ' sendir,1:3,1("Using preconfigured custom command on router " + host + ": " + pollscript)

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 27 February 2019 7:55
by EscApe
@Number8

Strange that you now get a syntax error. Maybe you accidentally changed more than just the Domoticz.Status to Domoticz.Log?

I have created a new brach on GitHub called 'For-older-Domoticz-(not-maintained)'. This version does not use the Domoticz.Status method. If you take the plugin.py from that branch it should work.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 27 February 2019 19:41
by Number8
EscApe wrote: Wednesday 27 February 2019 7:55 Strange that you now get a syntax error. Maybe you accidentally changed more than just the Domoticz.Status to Domoticz.Log?
Tripled checked. Unfortunately no error on my side
I have created a new brach on GitHub called 'For-older-Domoticz-(not-maintained)'. This version does not use the Domoticz.Status method. If you take the plugin.py from that branch it should work.
Thanks lot for that, I'll check this week-end and keep you posted
Nicolas

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 02 March 2019 8:52
by Number8
EscApe wrote: Wednesday 27 February 2019 7:55 @Number8

Strange that you now get a syntax error. Maybe you accidentally changed more than just the Domoticz.Status to Domoticz.Log?

I have created a new branch on GitHub called 'For-older-Domoticz-(not-maintained)'. This version does not use the Domoticz.Status method. If you take the plugin.py from that branch it should work.
Brilliant, it works like a charm now. Thanks a lot for your support.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 7:06
by Number8
@EscApe I have 3 Unifi AP's and likely more to come, so I ended up up with 3 Anyone buttons. Would be great I guess to have one master Anyone button. Is this something that could considered?

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 8:25
by EscApe
<something went wrong with this post... please ignore it>

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 8:38
by EscApe
@Number8,

There already are a few options:

1. Configure the plugin once, with 3 routers (separated with comma) instead of adding the plugin 3 times. (described on configuration page)

2. Use the override button in the 'master' plugin. It's a bit tricky: set the override mode for the master to 'Override indefinately' and use a (Lua) script to turn the Override switch on that master on/off based on the Anyone switch of the other AP's.

3. Use te plugin on only one of the AP's en force it to use ARP instead of (the preferred!) chipset based detection approach. (described on GitHub page)

4. If you happen to find a (proprietary Unifi) command on the AP's that returns all connected Mac addresses on all AP's in a network/mesh from one command on one AP then I can add it to the plugin (has to be something quicker and more reliable than ARP).

I would go with option 1 ;-)

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 9:52
by mikeoo
Number8 wrote: Sunday 03 March 2019 7:06 @EscApe I have 3 Unifi AP's and likely more to come, so I ended up up with 3 Anyone buttons. Would be great I guess to have one master Anyone button. Is this something that could considered?
I also use 3 Unify AP and have only one Anyhome button.
In Hardware page of Domoticz i use al 3 ip-adresses for Wifi Router Ip-adres like: 192.168.0.201,192.168.0.202,192.168.0.203

Now it scans al 3 AP without any problems.

Setup: https://www.domoticz.com/forum/viewtopi ... 20#p197905

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 10:44
by Varazir
I guess this has been asked before but please let us change the port to use.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 11:08
by Varazir
I have a pfSense router and trying to use this plugin.
I get this:

Code: Select all

2019-03-03 11:05:54.012 (iDetect) Could not construct router query command for <IP>
2019-03-03 11:05:54.013 (iDetect) Router initialized as:{'<IP>': {'initialized': False, 'cmd': '', 'port': <port>, 'prospone': datetime.datetime(2019, 3, 3, 11, 6, 6, 12931), 'user': 'domoticz', 'errorcount': 1}}
pfSense based on FreeBSD

I checked the plugin file and found it's using this command

Code: Select all

arp -a | grep '..:..:..:..:..:..' | awk '{print $ 4}' 
Ran it manually and I got a list of MAC addresses.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 03 March 2019 11:12
by mikeoo
Varazir wrote: Sunday 03 March 2019 10:44 I guess this has been asked before but please let us change the port to use.
Edit file plugin.py there you can change the portnumber if needed. Just search for port.