Python plugin: Presence detection from wireless router

Python and python framework

Moderator: leecollings

Rob67ert
Posts: 20
Joined: Tuesday 24 December 2019 13:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Rob67ert »

It will detect but only on ip, not on mac adress.
I get the same error every time there is a poll, now every 30 seconds.
User avatar
Freakandel
Posts: 24
Joined: Tuesday 18 June 2019 14:23
Target OS: Linux
Domoticz version:
Location: Netherlands, Breda region
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Freakandel »

I have an Asus RT-AC88U router with the latest Merlin firmware. I am using a 'ping' script in Domoticz for presence detection, but I want to get going with iPresence. I can't figure out sadly what and how I have to install (prerequisits and plugin). I'm fairly new to RasPi and not a developer ... :?:
Can someone help me out here? Thanks in advance!

Update: I've found the dependancy of PIP and Paramiko, so I have installed PIP first, then I tried to install Paramiko, but I get stuck at "Running setup.py bdist_wheel for pynacl..." a long time. I will let it running during the night, but it is allready running for 20 minutes now.

Update 2: The installation of Paramiko succeeded after all. It took about 35 minutes. After rebooting the RasPi the plugin worked as a charme.

Question: I have 3 Asus routers, 1 main, internet connected, router (the RT-AC88U) as a mesh base with DNS and DHCP, an Asus RT-AC66U as Mesh slave and an older Asus stand-alone router (not part of the mesh network). Are all connected devices, wired or wireless, visible even when not connected directly to the main router? :?:
Last edited by Freakandel on Wednesday 25 December 2019 10:21, edited 2 times in total.
Mrrodz
Posts: 22
Joined: Sunday 06 December 2015 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Mrrodz »

EscApe wrote: Tuesday 17 December 2019 0:10 Hi Mrrodz,

Good to hear that detection is working. To diagnose the error message I will need some more information. Can you enable debug mode and share the debug log? I'm especially interested in the configuration used and the commands send and response received over ssh (you can remove any passwords and/or share as PM for safety).

A configuration like <router ip>#type=unifiusg-arp should only execute ishow arp (old style configuration should also work)
Do you get any messages/errors when running ishow arp from the command line on the router?

One thing that has changes is that I removed some (seemingly) redundant path and exit statements around some commands. That may or may not be a problem on the unify. You could try the following configuration to test this:

Code: Select all

<routerip>#ssh=ishow arp;exit
Please share the results.
Hi EscApe,

These are from my logs
2019-12-24 21:45:47.780 (iDetect) onHeartbeat called
2019-12-24 21:45:47.781 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:45:57.745 (iDetect) 192.168.10.4 Timed poll starting like clockwork
2019-12-24 21:45:57.746 (iDetect) 192.168.10.4 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x6290e830>>
2019-12-24 21:45:57.747 (iDetect) 192.168.10.4 ====> SSH Fetching data using: /usr/sbin/wlanconfig ath0 list
2019-12-24 21:45:57.778 (iDetect) 192.168.10.4 ====> SSH returned (decoded):ADDR AID CHAN TXRATE RXRATE RSSI IDLE TXSEQ RXSEQ CAPS STATE MAXRATE(DOT11) DHCP TIME_TO_IP HTCAPS MODE PSMODE ASSOCTIME IEs
2019-12-24 21:45:57.778 (iDetect) 192.168.10.4 ====> SSH session took 31 milliseconds.
2019-12-24 21:45:57.780 (iDetect) Inbound data from: 192.168.10.4 containing ['00:04:20:F1:89:44', '1C:4D:66:AC:D4:AA', '7C:D5:66:F5:14:13', 'F0:81:73:F9:FB:98']
2019-12-24 21:45:57.780 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:45:57.806 (iDetect) onHeartbeat called
2019-12-24 21:45:57.806 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:45:57.778 Error: (iDetect) 192.168.10.4 ====> SSH returned error:Not supported
2019-12-24 21:45:59.212 (iDetect) 192.168.10.3 Timed poll starting like clockwork
2019-12-24 21:45:59.212 (iDetect) 192.168.10.3 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x62f03cd0>>
2019-12-24 21:45:59.212 (iDetect) 192.168.10.3 ====> SSH Fetching data using: /usr/sbin/wlanconfig ath0 list
2019-12-24 21:45:59.256 (iDetect) 192.168.10.3 ====> SSH returned (decoded):ADDR AID CHAN TXRATE RXRATE RSSI IDLE TXSEQ RXSEQ CAPS STATE MAXRATE(DOT11) DHCP TIME_TO_IP HTCAPS MODE PSMODE ASSOCTIME IEs
2019-12-24 21:45:59.256 (iDetect) 192.168.10.3 ====> SSH session took 43 milliseconds.
2019-12-24 21:45:59.258 (iDetect) Inbound data from: 192.168.10.3 containing ['04:CF:8C:97:A7:49', 'B8:27:EB:DD:78:A2', 'B8:27:EB:8E:5B:D9', '5C:CF:7F:02:95:BD', 'F0:FE:6B:62:E3:D2', '84:0D:8E:AB:B4:28', '84:0D:8E:AB:AA:C5', '48:E2:44:C1:61:0F', 'AC:CF:23:3F:8C:AA', 'D8:0D:17:D8:53:06', '68:FF:7B:CC:B4:C7', 'E4:8B:7F:DB:C6:49', 'C4:36:6C:12:9B:98', '00:26:29:00:28:3A', '40:CB:C0:3A:EC:77', 'E4:CE:8F:10:83:7A']
2019-12-24 21:45:59.258 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:45:59.256 Error: (iDetect) 192.168.10.3 ====> SSH returned error:Not supported
2019-12-24 21:46:00.510 Status: dzVents: Debug: Processing device-adapter for iDetect - Anyone: Switch device adapter
2019-12-24 21:46:07.824 (iDetect) onHeartbeat called
2019-12-24 21:46:07.824 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:46:22.738 (iDetect) onHeartbeat called
2019-12-24 21:46:22.738 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:46:33.047 (iDetect) onHeartbeat called
2019-12-24 21:46:33.048 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:46:43.082 (iDetect) onHeartbeat called
2019-12-24 21:46:43.083 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:46:57.347 (iDetect) onHeartbeat called
2019-12-24 21:46:57.348 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:46:59.260 (iDetect) 192.168.10.3 Timed poll starting like clockwork
2019-12-24 21:46:59.260 (iDetect) 192.168.10.3 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x62f03cd0>>
2019-12-24 21:46:59.260 (iDetect) 192.168.10.3 ====> SSH Fetching data using: /usr/sbin/wlanconfig ath0 list
2019-12-24 21:46:59.303 (iDetect) 192.168.10.3 ====> SSH returned (decoded):ADDR AID CHAN TXRATE RXRATE RSSI IDLE TXSEQ RXSEQ CAPS STATE MAXRATE(DOT11) DHCP TIME_TO_IP HTCAPS MODE PSMODE ASSOCTIME IEs
2019-12-24 21:46:59.303 (iDetect) 192.168.10.3 ====> SSH session took 42 milliseconds.
2019-12-24 21:46:59.307 (iDetect) Inbound data from: 192.168.10.3 containing ['04:CF:8C:97:A7:49', 'B8:27:EB:DD:78:A2', 'B8:27:EB:8E:5B:D9', '5C:CF:7F:02:95:BD', 'F0:FE:6B:62:E3:D2', '84:0D:8E:AB:B4:28', '84:0D:8E:AB:AA:C5', '48:E2:44:C1:61:0F', 'AC:CF:23:3F:8C:AA', 'D8:0D:17:D8:53:06', '68:FF:7B:CC:B4:C7', 'E4:8B:7F:DB:C6:49', 'C4:36:6C:12:9B:98', '00:26:29:00:28:3A', '40:CB:C0:3A:EC:77', 'E4:CE:8F:10:83:7A']
2019-12-24 21:46:59.308 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:46:59.303 Error: (iDetect) 192.168.10.3 ====> SSH returned error:Not supported
2019-12-24 21:47:00.541 Status: dzVents: Debug: Processing device-adapter for iDetect - Anyone: Switch device adapter
2019-12-24 21:47:07.368 (iDetect) onHeartbeat called
2019-12-24 21:47:07.368 (iDetect) 1 devices are present (excluding ignored devices)
2019-12-24 21:47:17.333 (iDetect) onHeartbeat called
to get this to work with my unifi setup was to allow a custom ssh key, i followed a guide on here a few posts back.

thanks i will try that out
Attachments
Screen Shot 2019-12-24 at 21.58.47.png
Screen Shot 2019-12-24 at 21.58.47.png (268.06 KiB) Viewed 1754 times
JediMax
Posts: 14
Joined: Tuesday 23 April 2019 14:35
Target OS: Linux
Domoticz version: 2020.2
Location: Kyiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by JediMax »

I install new version. And at start I have some errors in log
2019-12-26 15:18:42.652 Error: (iDetect) 'onStart' failed 'ImportError'.
2019-12-26 15:18:42.652 Error: (iDetect) ----> Line 427 in '/home/domoticz/plugins/iDetect/plugin.py', function onStart
2019-12-26 15:18:42.652 Error: (iDetect) ----> Line 212 in '/home/domoticz/plugins/iDetect/plugin.py', function onStart
2019-12-26 15:18:42.652 Error: (iDetect) ----> Line 11 in '/home/domoticz/plugins/iDetect/trackers/__init__.py', function <module>
2019-12-26 15:18:42.652 Error: (iDetect) ----> Line 7 in '/home/domoticz/plugins/iDetect/trackers/http_orbi.py', function <module>

What I do wrong?
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 »

@JediMax

Seems like the requests python module is not installed (by default). Can you try it after installing. On linux run the command below and restart domoticz or the whole system to be sure.

Code: Select all

sudo pip3 install requests
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 »

@Rob67ert

I really need more information to assess your situation. Can you enable debugging and share the debug log? What router make and model are you using?
Last edited by EscApe on Friday 27 December 2019 7:42, edited 1 time in total.
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 »

@Mrrodz,

Strange... both access points seem te return correct data, so what is it trying to do that is not supported???
Have you tried running '/usr/sbin/wlanconfig ath0 list' from the command line on the access point? What is the make and model of the access points?
JediMax
Posts: 14
Joined: Tuesday 23 April 2019 14:35
Target OS: Linux
Domoticz version: 2020.2
Location: Kyiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by JediMax »

Thank you for answer.
I install requests python module. Then I reinstall plugin. When I add new hardware (using plugin), new hardware adds normally. But then Domoticz stops. In log last line is about starting iDetect plugin.
I use Xiaomi 3G router with alternative firmware (Padavan).

I try to add uncorrect data to trackers/user field. Domoticz working good.

I think the problem is when plugin trying to connect to router. I can connect from Domoticz board to router via ssh with any problem (ssh [email protected] without password).

There is router's log
Dec 27 20:11:33 sshd[8293]: Connection closed by 192.168.1.201 port 34245 [preauth]
Dec 27 20:12:50 sshd[8296]: Connection closed by 192.168.1.201 port 34247 [preauth]

I see plugin trying to connect to router via 34245, 34247 ports, but router closed connection.
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 »

@JediMax

It’s going to be challenging to diagnose a problem like this without access to the specific router. Maybe I can tell a little more from the full debug log.
Can you enable debug mode and share the debug log (from the start of the plugin until it fails)?

Ssh indeed looks like a suspect, but there could still be several reasons. A few things you can check without a debug log:
- what python version is showing in the domoticz ‘about’ screen?
- what version of Domoticz are you running?
- does the padavan firmware offer a real Linux cli or a proprietary command set? Please try and run this on the router:

Code: Select all

type wl; type iwinfo
this is a small part of the autodetect script, just to test if this Linux based method works on the padavan firmware.
Rob67ert
Posts: 20
Joined: Tuesday 24 December 2019 13:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Rob67ert »

@EscApe
Her the information:
Router: TP-Link ARCHER-C7 v2
Frimware: Firmware: DD-WRT v3.0-r40559 std (08/06/19)

Log met mac adress:
Tag monitor: Mobile_1=XX:XX:XX:XX:XX:XX,Mobile_2=XX:XX:XX:XX:XX:XX,Router=XX:XX:XX:XX:XX:XX

2019-12-28 11:26:10.949 (iDetect) onHeartbeat called
2019-12-28 11:26:10.950 (iDetect) 0 devices are present (excluding ignored devices)
2019-12-28 11:26:19.197 (iDetect) 192.168.178.2 Timed poll starting like clockwork
2019-12-28 11:26:19.200 (iDetect) 192.168.178.2 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x69d32fd0>>
2019-12-28 11:26:19.200 (iDetect) 192.168.178.2 ====> SSH Fetching data using: /usr/sbin/ip neighbourexit
2019-12-28 11:26:19.222 (iDetect) 192.168.178.2 ====> SSH returned (decoded):
2019-12-28 11:26:19.222 (iDetect) 192.168.178.2 ====> SSH session took 21 milliseconds.
2019-12-28 11:26:19.232 (iDetect) Inbound data from: 192.168.178.2 containing []
2019-12-28 11:26:19.232 (iDetect) 0 devices are present (excluding ignored devices)
2019-12-28 11:26:19.222 Error: (iDetect) 192.168.178.2 ====> SSH returned empty response. Transport active: True

Log met ip adress:
Tag monitor: Mobile_1=192.168.178.13,Mobile_2=192.168.178.10,Router=192.168.178.2

2019-12-28 11:41:17.602 (iDetect) onHeartbeat called
2019-12-28 11:41:17.602 (iDetect) 3 devices are present (excluding ignored devices)
2019-12-28 11:41:25.868 (iDetect) local pinger Timed poll starting like clockwork
2019-12-28 11:41:26.153 (iDetect) Tried pinging tag: 192.168.178.2 --> error_level (0 means online): 0
2019-12-28 11:41:26.155 (iDetect) Inbound data from: local pinger containing ['192.168.178.2']
2019-12-28 11:41:26.156 (iDetect) 3 devices are present (excluding ignored devices)
2019-12-28 11:41:26.158 (iDetect) 192.168.178.2 Timed poll starting like clockwork
2019-12-28 11:41:26.158 (iDetect) 192.168.178.2 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x686bdc30>>
2019-12-28 11:41:26.158 (iDetect) 192.168.178.2 ====> SSH Fetching data using: /usr/sbin/ip neighbourexit
2019-12-28 11:41:26.180 (iDetect) 192.168.178.2 ====> SSH returned (decoded):
2019-12-28 11:41:26.180 (iDetect) 192.168.178.2 ====> SSH session took 21 milliseconds.
2019-12-28 11:41:26.183 (iDetect) Inbound data from: 192.168.178.2 containing []
2019-12-28 11:41:26.183 (iDetect) 3 devices are present (excluding ignored devices)
2019-12-28 11:41:26.180 Error: (iDetect) 192.168.178.2 ====> SSH returned empty response. Transport active: True
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 »

@Rob67ert

Thanks. The log helped me find a little bug for the command that is used for your router. Please update to latest version and try again.
Something else caught my eye: The plugin is using a generic 'ip' command instead of the Atheros chipset specific command. Did you force this in the configuration or did auto detection of the available chipset command(s) fail? If you want to investigate further please share a complete debug log, including the startup of the plugin and its auto detection routine.
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 »

@freakandel
Question: I have 3 Asus routers, 1 main, internet connected, router (the RT-AC88U) as a mesh base with DNS and DHCP, an Asus RT-AC66U as Mesh slave and an older Asus stand-alone router (not part of the mesh network). Are all connected devices, wired or wireless, visible even when not connected directly to the main router?
I do not have a mesh setup to test this, but I would not be surprised if the chipset specific methods of the plugin only return the clients that are directly connected to that specific router/access point. Forcing one of the generic methods like brctl or ARP on the main router would eventually return all clients in the mesh, but I suspect it would be slower to respond to changes. Another option would be to add all three access points to the plugin.

If you or another mesh user can find a command on the ASUS router that works (quickly and reliably) for the entire mesh then I can add it as an option to the plugin.
Rob67ert
Posts: 20
Joined: Tuesday 24 December 2019 13:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Rob67ert »

@EscApe

I update to the latetst version 2.0 (just downloaded it today)
I did not force anything, simply because I don't know how :-)
Can you tell me how to force it to the correcd chipset?

Log met mac adress:
Tag monitor: Mobile_1=XX:XX:XX:XX:XX:XX,Mobile_2=XX:XX:XX:XX:XX:XX,Router=XX:XX:XX:XX:XX:XX

2019-12-28 14:24:03.407 (iDetect) onHeartbeat called
2019-12-28 14:24:03.408 (iDetect) 0 devices are present (excluding ignored devices)
2019-12-28 14:24:11.547 (iDetect) 192.168.178.2 Timed poll starting like clockwork
2019-12-28 14:24:11.547 (iDetect) 192.168.178.2 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x6a70ae50>>
2019-12-28 14:24:11.547 (iDetect) 192.168.178.2 ====> SSH Fetching data using: /usr/sbin/ip neighbour
2019-12-28 14:24:11.547 exit
2019-12-28 14:24:11.565 (iDetect) 192.168.178.2 ====> SSH returned (decoded):
2019-12-28 14:24:11.565 (iDetect) 192.168.178.2 ====> SSH session took 18 milliseconds.
2019-12-28 14:24:11.567 (iDetect) Inbound data from: 192.168.178.2 containing []
2019-12-28 14:24:11.567 (iDetect) 0 devices are present (excluding ignored devices)
2019-12-28 14:24:11.565 Error: (iDetect) 192.168.178.2 ====> SSH returned empty response. Transport active: True
2019-12-28 14:24:13.375 (iDetect) onHeartbeat called
2019-12-28 14:24:13.378 (iDetect) 0 devices are present (excluding ignored devices)
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 »

@Rob67ert
Can you tell me how to force it to the correcd chipset?
There are several predefined methods that you can choose by adding #type=<method name> to the configuration and you can even construct your own custom command using #ssh=.... . However you first need to know what the command should be. If you share a full debug log -including the start of the plugin- there might be some pointers in there... maybe your router has the right commands but uses some unknown name for its interfaces (which the plugin would not find during auto detection).

Since I do not have access to every make and model of router I am afraid it is up to someone who has access to your type of router to find the proper command(s). You could experiment using the #ssh= option as described in the readme of the plugin, or (easier) directly on the routers command line. Google for something like “connected client list” and your router make/model/chipset ... maybe someone has already figured out something you can test.
Rob67ert
Posts: 20
Joined: Tuesday 24 December 2019 13:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Rob67ert »

@EscApe
Already thanks for the support :-)

Here the log from the start.

2019-12-28 15:32:20.912 Status: Domoticz V4.10717 (c)2012-2019 GizMoCuz
2019-12-28 15:32:20.931 Status: Build Hash: b38b49e5, Date: 2019-05-09 13:04:08
2019-12-28 15:32:20.932 Status: Startup Path: /home/pi/domoticz/
2019-12-28 15:32:21.590 Sunrise: 08:47:00 SunSet: 16:33:00
2019-12-28 15:32:21.590 Day length: 07:46:00 Sun at south: 12:40:00
2019-12-28 15:32:21.590 Civil twilight start: 08:06:00 Civil twilight end: 17:14:00
2019-12-28 15:32:21.590 Nautical twilight start: 07:22:00 Nautical twilight end: 17:58:00
2019-12-28 15:32:21.590 Astronomical twilight start: 06:41:00 Astronomical twilight end: 18:39:00
2019-12-28 15:32:22.947 Active notification Subsystems: pushbullet (1/13)
2019-12-28 15:32:22.926 Status: PluginSystem: Started, Python version '3.5.3'.
2019-12-28 15:32:23.221 Starting shared server on: :::6144
2019-12-28 15:32:23.174 Status: WebServer(HTTP) started on address: :: with port 8080
2019-12-28 15:32:23.208 Status: Camera: settings (re)loaded
2019-12-28 15:32:23.222 Status: TCPServer: shared server started...
2019-12-28 15:32:23.222 Status: RxQueue: queue worker started...
2019-12-28 15:32:23.266 Status: Incoming connection from: 192.168.178.4
2019-12-28 15:32:25.223 Status: Hardware Monitor: Started
2019-12-28 15:32:25.308 Status: (iDetect) Started.
2019-12-28 15:32:25.308 Status: EventSystem: reset all events...
2019-12-28 15:32:25.355 Status: EventSystem: reset all device statuses...
2019-12-28 15:32:25.579 Status: Python EventSystem: Initalizing event module.
2019-12-28 15:32:25.579 Status: EventSystem: Started
2019-12-28 15:32:25.579 Status: EventSystem: Queue thread started...
2019-12-28 15:32:25.677 Status: PluginSystem: Entering work loop.
2019-12-28 15:32:40.134 Status: (iDetect) Entering work loop.
2019-12-28 15:32:40.135 Status: (iDetect) Initialized version 2.0, author 'ESCape'
2019-12-28 15:32:45.311 (iDetect) Debug logging mask set to: PYTHON
2019-12-28 15:32:45.311 (iDetect) Operation system is: linux
2019-12-28 15:32:45.327 (iDetect) The OS user profile running domoticz is: root
2019-12-28 15:32:45.327 (iDetect) Parsing user and optional keyfile from:root
2019-12-28 15:32:45.327 (iDetect) start get or create wireless device
2019-12-28 15:32:45.327 (iDetect) Mobile_1 monitor tag_id:xx:xx:xx:18:D3:88, domoticz unit:4
2019-12-28 15:32:45.328 (iDetect) start get or create wireless device
2019-12-28 15:32:45.328 (iDetect) Mobile_2 monitor tag_id:xx:xx:xx:E6:F1:AA, domoticz unit:6
2019-12-28 15:32:45.328 (iDetect) start get or create wireless device
2019-12-28 15:32:45.328 (iDetect) Router monitor tag_id:xx:xx:xx:F5:9E:50, domoticz unit:9
2019-12-28 15:32:45.328 (iDetect) Monitoring {'xx:xx:xx:18:D3:88': <plugin.tag_device object at 0x6a3d4d90>, 'xx:xx:xx:E6:F1:AA': <plugin.tag_device object at 0x69826290>, 'xx:xx:xx:F5:9E:50': <plugin.tag_device object at 0x698269b0>} for presence.
2019-12-28 15:32:45.328 (iDetect) Tracker configuration:192.168.178.2
2019-12-28 15:32:45.328 (iDetect) tracker:192.168.178.2
2019-12-28 15:32:45.328 (iDetect) options:
2019-12-28 15:32:45.330 (iDetect) 192.168.178.2 Tracker is of the ssh kind
2019-12-28 15:32:45.330 (iDetect) 192.168.178.2 ====> SSH Fetching data using:
2019-12-28 15:32:45.330 export PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH
2019-12-28 15:32:45.330 type wl
2019-12-28 15:32:45.330 type iwinfo
2019-12-28 15:32:45.330 type wlanconfig
2019-12-28 15:32:45.330 type qcsapi_sockrpc
2019-12-28 15:32:45.330 type ip
2019-12-28 15:32:45.330 type brctl
2019-12-28 15:32:45.330 type arp
2019-12-28 15:32:45.330 [ -f /proc/net/arp ] && type cat
2019-12-28 15:32:45.330 echo 0
2019-12-28 15:32:45.330 exit
2019-12-28 15:32:45.330 (iDetect) 192.168.178.2 ====> SSH not connected ... connecting
2019-12-28 15:32:45.330 (iDetect) 192.168.178.2 ====> SSH start connect
2019-12-28 15:32:47.525 (iDetect) 192.168.178.2 ====> SSH returned (decoded):wl: not found
2019-12-28 15:32:47.525 iwinfo: not found
2019-12-28 15:32:47.525 wlanconfig: not found
2019-12-28 15:32:47.525 qcsapi_sockrpc: not found
2019-12-28 15:32:47.525 ip is /usr/sbin/ip
2019-12-28 15:32:47.525 brctl is /usr/sbin/brctl
2019-12-28 15:32:47.525 arp is /sbin/arp
2019-12-28 15:32:47.525 cat is /bin/cat
2019-12-28 15:32:47.525 0
2019-12-28 15:32:47.525
2019-12-28 15:32:47.525 (iDetect) 192.168.178.2 ====> SSH session took 195 milliseconds.
2019-12-28 15:32:47.526 (iDetect) Available commands on 192.168.178.2:{'cat': '/bin/cat', 'arp': '/sbin/arp', 'brctl': '/usr/sbin/brctl', 'ip': '/usr/sbin/ip'}
2019-12-28 15:32:47.526 (iDetect) 192.168.178.2 Prepared to poll using: /usr/sbin/ip neighbour
2019-12-28 15:32:47.526 exit
2019-12-28 15:32:47.527 (iDetect) 192.168.178.2 tracker will autodetect ssh cli
2019-12-28 15:32:47.527 (iDetect) 192.168.178.2 Data will be received and interpreted by <bound method BasePlugin.onDataReceive of <plugin.BasePlugin object at 0x690445f0>>
2019-12-28 15:32:47.527 (iDetect) Trackers initialized as:{'192.168.178.2': <trackers.ssh_autodetect.ssh_autodetect object at 0x69832410>}
2019-12-28 15:32:47.527 (iDetect) Plugin initialization done.
2019-12-28 15:32:47.501 Status: (iDetect) 192.168.178.2 ====> SSH connection established
2019-12-28 15:32:47.526 Status: (iDetect) 192.168.178.2 No supported chipset found. Using generic mode: ip
2019-12-28 15:32:47.527 Status: (iDetect) Tracker activated:192.168.178.2 port 22, user: root, type: default and options: {}
2019-12-28 15:33:17.677 (iDetect) 192.168.178.2 Timed poll starting like clockwork
2019-12-28 15:33:17.678 (iDetect) 192.168.178.2 Start poll and return results to <bound method tracker.receiver_callback of <trackers.ssh_autodetect.ssh_autodetect object at 0x69832410>>
2019-12-28 15:33:17.678 (iDetect) 192.168.178.2 ====> SSH Fetching data using: /usr/sbin/ip neighbour
2019-12-28 15:33:17.678 exit
2019-12-28 15:33:17.698 (iDetect) 192.168.178.2 ====> SSH returned (decoded):
2019-12-28 15:33:17.699 (iDetect) 192.168.178.2 ====> SSH session took 20 milliseconds.
2019-12-28 15:33:17.701 (iDetect) Inbound data from: 192.168.178.2 containing []
2019-12-28 15:33:17.702 (iDetect) 0 devices are present (excluding ignored devices)
2019-12-28 15:33:17.698 Error: (iDetect) 192.168.178.2 ====> SSH returned empty response. Transport active: True
Rob67ert
Posts: 20
Joined: Tuesday 24 December 2019 13:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Rob67ert »

@EscApe

It works :-)

With #type=brctl I got a whole list with mac adresses.
And no error.

Thanks for the support
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 »

@Rob67ert

Great! Happy to help.
Brctl is one of the generic methods. Generic methods will respond slower to changes from present to absent than hardware specific methods (depending on the router it might show a device as connected for many many minutes after leaving). It might still be worth investigating a hardware specific command. I would expect a router with atheros chipset to support wlanconfig, but the plugin can't find it. This might be DD-WRT specific.

@Anyone with TP-Link ARCHER-C7 v2 running DD-WRT v3.0
Maybe another owner of this make/model and firmware can chip in??
JediMax
Posts: 14
Joined: Tuesday 23 April 2019 14:35
Target OS: Linux
Domoticz version: 2020.2
Location: Kyiv, Ukraine
Contact:

Re: Python plugin: Presence detection from wireless router

Post by JediMax »

EscApe wrote: Friday 27 December 2019 22:53 @JediMax

It’s going to be challenging to diagnose a problem like this without access to the specific router. Maybe I can tell a little more from the full debug log.
Can you enable debug mode and share the debug log (from the start of the plugin until it fails)?

Ssh indeed looks like a suspect, but there could still be several reasons. A few things you can check without a debug log:
- what python version is showing in the domoticz ‘about’ screen?
- what version of Domoticz are you running?
- does the padavan firmware offer a real Linux cli or a proprietary command set? Please try and run this on the router:

Code: Select all

type wl; type iwinfo
this is a small part of the autodetect script, just to test if this Linux based method works on the padavan firmware.

Code: Select all

type wl; type iwinfo 
on router not working.

Here is part of Domoticz log (with #type=brctl)

2019-12-28 18:53:34.081 (iDetect) Debug logging mask set to: PYTHON
2019-12-28 18:53:34.082 (iDetect) Operation system is: linux
2019-12-28 18:53:34.096 (iDetect) The OS user profile running domoticz is: root
2019-12-28 18:53:34.096 (iDetect) Parsing user and optional keyfile from:admin
2019-12-28 18:53:34.097 (iDetect) start get or create wireless device
2019-12-28 18:53:34.097 (iDetect) JediMax_phone monitor tag_id:04:D6:xxxxxxxx, domoticz unit:4
2019-12-28 18:53:34.097 (iDetect) start get or create wireless device
2019-12-28 18:53:34.097 (iDetect) Alina_phone monitor tag_id:74:23:xxxxxxxx, domoticz unit:5
2019-12-28 18:53:34.097 (iDetect) Monitoring {'04:D6:xxxxxxxx': <plugin.tag_device object at 0xa82c7cd0>, '74:23:xxxxxxx': <plugin.tag_device object at 0xa70dbcb0>} for presence.
2019-12-28 18:53:34.097 (iDetect) Tracker configuration:192.168.1.1#type=brctl
2019-12-28 18:53:34.097 (iDetect) tracker:192.168.1.1
2019-12-28 18:53:34.097 (iDetect) options:type=brctl
2019-12-28 18:53:34.099 (iDetect) 192.168.1.1 Tracker is of the ssh kind
2019-12-28 18:53:34.099 (iDetect) 192.168.1.1 Data will be received and interpreted by <bound method BasePlugin.onDataReceive of <plugin.BasePlugin object at 0xa8468630>>
2019-12-28 18:53:34.099 (iDetect) Trackers initialized as:{'192.168.1.1': <trackers.ssh_brctl.ssh_brctl object at 0xa70dbff0>}
2019-12-28 18:53:34.099 (iDetect) Plugin initialization done.
2019-12-28 18:53:34.100 (iDetect) onStop called
2019-12-28 18:53:34.100 (iDetect) 192.168.1.1 ====> SSH client closed
2019-12-28 18:53:34.100 (iDetect) 192.168.1.1 ====> SSH no transport
2019-12-28 18:53:34.100 (iDetect) 192.168.1.1 Poll timer canceled

Python 3.5.2, Domoticz 4.11280
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 »

Hi JediMax,
on router not working.
Are there any (error) messages?
Here is part of Domoticz log (with #type=brctl)
Was there any reason to add the #type? By adding the #type configuration you are bypassing the autodetection process. So you are getting less information.

Anyway it seems strange that domoticz stops when enabling the plugin.I would expect to see error messages from ssh if commands are not found. Does domoticz actually stop or is it just stopping this plugin? I cannot test/reproduce this in my setup. There are some things you could investigate:

- do other domoticz python plugins work correctly?

- temporarily disable all other hardware in Domoticz and just enable the idetect plugin for testing

- find any command that will work on the router cli ... could be something simple like ‘help’ or ‘echo hello’ and configure the tracker (router) in the plugin as (for example) 192.168.1.1#ssh=help . This will obviously not do any presence detection but the output of the command should show up in the debug log. That way you can check if this is a problem with the ssh implementation on your router.

- update python (I am on 3.5.3)

- update Domoticz (I am on 4.11570)

- your domoticz or python setup could be damaged

- the padavan ssh server could be incompatible or configured in a way paramiko does not support
Fleshi
Posts: 14
Joined: Tuesday 23 May 2017 21:18
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python plugin: Presence detection from wireless router

Post by Fleshi »

Rob67ert wrote: Saturday 28 December 2019 16:21 @EscApe

It works :-)

With #type=brctl I got a whole list with mac adresses.
And no error.

Thanks for the support
@EscApe, to start with, you are a hero :)

I also have a TP-Link ARCHER-C7 v4 running DD-WRT v3.0 and the plugin didn't work untill I added the commend #type=brctl :)

If I can help you with providing information about this type of router please let me know!!!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest