Page 23 of 55

Re: Python plugin: Presence detection from wireless router

Posted: Friday 16 November 2018 18:33
by EscApe
Thanks mikeoo! That’s really helpful for orther unifi owners.

Re: Python plugin: Presence detection from wireless router

Posted: Monday 19 November 2018 8:56
by Freekers
Is it possible to disable SSH Host Key Checking? I'm asking this because I've recently switched to the Domoticz docker image. Every time the Docker image is updated, I need to login in the Docker and manually trust my router as known SSH host before iDetect works. If not, it will be stuck on this screen:

Code: Select all

RSA key fingerprint is 96:a9:23:5c:cc:d1:0a:d4:70:22:93:e9:9e:1e:74:2f.
Are you sure you want to continue connecting (yes/no)? yes
I'd rather not change the Docker container/image too much, as it's against the idea of Docker.

Thank you :)

Re: Python plugin: Presence detection from wireless router

Posted: Monday 19 November 2018 20:33
by EscApe
@Freekers,

Wouldn’t it be better to store the trusted host file on persistent storage? I think you can accomplish this by letting the docker container mount a folder on the synology to /root/.ssh (if Domoticz is running as root). This would also fix your custom authentication key file issue. To my knowledge you can update the image and refresh the container without having to edit this mapping after every update.

Re: Python plugin: Presence detection from wireless router

Posted: Tuesday 20 November 2018 22:39
by Freekers
EscApe wrote: Monday 19 November 2018 20:33 @Freekers,

Wouldn’t it be better to store the trusted host file on persistent storage? I think you can accomplish this by letting the docker container mount a folder on the synology to /root/.ssh (if Domoticz is running as root). This would also fix your custom authentication key file issue. To my knowledge you can update the image and refresh the container without having to edit this mapping after every update.
You are right, not sure why I haven't thought about this sooner. Thanks for pointing me in the right direction :)
For those of you who want to use the same approach, here's how:

Assuming iDetect is currently working as it should in your Domoticz docker, first copy the known_hosts file out of your Docker to the host using:

Code: Select all

docker cp domoticz:/root/.ssh/known_hosts /volume3/docker/domoticz/known_hosts
Next, restart your Domoticz docker image with the following volume attached:

Code: Select all

-v /volume3/docker/domoticz/known_hosts:/root/.ssh/known_hosts
Of course, replace file paths where appropriate, and that's it :) When updating your Domoticz docker image/container, it shouldn't ask to trust the host anymore, since it uses the known_hosts file we exported from our working Docker.

Re: Python plugin: Presence detection from wireless router

Posted: Friday 30 November 2018 14:01
by rgroothuis
I'm using the iDetect python plugin with great pleasure to detect the iPhones getting and leave home, this works fine. I've added my Samsung TV as well to determine if it is On or Off. But on a regular/frequent basis it is detected that the TV is switched on, meaning it has received an IP address from the router. Is the Samsung TV going on and off in the background? Why do I see this behaviour?

Code: Select all

SamsungTV switched ON at 29/11/2018 03:54:26!
SamsungTV switched OFF at 29/11/2018 03:57:41!
SamsungTV switched ON at 29/11/2018 06:57:18!
SamsungTV switched OFF at 29/11/2018 07:00:33!
SamsungTV switched ON at 29/11/2018 09:58:54!
SamsungTV switched OFF at 29/11/2018 10:01:55!
SamsungTV switched ON at 29/11/2018 13:00:31!
SamsungTV switched OFF at 29/11/2018 13:03:46!
SamsungTV switched ON at 29/11/2018 16:03:23!
SamsungTV switched OFF at 29/11/2018 16:06:23!
SamsungTV switched ON at 29/11/2018 19:04:59!
SamsungTV switched OFF at 29/11/2018 19:08:14!

Re: Python plugin: Presence detection from wireless router

Posted: Friday 30 November 2018 23:42
by EscApe
Your TV is probably going online to check for updates/EPG/cloud services etc. Also 'Stand-by' is the new name for the 'gathering information about our customers' mode ;)

I wouldn't worry about it. The wireless interface is definitely connecting (frequently), but it was already doing so before you noticed this in the plugin.

Python plugin: Presence detection from wireless router

Posted: Saturday 01 December 2018 9:09
by mvzut
Alternatively you could try the http/https poller plugin. This uses pinging to check if a device is present. In standby mode, your TV apparently has an active connection to your router now and then, but it might ignore ping requests in that state. Just something you could try out. I used this method for a while with my own Samsung TV, worked fine back then (but this is an "ancient" 5 year old TV ).

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 01 December 2018 15:45
by rgroothuis
EscApe wrote: Friday 30 November 2018 23:42 Your TV is probably going online to check for updates/EPG/cloud services etc. Also 'Stand-by' is the new name for the 'gathering information about our customers' mode ;)

I wouldn't worry about it. The wireless interface is definitely connecting (frequently), but it was already doing so before you noticed this in the plugin.
I made a similar assumption, thanks. I want to know if the TV is On or Off, put with the pinging or DHCP list it is not really effective.

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 01 December 2018 15:46
by rgroothuis
mvzut wrote: Saturday 01 December 2018 9:09 Alternatively you could try the http/https poller plugin. This uses pinging to check if a device is present. In standby mode, your TV apparently has an active connection to your router now and then, but it might ignore ping requests in that state. Just something you could try out. I used this method for a while with my own Samsung TV, worked fine back then (but this is an "ancient" 5 year old TV Image).
Ok, thanks. Will take a look at that option, http polling.

Re: Python plugin: Presence detection from wireless router

Posted: Friday 07 December 2018 9:27
by hestia
Thanks for this plugin
/!\ Unfortunately it makes Domoticz crashes for me
I just did this:
1/ cd ~/domoticz/plugins
2/ git clone https://github.com/d-EScape/Domoticz_iDetect iDetect
3/ I have a ~/domoticz/plugins/iDetect directory that contains the plugin.py and two zip files for icons4/
4/ Restart Domoticz
=> Domoticz crashes :-(

Any ideas ?
Version: 4.10224

Re: Python plugin: Presence detection from wireless router

Posted: Friday 07 December 2018 20:28
by EscApe
@hestia

There’s not much I can tell without any debug log. Only thing I can guess is a damaged Domoticz and/or python installation. Do you have any other python plugins running successfully in Domoticz?

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 08 December 2018 7:11
by mikeoo
hestia wrote: Friday 07 December 2018 9:27 Thanks for this plugin
/!\ Unfortunately it makes Domoticz crashes for me
I just did this:
1/ cd ~/domoticz/plugins
2/ git clone https://github.com/d-EScape/Domoticz_iDetect iDetect
3/ I have a ~/domoticz/plugins/iDetect directory that contains the plugin.py and two zip files for icons4/
4/ Restart Domoticz
=> Domoticz crashes :-(

Any ideas ?
Version: 4.10224
Maybe the problem is related to Python version.
https://www.google.com/search?q=domoticz+python+crash

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 08 December 2018 11:09
by hestia
EscApe wrote: Friday 07 December 2018 20:28 @hestia

There’s not much I can tell without any debug log. Only thing I can guess is a damaged Domoticz and/or python installation. Do you have any other python plugins running successfully in Domoticz?
I've AwoxSMP in a plugins folder but I don't use it and it didn't make Domoticz crashes when launched.
I've other python scripts that run w/o issues

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 08 December 2018 11:11
by hestia
mikeoo wrote: Saturday 08 December 2018 7:11
hestia wrote: Friday 07 December 2018 9:27 Thanks for this plugin
/!\ Unfortunately it makes Domoticz crashes for me
I just did this:
1/ cd ~/domoticz/plugins
2/ git clone https://github.com/d-EScape/Domoticz_iDetect iDetect
3/ I have a ~/domoticz/plugins/iDetect directory that contains the plugin.py and two zip files for icons4/
4/ Restart Domoticz
=> Domoticz crashes :-(

Any ideas ?
Version: 4.10224
Maybe the problem is related to Python version.
https://www.google.com/search?q=domoticz+python+crash
My Python Version: 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124]
the last one I think
I'm not sure to understand what to do with this post https://domoticz.com/forum/viewtopic.php?t=23576
I need to read it more...

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 08 December 2018 11:19
by mikeoo
hestia wrote: Saturday 08 December 2018 11:09
EscApe wrote: Friday 07 December 2018 20:28 @hestia

There’s not much I can tell without any debug log. Only thing I can guess is a damaged Domoticz and/or python installation. Do you have any other python plugins running successfully in Domoticz?
I've AwoxSMP in a plugins folder but I don't use it and it didn't make Domoticz crashes when launched.
I've other python scripts that run w/o issues
Problem with python is that some plugin runs fine with every version of Python and other can crash. Best way i think is trying the check the logfiles is you can find any info about the crash. On a rasp you can find the logs in /var/log

Re: Python plugin: Presence detection from wireless router

Posted: Saturday 08 December 2018 16:44
by EscApe
My Python Version: 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124]
the last one I think
I'm not sure to understand what to do with this post https://domoticz.com/forum/viewtopic.php?t=23576
I need to read it more...
When i started on plugins some imports would indeed crash Domoticz. So i did not use those. This problem might not be related to the message you are referring to... not sure though :?

I have just installed the latest Domoticz V4.10266 to make sure it is not caused by a change in Domoticz, but it is still running fine.

Please set Domoticz and the plugin to debug logging and share your logs. Otherwise we can only speculate.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 09 December 2018 17:42
by hestia
@EscApe, @mikeoo
Thanks for your guidelines

Finally it works, I don't know exactly what was wrong: my domoticz.sh regarding errog log, sudo systemctl daemon-reload to do
or my beta version that has an issue when I reboot the server...
=> I upgraded to the last beta (Version: 4.10267) and there is no longer a crash even after a reboot.

My phone is detected, I'm going to add the others

Thanks EscApe for this plugin :-)

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 09 December 2018 22:22
by jackisfree
I have this great plugin working on my Domitcz and my Unifi AP.

I have tested the plugin with my Unifi USG but then it isn't working.
Is is possible to het it work with the Unifi USG.
I can see the arp tabel on the Unifi USG with "show arp"

When I use the plugin and looked add the log I see the following:
Available commands on xx.xx.xx.xx:['brctl', 'arp', 'procarp']
Found suitable command (and interfaces) for router xx.xx.xx.xx:{'brctl': []}

later I see:
Found these devices connected:[]
Seems to have went offline: phone1

When I entered the brctl command on ssh session with Unifi USG it say unkown command

Can somebody help me

Re: Python plugin: Presence detection from wireless router

Posted: Monday 10 December 2018 19:57
by EscApe
The USG seems to have a proprietary OS with its own commands, so autodetecting the capabilities will not work/be unpredictable.
I have (just) added support for the USG to the plugin as a selectable custom command. Specify your USG in the plugin as <routerip>=unifiusg-arp

I do expect the response time and reliability on the AP's (using the wireless commands) to be better than on the USG (using arp), but am very interested to hear how you experience the performance of both methods.

Re: Python plugin: Presence detection from wireless router

Posted: Sunday 16 December 2018 23:01
by tomaforn
I'm trying to get this plugin up and running, but I get no results and also errors show up in the log:

Code: Select all

2018-12-16 22:41:01.098 (iDetect) Prosponed connection to 192.168.1.1 for 0:00:00.246930
2018-12-16 22:41:01.098 (iDetect) Did not retreive WLAN information from any router
2018-12-16 22:41:01.098 (iDetect) Entire poll took 0% of the poll interval time (0 milliseconds)
2018-12-16 22:41:16.124 (iDetect) 192.168.1.1 was not properly initialized. Retrying to get router capabilities (and skipping this poll round).
2018-12-16 22:41:16.124 (iDetect) Fetching data from 192.168.1.1 using: ssh -i -o ConnectTimeout=3 -p22 [email protected]
2018-12-16 22:41:16.124 #!/bin/sh
2018-12-16 22:41:16.124 export PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH
2018-12-16 22:41:16.124 type wl > /dev/null 2>&1 && printf "~wl"
2018-12-16 22:41:16.124 type iwinfo > /dev/null 2>&1 && printf "~iwinfo"
2018-12-16 22:41:16.124 type wlanconfig > /dev/null 2>&1 && printf "~wlanconfig"
2018-12-16 22:41:16.124 type qcsapi_sockrpc > /dev/null 2>&1 && printf "~qcsapi_sockrpc"
2018-12-16 22:41:16.124 type brctl > /dev/null 2>&1 && printf "~brctl"
2018-12-16 22:41:16.124 type arp > /dev/null 2>&1 && printf "~arp"
2018-12-16 22:41:16.124 [ -f /proc/net/arp ] && printf "~procarp"
2018-12-16 22:41:16.124 exit
2018-12-16 22:41:16.124
2018-12-16 22:41:16.514 (iDetect) SSH subprocess for 192.168.1.1 failed with error (255):b''
2018-12-16 22:41:16.514 (iDetect) SSH command on 192.168.1.1 took 389 milliseconds.
2018-12-16 22:41:16.514 (iDetect) Could not retreive available commands on 192.168.1.1
2018-12-16 22:41:16.515 (iDetect) Routerinfo:{'errorcount': 3, 'port': 22, 'initialized': False, 'cmd': '', 'prospone': datetime.datetime(2018, 12, 16, 22, 42, 46, 514880), 'user': 'admin'}
I have verified the SSH-access to my AC68U router from the Domoticz setup - works fine.
If I run a "wl -i eth2 assoclist" command manually on the router both my wanted devices are listed (same as I entered in the plugin settings)

Any ideas what I'm missing?

Thanks,
Tomas