Python plugin: Presence detection from wireless router

Python and python framework

Moderator: leecollings

Post Reply
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by quack3d »

Looks like import ctypes is the problem. I get nothing from the log if I have only that line.

Trying to google how to disable the redirection globally but no luck so far.
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by quack3d »

Ok. A step forward I think. I used C:\Windows\SysNative\OpenSSH\ as path. 32-bit programs apparently will go to System32 if using SysNative.

Checking if [C:\Windows\SysNative\OpenSSH\ssh -V] will run: OK

So, log now says:

Code: Select all

2018-06-03 19:25:21.521 Error: (iDetect) SSH subprocess failed with error: Command '['C:\\Windows\\SysNative\\OpenSSH\\ssh', '-o', 'ConnectTimeout=2', '[email protected]', '#!/bin/sh\n\t\t\t\t\texport PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH\n\t\t\t\t\ttest=$(which wl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wl@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wl -i $iface assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\ttest=$(which iwinfo > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "iwinfo@"\n\t\t\t\t\t\t\tfor iface in $(iwinfo | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo wlan0 assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\t\n\t\t\t\t\ttest=$(which arp > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "arp"\n\t\t\t\t\tfi']' timed out after 4 seconds
2018-06-03 19:25:21.522 Error: (iDetect) Could not determine router capabilities
I then tried the following in a shell instead:

Code: Select all

test = subprocess.run(['C:\\Windows\\SysNative\\OpenSSH\\ssh', '-o', 'ConnectTimeout=2', '[email protected]', '#!/bin/sh\n\t\t\t\t\texport PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH\n\t\t\t\t\ttest=$(which wl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wl@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wl -i $iface assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\ttest=$(which iwinfo > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "iwinfo@"\n\t\t\t\t\t\t\tfor iface in $(iwinfo | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo wlan0 assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\t\n\t\t\t\t\ttest=$(which arp > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "arp"\n\t\t\t\t\tfi'])
And the line changed from >>> to wl@eth1 eth2 >>>. Also, I checked in router log and it said 'Pubkey auth succeeded for 'admin' with key sha1!! ..." When iDetect does it it said "Exit before auth: Error reading: Connection reset by peer".

EDIT: Another step forward. Changed the Domoticz service to use my user account instead of system. Now router says:

Jun 3 20:09:45 dropbear[12614]: Child connection from 10.0.0.10:7529
Jun 3 20:09:47 dropbear[12614]: Pubkey auth succeeded for 'admin' with key sha1!! xxxxxxxxxxxxxxxxxx from 10.0.0.10:7529
Jun 3 20:09:47 dropbear[12614]: Exit (admin): Disconnect received

But I still get that error in Domoticz.
User avatar
BUSHA
Posts: 13
Joined: Tuesday 13 June 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8367
Location: Kharkiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by BUSHA »

Don't work on my Xiaomi Mi-Mini router with Padavan firmware.
But If I connecting directly to router by ssh then "arp -a | awk '{print $ 4}'" command return perfectly clean mac addresses list..

FInd log below:
Spoiler: show
2018-06-03 22:03:30.305 Error: (iDetect) No usable commandline to check presence. Trying again to detect router capabilities.
2018-06-03 22:03:30.305 Error: (iDetect) If you keep getting this message: check your (authentication) settings and router status.
2018-06-03 22:03:30.305 Error: (iDetect) Make sure your router supports ssh and the commands used by this plugin. If this message persists disable the plugin (for now), or the plugin might flood the Domoticz eventsystem
2018-06-03 22:03:30.305 Error: (iDetect) Temporarily limiting the polling frequency to twice a minute after encountering more than 5 (ssh) errors in a row.
2018-06-03 22:03:30.305 Error: (iDetect) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-06-03 22:03:30.306 Error: (iDetect) Could not determine router capabilities
2018-06-03 22:04:00.286 (iDetect) Pushing 'onHeartbeatCallback' on to queue
2018-06-03 22:04:00.309 (iDetect) Processing 'onHeartbeatCallback' message
2018-06-03 22:04:00.309 (iDetect) Calling message handler 'onHeartbeat'.
2018-06-03 22:04:00.309 (iDetect) devid2domid: {'device1': 3, 'device2': 2}
2018-06-03 22:04:00.310 (iDetect) Checking router capabilities and wireless interfaces
2018-06-03 22:04:00.310 (iDetect) Pushing 'PollIntervalDirective' on to queue
2018-06-03 22:04:00.310 (iDetect) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-06-03 22:04:00.310 (iDetect) Could not detemine the user profile running Domoticz
2018-06-03 22:04:00.310 (iDetect) Fetching data from router using ssh
2018-06-03 22:04:00.310 (iDetect) command: ['ssh', '-o', 'ConnectTimeout=2', '[email protected]', '#!/bin/sh\n\t\t\t\t\texport PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH\n\t\t\t\t\ttest=$(which wl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wl@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wl -i $iface assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\ttest=$(which iwinfo > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "iwinfo@"\n\t\t\t\t\t\t\tfor iface in $(iwinfo | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo wlan0 assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\t\n\t\t\t\t\ttest=$(which arp > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "arp"\n\t\t\t\t\tfi']
2018-06-03 22:04:00.310 (iDetect) Processing 'PollIntervalDirective' message
2018-06-03 22:04:00.310 (iDetect) Heartbeat interval set to: 30.
EscApe
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

Post by EscApe »

@quack3d

I did not modify the plugin (and have not setup key authentication on Windows) but ran some of the commands as a simulation in the Windows Python shell. The SysNative path lets me run the commands as expected. Even the remote sh script for router capability detection. Thats very promising!

Could you try removing the shell=True additions you made to the subprocess.run lines? In my tests they stop the commands from returning (anything to) the Python command prompt.

So far i think the plugin might run without any modification if:
- key based authentication is setup for the right user (you know more about setting that up on Windows than I do ;-))
- the PATH for the Domoticz/Python processes list C:\Windows\SysNative\OpenSSH\ before C:\Windows\System32\OpenSSH\ (can you set it for the Domoticz process?)

If this turns out to be the case, then it seems better to write some instructions for a Windows setup instead of adding complexity to the plugin itself (OS detection and OS specific work-arounds).
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by quack3d »

I had them removed before my last reply. Not sure why I get the error. It authenticates with the router. Doesn't see my phone as online though.
EscApe
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

Post by EscApe »

@BUSHA

The thing in your log that caught my eye is: SSH subprocess failed with error: 'module' object has no attribute 'run'
The startup of the plugin is missing from your log, but this looks like it is telling us that the subprocess module has no .run method. Which is strange, because that is a standard module for Python3.

Things you could check:
- Python version as displayed in Domoticz under Settings>About
- Run Python3 from the command line and enter import subprocess --> see what happens
If that is all correct also:
- If you use key based authentication: make sure key based access is setup for the right user (the user that runs the Domoticz process/daemon)

Are you running Domoticz on Linux?
EscApe
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

Post by EscApe »

@quack3d

At least were making progress;-) Can you provide a debug log of the now running plugin? From the time it starts up until at least the first heartbeat (poll).

What router are you using?
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by quack3d »

RT-AC68U

Just restarted the service but haven't gotten the/an error yet. Weird. Anyways, here is debug log:

Code: Select all

2018-06-03 22:10:57.592 (iDetect) Started.
2018-06-03 22:10:57.856 (iDetect) Initialized version 0.3.1, author 'ESCape'
2018-06-03 22:10:57.856 (iDetect) Entering work loop.
2018-06-03 22:10:57.857 (iDetect) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2018-06-03 22:10:57.870 (iDetect) Checking if [C:\Windows\SysNative\OpenSSH\ssh -V] will run: OK
2018-06-03 22:10:57.870 (iDetect) Monitoring {'phone1': '28:28:28:28:28:28'} for presence.
2018-06-03 22:10:57.870 (iDetect) Pushing 'PollIntervalDirective' on to queue
2018-06-03 22:10:57.870 (iDetect) Checking router capabilities and wireless interfaces
2018-06-03 22:10:57.870 (iDetect) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-06-03 22:10:57.870 (iDetect) Fetching data from router using ssh
2018-06-03 22:10:57.870 (iDetect) command: ['C:\\Windows\\SysNative\\OpenSSH\\ssh', '-o', 'ConnectTimeout=2', '[email protected]', '#!/bin/sh\n\t\t\t\t\texport PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH\n\t\t\t\t\ttest=$(which wl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wl@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wl -i $iface assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\ttest=$(which iwinfo > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "iwinfo@"\n\t\t\t\t\t\t\tfor iface in $(iwinfo | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo wlan0 assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\t\n\t\t\t\t\ttest=$(which arp > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "arp"\n\t\t\t\t\tfi']
2018-06-03 22:11:00.457 (iDetect) Returncode ssh command: 0
2018-06-03 22:11:00.458 (iDetect) Output from router: b'wl@eth1 eth2 '
2018-06-03 22:11:00.459 (iDetect) Parsed data from router: ['wl', 'eth1 eth2 ']
2018-06-03 22:11:00.459 (iDetect) Using wl command on router (best method) for interfaces ['eth1', 'eth2']
2018-06-03 22:11:00.459 (iDetect) Constructed this cmd for the router to poll for present phones: export PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH;wl -i eth1 assoclist | cut -d' ' -f2;wl -i eth2 assoclist | cut -d' ' -f2;exit
2018-06-03 22:11:00.459 (iDetect) monitoring device: iDetect - phone1
2018-06-03 22:11:00.459 (iDetect) iDetect - phone1 is stil in use
2018-06-03 22:11:00.459 (iDetect) devid2domid: {'phone1': 2}
2018-06-03 22:11:00.460 (iDetect) monitormacs: {'phone1': '28:28:28:28:28:28'}
2018-06-03 22:11:00.460 (iDetect) Processing 'PollIntervalDirective' message
2018-06-03 22:11:07.370 (iDetect) Pushing 'onHeartbeatCallback' on to queue
User avatar
BUSHA
Posts: 13
Joined: Tuesday 13 June 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8367
Location: Kharkiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by BUSHA »

@EscApe

Thank you for reply!

Python Version: 3.4.2

Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subproces
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'subproces'

For now I'm using password auth.

I'm running domoticz on Raspbian
EscApe
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

Post by EscApe »

@BUSHA

You missed a 's' in subprocess

Can you try this and share the output?:

Code: Select all

import subprocess
subprocess.run(["sshpass", "-V"])
User avatar
BUSHA
Posts: 13
Joined: Tuesday 13 June 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8367
Location: Kharkiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by BUSHA »

@EscApe

>>> import subprocess
>>> subprocess.run(["sshpass", "-V"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'run'
>>>
EscApe
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

Post by EscApe »

@quack3d:

I'm assuming 28:28:28:28:28:28 is there for privacy purposes and not the actual MAC address you configured for your phone(?)

From the log it looks like the plugin is running fine. At least the initialization part.
Have you checked if the devices are now switching off when you disable wifi on the phone? Wait for at least the 'grace period' + 1 extra poll interval (you set those in the plugin configuration page). Is the domoticz device ever switched on or off (shown in the device log)?

Your log fragments ends before the poll is actually performed. Can you provide a bit more logging? The debug log should show the mac addresses it gets from the router.
EscApe
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

Post by EscApe »

@BUSHA

So subprocess is not as 'standard' as i thought(?) Please install the Python subprocess module and try again.

Edit: It looks like subprocess.run might require Python 3.5 or higher. Not sure about that, but i don't see it in the documentation for python 3.4.
Last edited by EscApe on Sunday 03 June 2018 23:15, edited 2 times in total.
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by quack3d »

Yes, 28:28... for privacy purposes. The device is Off and never turns to On. There isn't more logging. Just 'Pushing 'onHeartbeatCallback' on to queue' over and over again.

Btw, from my router log it looks like it's only connecting when I restart the Domoticz service. That's the only time the log says this:

Jun 3 22:47:38 dropbear[16622]: Child connection from 10.0.0.10:12086
Jun 3 22:47:40 dropbear[16622]: Pubkey auth succeeded for 'admin' with key sha1!! xxxxxxxx from 10.0.0.10:12086
Jun 3 22:47:40 dropbear[16622]: Exit (admin): Disconnect received
User avatar
BUSHA
Posts: 13
Joined: Tuesday 13 June 2017 17:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8367
Location: Kharkiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by BUSHA »

@EscApe
Looks like that subprocess It's standard module.. problem in another place.
Anyway I spent too much time for this. Better to continue living without "phone online" notifications :D

Anyway thank you!
EscApe
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

Post by EscApe »

@quack3d

That’s strange. In debug mode the first thing it does on a heartbeat is send something quite simple to the log and even that is not showing up. Makes me wonder if this is a Domoticz issue(?)

I will have to investigate and install Domoticz on windows myself. Not today ... I’m pushing bedtime onto my event queue;-)
EscApe
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

Post by EscApe »

@quack3d

After setting up Domoticz and ssh key based authentication on a (virtual) Windows machine I ended up with the same situation. Even if i replace the entire heartbeat function with a simple message it never shows up in the log. I know there are some issues with different python versions and the Domoticz plugin framework on Linux. That's why I compiled my Domoticz on Linux instead of installing the binaries. Maybe the same goes for Windows?

Good news is that I figured out a way for the plugin to detect the OS en use the full ssh path (you provided) on Windows, without requiring additional modules. Unfortunately it will be useless if the onheartbeat function won't run.

I'm sorry, but at this time i cannot spend the amount of time required to make the plugin work on Windows or to compile Domoticz myself for further testing. For now it will just have to be a Linux compatible plugin.
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by quack3d »

Ok. Thanks for trying. Hope you'll find a way someday.
canix1
Posts: 9
Joined: Friday 25 May 2018 20:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by canix1 »

Hi,

Just installed iDetect.
I have verified that the SSH is working using the private key but I get these errors.

Code: Select all

2018-06-06 00:50:18.063 (iDetect) Pushing 'onHeartbeatCallback' on to queue 
2018-06-06 00:50:18.073 (iDetect) Processing 'onHeartbeatCallback' message 
2018-06-06 00:50:18.073 (iDetect) Calling message handler 'onHeartbeat'. 
2018-06-06 00:50:18.073 (iDetect) devid2domid: {'IPhone': 3, 'Android': 4, 'Microsoft': 2} 
2018-06-06 00:50:18.073 Error: (iDetect) No usable commandline to check presence. Trying again to detect router capabilities. 
2018-06-06 00:50:18.074 Error: (iDetect) If you keep getting this message: check your (authentication) settings and router status. 
2018-06-06 00:50:18.074 Error: (iDetect) Make sure your router supports ssh and the commands used by this plugin. If this message persists disable the plugin (for now), or the plugin might flood the Domoticz eventsystem 
2018-06-06 00:50:18.074 (iDetect) Checking router capabilities and wireless interfaces 
2018-06-06 00:50:18.074 Error: (iDetect) Temporarily limiting the polling frequency to twice a minute after encountering more than 5 (ssh) errors in a row. 
2018-06-06 00:50:18.074 (iDetect) Pushing 'PollIntervalDirective' on to queue 
2018-06-06 00:50:18.074 (iDetect) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz. 
2018-06-06 00:50:18.074 (iDetect) Could not detemine the user profile running Domoticz 
2018-06-06 00:50:18.074 (iDetect) Fetching data from router using ssh 
2018-06-06 00:50:18.075 (iDetect) command: ['ssh', '-o', 'ConnectTimeout=2', '[email protected]', '#!/bin/sh\n\t\t\t\t\texport PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH\n\t\t\t\t\ttest=$(which wl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wl@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wl -i $iface assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\ttest=$(which iwinfo > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "iwinfo@"\n\t\t\t\t\t\t\tfor iface in $(iwinfo | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo wlan0 assoclist > /dev/null 2>&1)\n\t\t\t\t\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\t\t\t\t\tprintf "$iface "\n\t\t\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\tdone\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\t\n\t\t\t\t\ttest=$(which arp > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "arp"\n\t\t\t\t\tfi'] 
2018-06-06 00:50:18.075 Error: (iDetect) SSH subprocess failed with error: 'module' object has no attribute 'run' 
2018-06-06 00:50:18.075 Error: (iDetect) Could not determine router capabilities 
2018-06-06 00:50:18.075 (iDetect) Processing 'PollIntervalDirective' message 
2018-06-06 00:50:18.075 (iDetect) Heartbeat interval set to: 30. 
Any suggestions?

Cheers
EscApe
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

Post by EscApe »

Hi Canix,

The plugin requires Python3.5 or higher. Looks like you are running 3.4?
Post Reply

Who is online

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