Page 31 of 56

Re: Python plugin: Presence detection from wireless router

Posted: Tuesday 31 December 2019 9:44
by EscApe
@Fleshi,

Thanks! Yes, of course your help would be greatly appreciated! How are your python and Linux skills?
The preferred way to add support for any chipset would be to include it in the auto detection routine. If you can read python, than router_cli_helper.py in the helpers directory will give you some info on what info is needed.

Auto detection has to steps:
1. Detecting the available commands on the router with the router side script in the try_available_commands variable.
2. Trying the found (hardware specific commands) with the router side scrips in the corresponding interface_check[] dictionary on every interface the router has (and that looks like a potential wireless interface)

So what we need is:
- A command that queries the wireless chipset (not in try_available_commands... might be just ’iw’ from what I’ve read)
- the command syntax for the command found to list the connected clients
- does the command return an error level when it is used on a correct/incorrect interface?
- what interface names are used on this router?

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 04 January 2020 23:20
by tjabas
i dont really inderstand how i should install this plugin, i cant find any installation link on github.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 05 January 2020 10:13
by EscApe
@tjabas
i dont really inderstand how i should install this plugin, i cant find any installation link on github.
You are right. The installation instructions where missing from the readme on GitHub. I have just added them.

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 08 January 2020 21:58
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,

Sorry for the delay but i had to reinstall domoticz due to an error, so i never got to the bottom of the original ssh error i was having.

however i logged into my both my access point and used

Code: Select all

ssh=ishow arp;exit
and the UAP-AC-LR, UAP-AC-Lite both responded with a list of devices connected. But my USG came back with

Code: Select all

-vbash: arp: command not found
i am still getting an error when running with the unifi tracker

Code: Select all

192.168.10.3#type=unifiusg-arp,192.168.10.4#type=unifiusg-arp
i get

Code: Select all

2020-01-08 20:47:29.614 Error: (iDetect) 192.168.10.4 ====> SSH returned empty response. Transport active: True
2020-01-08 20:47:29.650 Error: (iDetect) 192.168.10.3 ====> SSH returned error:ash: ishow: not found

thanks

Re: Python plugin: Presence detection from wireless router

Posted: Wednesday 08 January 2020 22:58
by Mrrodz
@EscApe

I did a bit more exploring. so the

Code: Select all

ssh=ishow arp
worked on the access points but would only return 14 out of 30 devices - a bit strange as some of them were wired and some wireless. Another thing i found was the UniFi UAP-AC-LR would respond with device names and mac's, where the Lite responds with just the mac addresses.

So i went back to the USG but was getting the error

Code: Select all

-vbash: ishow: command not found
explored a bit and found

Code: Select all

show arp
worked when i SSH into the USG but then discovered that even though i got a response in terminal iDetects wouldn't sort the data and activate the the domoticz switch with the following error

Code: Select all

2020-01-08 21:27:50.805  Error: (iDetect) 192.168.10.1 ====> SSH returned error:vbash: show: command not found

2020-01-08 21:27:50.805  Error: (iDetect) 192.168.10.1 ====> SSH returned empty response. Transport active: True
2020-01-08 21:27:50.805  (iDetect) 192.168.10.1 ====> SSH returned (decoded):
2020-01-08 21:27:50.805  (iDetect) 192.168.10.1 ====> SSH session took 90 milliseconds.
2020-01-08 21:27:50.806  (iDetect) Inbound data from: 192.168.10.1 containing []
Did som digging on the unifi sites and found that if i changed the tracker unifiusg-arp from

Code: Select all

self.trackerscript = "ishow arp"
to

Code: Select all

self.trackerscript = "sudo arp"
it all works well and it responds with mac address and hostnames

i don't know if this info is helpful my USG is the 4 port version.

thanks for all the great work

Re: Python plugin: Presence detection from wireless router

Posted: Thursday 09 January 2020 20:13
by EscApe
@Mrrodz

A "http_unifi" tracker type has recently been added to the plugin by GitHub user stas-demydiuk. I do not know if it will work for your access points, but I might be worth trying. Specify it like

Code: Select all

192.168.10.3#type=http_unifi
worked on the access points but would only return 14 out of 30 devices - a bit strange as some of them were wired and some wireless.
When using arp you will probably not need to query every access point and router. If I understand the protocol correctly then when a device connects and broadcasts anything (like a DHCP request) then the arp table on every switch in your LAN will be populated. Also ARP is for all devices, not just the wireless ones. I cannot explain the 14 versus 30 devices. Does anyone else have a clue?
Another thing i found was the UniFi UAP-AC-LR would respond with device names and mac's, where the Lite responds with just the mac addresses.
That does not matter to the plugin. It will filter out just the Mac addresses.
So i went back to the USG but was getting the error

Code: Select all

-vbash: ishow: command not found
It turns out that the "i" was a typo. It should have just been 'show arp'. Sorry about that. It is fixed in the latest. Still using 'show arp' though, not 'sudo arp'. I don't want to break anything that seems to have been working for other users. Cannot test it myself, since I don't own any unifi stuff.

Code: Select all

self.trackerscript = "sudo arp"
it all works well and it responds with mac address and hostnames
Strange that it needs sudo. Doesn't it work without? If the corrected typo already fixes the issue then we will not need to investigate this.

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 11 January 2020 14:44
by vstras
@Mrrodz

I use this in my tracker unifiusg-arp

Code: Select all

self.trackerscript = "vbash -ic 'show arp'"
My USG is also the 4 port model

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 9:52
by HenriM
@vstras

You are a hero. With this change iDetect finally does not give any error/warnings anymore with my USG (4 port model). I propose that your change will be merged into the repository.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 15:48
by Franzie
I have a problem with iDetect V2. After installing this plugin I have the following log:

2020-01-11 19:45:57.869 Status: (iDetect) Started.
2020-01-11 19:45:58.019 Status: (iDetect) Entering work loop.
2020-01-11 19:45:58.020 Status: (iDetect) Initialized version 2.0, author 'ESCape'
2020-01-11 19:45:59.547 Status: (iDetect) 192.168.1.1 ====> SSH connection established
2020-01-11 19:45:59.662 Status: (iDetect) 192.168.1.1 No supported chipset found. Using generic mode: ip
2020-01-11 19:45:59.663 Status: (iDetect) Tracker activated:192.168.1.1 port 22, user: admin, type: default and options: {}
2020-01-11 19:45:59.661 Error: (iDetect) 192.168.1.1 ====> SSH returned error:vbash: line 2: type: wl: not found
2020-01-11 19:45:59.661 vbash: line 3: type: iwinfo: not found
2020-01-11 19:45:59.661 vbash: line 4: type: wlanconfig: not found
2020-01-11 19:45:59.661 vbash: line 5: type: qcsapi_sockrpc: not found


I am using a Unifi USG as router and I really don't know where to start resolving this error.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 16:51
by EscApe
@vstras
.... I propose that your change will be merged into the repository.
Done

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 16:56
by EscApe
@Franzie

Unifi USG only offers a proprietary command set, so the plugin will not autodetect it. You can use it by configuring the plugin as follows:

Code: Select all

192.168.1.1#type=unifiusg-arp

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 17:55
by Franzie
2020-01-12 17:54:01.156 Error: (iDetect) 192.168.1.1 ====> SSH returned error:vbash: show: command not found
2020-01-12 17:54:01.156
2020-01-12 17:54:01.156 Error: (iDetect) 192.168.1.1 ====> SSH returned empty response. Transport active: True

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 19:08
by EscApe
@Franzie

Did you update to the latest version? It was published about two hours ago.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 19:19
by Franzie
No not two hours, this was the installation from this morning 😀. I will update later on.
Thanks so far!

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 19:39
by tjabas
Hi!

i tried this plugin but Domoticz freezes after my google devices has been discovered, it says fatal error signal 11, i didnt save the log, and it also said something about plugin manager.

i need to reboot the rpi and disable the plugin, for domoticz to run without any errors.

any suggestions of whats wrong?

i run domoticz v.4.11415

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 20:50
by EscApe
@tjabas

Did you disable all other python plugins?
What python version is displayed in the domoticz ‘about’ screen?

Do the google WiFi devices even offer ssh access or did you modify/root them? They might still be very different from the usual Linux based routers. As with other proprietary command lines a different method might be needed. But that needs to be researched by someone who has access to such a device.

Nevertheless not finding supported ssh commands should not crash the plugin or Domoticz.
To dig a little deeper a debug log might help.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 22:11
by tjabas
EscApe wrote: Sunday 12 January 2020 20:50 @tjabas

Did you disable all other python plugins?
What python version is displayed in the domoticz ‘about’ screen?

Do the google WiFi devices even offer ssh access or did you modify/root them? They might still be very different from the usual Linux based routers. As with other proprietary command lines a different method might be needed. But that needs to be researched by someone who has access to such a device.

Nevertheless not finding supported ssh commands should not crash the plugin or Domoticz.
To dig a little deeper a debug log might help.
no i didnt disable all python plugins, just this one, never mind the wifi devices, i mixed them up with another plugin, i have problems with them there , not in this plugin, sorry.
but it still get the error code that i wrote earlier in the thread.

this is from my about page:

Version: 4.11415
Build Hash: 9bcb67547
Compile Date: 2019-10-25 17:56:30
dzVents Version: 2.4.29
Python Version: 3.4.2 (default, Sep 16 2019, 20:33:47) [GCC 4.9.2]

i also get the same error when i try to install the latest beta of domoticz.

maybe i should install another version if python?

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 12 January 2020 22:13
by Franzie
@EscApe

Thank you, all up and running after git pull.

Great!

/Frans

Re: Python plugin: Presence detection from wireless router

Posted: Monday 13 January 2020 9:43
by EscApe
@tjabas
maybe i should install another version if python?
Yes. As stated in the readme the plugin requires python 3.5
no i didnt disable all python plugins,
To diagnose which plugin is crashing domoticz you should disable all plugins and enable them one by one. Is the plugin causing a crash, or was that the mixup with another plugin?
i also get the same error when i try to install the latest beta of domoticz.
I will happily help you diagnose this issue, but please include a full debug log from the moment the plugin starts until any crash or error message. The information you have given in this and the previous post is a bit confusing.

Re: Python plugin: Presence detection from wireless router

Posted: Monday 13 January 2020 11:20
by Franzie
Initially I saw everything was fine, phones are registered in and out. That works well!
But now I have in my log, every 50 minutes:

Error: (iDetect) 192.168.1.1 ====> SSH failed with exception:

I poll every 15 secs and grace period is 30 secs.