Python plugin: Presence detection from wireless router
Moderator: leecollings
-
- 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
Hi Magnus,
I cannot confirm compatibility with tomato firmware, since i'm not running that firmware, but it as long as it has ssh enabled i see no reason for it not to work.
My first guess would be that ssh key based authentication to the router is not setup for the userprofile running domoticz (root by default) or ssh is not enabled on the router(?) You can find more info on the ssh setup in this thread or through google.
If ssh is not the issue, can you provide some logging from the start of the plugin (not just the heartbeat)?
What operating system are you running Domoticz on?
I cannot confirm compatibility with tomato firmware, since i'm not running that firmware, but it as long as it has ssh enabled i see no reason for it not to work.
My first guess would be that ssh key based authentication to the router is not setup for the userprofile running domoticz (root by default) or ssh is not enabled on the router(?) You can find more info on the ssh setup in this thread or through google.
If ssh is not the issue, can you provide some logging from the start of the plugin (not just the heartbeat)?
What operating system are you running Domoticz on?
-
- Posts: 62
- Joined: Tuesday 22 November 2016 21:04
- Target OS: Linux
- Domoticz version: 2020.2
- Location: Gothenburg
- Contact:
Re: Python plugin: Presence detection from wireless router
Im runing it on a Raspberry 3.EscApe wrote: ↑Monday 13 August 2018 19:47 Hi Magnus,
I cannot confirm compatibility with tomato firmware, since i'm not running that firmware, but it as long as it has ssh enabled i see no reason for it not to work.
My first guess would be that ssh key based authentication to the router is not setup for the userprofile running domoticz (root by default) or ssh is not enabled on the router(?) You can find more info on the ssh setup in this thread or through google.
If ssh is not the issue, can you provide some logging from the start of the plugin (not just the heartbeat)?
What operating system are you running Domoticz on?
The router have ssh enabled.
But its complainign that it cant run ssh -V
Code: Select all
2018-08-14 08:42:11.196 Error: (Presence detection WIFI) [ssh -V] will not run but is required! (error: 'module' object has no attribute 'run')
2018-08-14 08:42:11.196 Error: (Presence detection WIFI) [sshpass -V] will not run but is required! (error: 'module' object has no attribute 'run')
2018-08-14 08:42:11.197 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:42:11.197 Error: (Presence detection WIFI) Could not determine router capabilities
Code: Select all
root@unknown:/tmp/home/root# ssh -V
Dropbear v2016.74
root@unknown:/tmp/home/root#
Code: Select all
pi@raspberrypi:~ $ ssh -V
OpenSSH_6.7p1 Raspbian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016
pi@raspberrypi:~ $ cat /etc/issue
Raspbian GNU/Linux 8 \n \l
pi@raspberrypi:~ $
Code: Select all
2018-08-14 08:42:10.890 Status: (Presence detection WIFI) Started.
2018-08-14 08:42:11.196 (Presence detection WIFI) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2018-08-14 08:42:11.196 (Presence detection WIFI) Not running on Windows
2018-08-14 08:42:11.196 (Presence detection WIFI) Monitoring {'phone1': 'C4:9F:4C:EE:F1:B7', 'phone4': 'C4:9F:4C:EF:E9:8A', 'phone3': '58:48:22:A4:4E:D2', 'phone2': '58:48:22:A1:8B:1C'} for presence.
2018-08-14 08:42:11.197 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:42:11.197 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:42:11.197 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:42:11.197 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:42:11.197 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone1
2018-08-14 08:42:11.197 (Presence detection WIFI) Presence detection WIFI - phone1 is stil in use
2018-08-14 08:42:11.197 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone2
2018-08-14 08:42:11.197 (Presence detection WIFI) Presence detection WIFI - phone2 is stil in use
2018-08-14 08:42:11.198 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone4
2018-08-14 08:42:11.198 (Presence detection WIFI) Presence detection WIFI - phone4 is stil in use
2018-08-14 08:42:11.198 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone3
2018-08-14 08:42:11.198 (Presence detection WIFI) Presence detection WIFI - phone3 is stil in use
2018-08-14 08:42:11.198 (Presence detection WIFI) monitoring device: Presence detection WIFI - Override
2018-08-14 08:42:11.198 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:42:11.198 (Presence detection WIFI) monitormacs: {'phone1': 'C4:9F:4C:EE:F1:B7', 'phone4': 'C4:9F:4C:EF:E9:8A', 'phone3': '58:48:22:A4:4E:D2', 'phone2': '58:48:22:A1:8B:1C'}
2018-08-14 08:42:11.198 (Presence detection WIFI) Pushing 'PollIntervalDirective' on to queue
2018-08-14 08:42:11.198 (Presence detection WIFI) Processing 'PollIntervalDirective' message
2018-08-14 08:42:11.198 (Presence detection WIFI) Heartbeat interval set to: 15.
2018-08-14 08:42:11.187 Status: (Presence detection WIFI) Entering work loop.
2018-08-14 08:42:11.189 Status: (Presence detection WIFI) Initialized version 0.4.2, author 'ESCape'
2018-08-14 08:42:11.196 Error: (Presence detection WIFI) [ssh -V] will not run but is required! (error: 'module' object has no attribute 'run')
2018-08-14 08:42:11.196 Error: (Presence detection WIFI) [sshpass -V] will not run but is required! (error: 'module' object has no attribute 'run')
2018-08-14 08:42:11.197 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:42:11.197 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:42:18.121 (Presence detection WIFI) Pushing 'onStopCallback' on to queue
2018-08-14 08:42:18.159 (Presence detection WIFI) Processing 'onStopCallback' message
2018-08-14 08:42:18.159 (Presence detection WIFI) Message handler 'onStop' not callable, ignored.
2018-08-14 08:42:18.523 (Presence detection WIFI) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2018-08-14 08:42:18.523 (Presence detection WIFI) Not running on Windows
2018-08-14 08:42:18.524 (Presence detection WIFI) Monitoring {'phone1': 'C4:9F:4C:EE:F1:B7', 'phone4': 'C4:9F:4C:EF:E9:8A', 'phone3': '58:48:22:A4:4E:D2', 'phone2': '58:48:22:A1:8B:1C'} for presence.
2018-08-14 08:42:18.524 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:42:18.524 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:42:18.524 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:42:18.524 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:42:18.524 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone1
2018-08-14 08:42:18.524 (Presence detection WIFI) Presence detection WIFI - phone1 is stil in use
2018-08-14 08:42:18.524 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone2
2018-08-14 08:42:18.525 (Presence detection WIFI) Presence detection WIFI - phone2 is stil in use
2018-08-14 08:42:18.525 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone4
2018-08-14 08:42:18.525 (Presence detection WIFI) Presence detection WIFI - phone4 is stil in use
2018-08-14 08:42:18.525 (Presence detection WIFI) monitoring device: Presence detection WIFI - phone3
2018-08-14 08:42:18.525 (Presence detection WIFI) Presence detection WIFI - phone3 is stil in use
2018-08-14 08:42:18.525 (Presence detection WIFI) monitoring device: Presence detection WIFI - Override
2018-08-14 08:42:18.525 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:42:18.525 (Presence detection WIFI) monitormacs: {'phone1': 'C4:9F:4C:EE:F1:B7', 'phone4': 'C4:9F:4C:EF:E9:8A', 'phone3': '58:48:22:A4:4E:D2', 'phone2': '58:48:22:A1:8B:1C'}
2018-08-14 08:42:18.525 (Presence detection WIFI) Pushing 'PollIntervalDirective' on to queue
2018-08-14 08:42:18.525 (Presence detection WIFI) Processing 'PollIntervalDirective' message
2018-08-14 08:42:18.525 (Presence detection WIFI) Heartbeat interval set to: 15.
2018-08-14 08:42:18.121 Status: (Presence detection WIFI) Stop directive received.
2018-08-14 08:42:18.199 Status: (Presence detection WIFI) Exiting work loop.
2018-08-14 08:42:18.221 Status: (Presence detection WIFI) Stopping threads.
2018-08-14 08:42:18.221 Status: (Presence detection WIFI) Stopped.
2018-08-14 08:42:18.222 Status: (Presence detection WIFI) Started.
2018-08-14 08:42:18.514 Status: (Presence detection WIFI) Entering work loop.
2018-08-14 08:42:18.516 Status: (Presence detection WIFI) Initialized version 0.4.2, author 'ESCape'
2018-08-14 08:42:18.523 Error: (Presence detection WIFI) [ssh -V] will not run but is required! (error: 'module' object has no attribute 'run')
2018-08-14 08:42:18.523 Error: (Presence detection WIFI) [sshpass -V] will not run but is required! (error: 'module' object has no attribute 'run')
2018-08-14 08:42:18.524 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:42:18.524 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:42:28.027 (Presence detection WIFI) Pushing 'onHeartbeatCallback' on to queue
2018-08-14 08:42:28.039 (Presence detection WIFI) Processing 'onHeartbeatCallback' message
2018-08-14 08:42:28.040 (Presence detection WIFI) Calling message handler 'onHeartbeat'.
2018-08-14 08:42:28.040 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:42:28.040 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:42:28.040 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:42:28.040 (Presence detection WIFI) Could not detemine the user profile running Domoticz
2018-08-14 08:42:28.040 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:42:28.040 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:42:28.040 Error: (Presence detection WIFI) No usable commandline to check presence. Trying again to detect router capabilities.
2018-08-14 08:42:28.040 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:42:28.041 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:42:43.029 (Presence detection WIFI) Pushing 'onHeartbeatCallback' on to queue
2018-08-14 08:42:43.063 (Presence detection WIFI) Processing 'onHeartbeatCallback' message
2018-08-14 08:42:43.063 (Presence detection WIFI) Calling message handler 'onHeartbeat'.
2018-08-14 08:42:43.063 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:42:43.063 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:42:43.063 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:42:43.064 (Presence detection WIFI) Could not detemine the user profile running Domoticz
2018-08-14 08:42:43.064 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:42:43.064 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:42:43.063 Error: (Presence detection WIFI) No usable commandline to check presence. Trying again to detect router capabilities.
2018-08-14 08:42:43.064 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:42:43.064 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:42:58.031 (Presence detection WIFI) Pushing 'onHeartbeatCallback' on to queue
2018-08-14 08:42:58.036 (Presence detection WIFI) Processing 'onHeartbeatCallback' message
2018-08-14 08:42:58.036 (Presence detection WIFI) Calling message handler 'onHeartbeat'.
2018-08-14 08:42:58.037 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:42:58.037 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:42:58.037 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:42:58.037 (Presence detection WIFI) Could not detemine the user profile running Domoticz
2018-08-14 08:42:58.037 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:42:58.037 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:42:58.037 Error: (Presence detection WIFI) No usable commandline to check presence. Trying again to detect router capabilities.
2018-08-14 08:42:58.037 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:42:58.037 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:43:13.034 (Presence detection WIFI) Pushing 'onHeartbeatCallback' on to queue
2018-08-14 08:43:13.065 (Presence detection WIFI) Processing 'onHeartbeatCallback' message
2018-08-14 08:43:13.065 (Presence detection WIFI) Calling message handler 'onHeartbeat'.
2018-08-14 08:43:13.065 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:43:13.065 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:43:13.065 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:43:13.065 (Presence detection WIFI) Could not detemine the user profile running Domoticz
2018-08-14 08:43:13.065 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:43:13.066 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:43:13.065 Error: (Presence detection WIFI) No usable commandline to check presence. Trying again to detect router capabilities.
2018-08-14 08:43:13.066 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:43:13.066 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:43:28.036 (Presence detection WIFI) Pushing 'onHeartbeatCallback' on to queue
2018-08-14 08:43:28.038 (Presence detection WIFI) Processing 'onHeartbeatCallback' message
2018-08-14 08:43:28.038 (Presence detection WIFI) Calling message handler 'onHeartbeat'.
2018-08-14 08:43:28.038 (Presence detection WIFI) devid2domid: {'phone1': 2, 'phone4': 4, 'phone3': 5, 'phone2': 3}
2018-08-14 08:43:28.038 (Presence detection WIFI) Checking router capabilities and wireless interfaces
2018-08-14 08:43:28.039 (Presence detection WIFI) Pushing 'PollIntervalDirective' on to queue
2018-08-14 08:43:28.039 (Presence detection WIFI) Using ssh public key authentication (~/.ssh/id_rsa.pub) for OS user running domoticz.
2018-08-14 08:43:28.039 (Presence detection WIFI) Could not detemine the user profile running Domoticz
2018-08-14 08:43:28.039 (Presence detection WIFI) Fetching data from router using ssh
2018-08-14 08:43:28.039 (Presence detection WIFI) 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 $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(iwinfo $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 wlanconfig > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "wlanconfig@"\n\t\t\t\t\t\t\tfor iface in $(ifconfig | cut -d \' \' -f1| tr \':\' \'\n\' | grep \'^eth\\|^wlan\\|^ath\')\n\t\t\t\t\t\t\tdo\n\t\t\t\t\t\t\t\t\ttest=$(wlanconfig $iface list > /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 brctl > /dev/null 2>&1)\n\t\t\t\t\tif [ $? == 0 ]; then\n\t\t\t\t\t\t\tprintf "brctl"\n\t\t\t\t\t\t\texit\n\t\t\t\t\tfi\t\t\t\t\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\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tif [ -f /proc/net/arp ]; then\n\t\t\t\t\t\tprintf "procarp"\n\t\t\t\t\t\texit\n\t\t\t\t\tfi\n\t\t\t\t\tprintf none']
2018-08-14 08:43:28.039 (Presence detection WIFI) Processing 'PollIntervalDirective' message
2018-08-14 08:43:28.039 (Presence detection WIFI) Heartbeat interval set to: 30.
2018-08-14 08:43:28.038 Error: (Presence detection WIFI) No usable commandline to check presence. Trying again to detect router capabilities.
2018-08-14 08:43:28.038 Error: (Presence detection WIFI) Temporarily limiting the polling frequency after encountering 5 (ssh) errors in a row.
2018-08-14 08:43:28.039 Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
2018-08-14 08:43:28.039 Error: (Presence detection WIFI) Could not determine router capabilities
2018-08-14 08:43:40.044 (Presence detection WIFI) Pushing 'onStopCallback' on to queue
2018-08-14 08:43:40.057 (Presence detection WIFI) Processing 'onStopCallback' message
2018-08-14 08:43:40.057 (Presence detection WIFI) Message handler 'onStop' not callable, ignored.
2018-08-14 08:43:40.044 Status: (Presence detection WIFI) Stop directive received.
2018-08-14 08:43:40.245 Status: (Presence detection WIFI) Stopping threads.
2018-08-14 08:43:40.540 Status: (Presence detection WIFI) Exiting work loop.
2018-08-14 08:43:40.540 Status: (Presence detection WIFI) Stopped.
-
- 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
Thanks for the additional log. “error: 'module' object has no attribute 'run'” tells me you are running a python version lower than 3.5.
Python3.5 is required but unfortunately it is not the standard for Raspbian at this point. As stated earlier in this thread I should have used the subprocess.popen instead of subprocess.run method when writing the plugin. So it would not require python3.5. Unless I rewrite it or python3.5 becomes the standard it will not work unless you install python3.5 manually.
Python3.5 is required but unfortunately it is not the standard for Raspbian at this point. As stated earlier in this thread I should have used the subprocess.popen instead of subprocess.run method when writing the plugin. So it would not require python3.5. Unless I rewrite it or python3.5 becomes the standard it will not work unless you install python3.5 manually.
-
- Posts: 116
- Joined: Friday 20 December 2013 7:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Presence detection from wireless router
Ik like this plugin, but unfortunately it is not working for my Asus RT-AC87U.
for Broadcom hardware
wl -i eth1 assoclist (for 2.4Ghz)
wl -i eth2 assoclist (for 5GHz)
And if you have an 87U it's different for the 5GHz band because of the different hardware....
qcsapi_sockrpc get_count_assoc wifi0
This will tell you how many clients are associated. After that, you have to query the router for every client. So if you have a count of 2 clients:
qcsapi_sockrpc get_station_mac_addr wifi0 0
qcsapi_sockrpc get_station_mac_addr wifi0 1
This will return the MAC of associated clients 0 and 1 (the index starts at 0).
Can you and do you want to enhance the plugin for the RT-AC87U?
for Broadcom hardware
wl -i eth1 assoclist (for 2.4Ghz)
wl -i eth2 assoclist (for 5GHz)
And if you have an 87U it's different for the 5GHz band because of the different hardware....
qcsapi_sockrpc get_count_assoc wifi0
This will tell you how many clients are associated. After that, you have to query the router for every client. So if you have a count of 2 clients:
qcsapi_sockrpc get_station_mac_addr wifi0 0
qcsapi_sockrpc get_station_mac_addr wifi0 1
This will return the MAC of associated clients 0 and 1 (the index starts at 0).
Can you and do you want to enhance the plugin for the RT-AC87U?
-
- 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
Hi wizzard72,
The plugin should fall back on non chipset specific commands (brctl or arp) if the chipset specific commands like wl or iwconfig are not available. The debug log should tell you which command it will use. In routers with more than one brand of wireless chipset this could be a problem. Even if the wl command is available for the broadcom chip it might not give you any info on the Quantenna wifi chipset.
You can force the plugin to use a generic command (from the instructions on GitHub):
If you have the python and shell scripting skills you could hardcode some router-specific changes in the plugin(?)
Help on expanding the plugin from people with the programming skills and access to the router is always welcome!
The plugin should fall back on non chipset specific commands (brctl or arp) if the chipset specific commands like wl or iwconfig are not available. The debug log should tell you which command it will use. In routers with more than one brand of wireless chipset this could be a problem. Even if the wl command is available for the broadcom chip it might not give you any info on the Quantenna wifi chipset.
You can force the plugin to use a generic command (from the instructions on GitHub):
I might add Quantenna support in the (not so near) future if i can get some help on the available commands and their syntax from anyone who owns a router like that. That will not solve the issue with different wifi chipsets in one router. Currently i have no plans to solve that. That would make the plugin very complex if you also want to account for different interface names etc.It is now possible to force the plugin into using generic tools. This is not the preferred way, but can be usefull in some situations. Because the plugin is already using all avaiable settings fields i combined this setting with the 'WiFi Router IP address' field. If you add '#forcegeneric' behind the address it will skip the detection of chipset specific tools (eg 192.168.0.1#forcegeneric)
If you have the python and shell scripting skills you could hardcode some router-specific changes in the plugin(?)
Help on expanding the plugin from people with the programming skills and access to the router is always welcome!
-
- 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
For Melotron and others using python3.4:
I have changed the plugin to no longer require python3.5
It should now run on your default raspbian/Domoticz/Python3.4 setup.
I have changed the plugin to no longer require python3.5
It should now run on your default raspbian/Domoticz/Python3.4 setup.
-
- Posts: 62
- Joined: Tuesday 22 November 2016 21:04
- Target OS: Linux
- Domoticz version: 2020.2
- Location: Gothenburg
- Contact:
Re: Python plugin: Presence detection from wireless router
I've installed Python 3.5 now but its still generating an error.EscApe wrote: ↑Tuesday 14 August 2018 10:25 Thanks for the additional log. “error: 'module' object has no attribute 'run'” tells me you are running a python version lower than 3.5.
Python3.5 is required but unfortunately it is not the standard for Raspbian at this point. As stated earlier in this thread I should have used the subprocess.popen instead of subprocess.run method when writing the plugin. So it would not require python3.5. Unless I rewrite it or python3.5 becomes the standard it will not work unless you install python3.5 manually.
Code: Select all
pi@raspberrypi:~ $ python3 --version
Python 3.5.2
pi@raspberrypi:~ $
pi@raspberrypi:~ $ python --version
Python 2.7.9
pi@raspberrypi:~ $
Code: Select all
Error: (Presence detection WIFI) [ssh -V] will not run but is required! (error: 'module' object has no attribute 'run')
Error: (Presence detection WIFI) [sshpass -V] will not run but is required! (error: 'module' object has no attribute 'run')
Error: (Presence detection WIFI) SSH subprocess failed with error: 'module' object has no attribute 'run'
Error: (Presence detection WIFI) Could not determine router capabilities
-
- Posts: 116
- Joined: Friday 20 December 2013 7:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Presence detection from wireless router
Hi EscApe,EscApe wrote: ↑Tuesday 14 August 2018 14:24 Hi wizzard72,
The plugin should fall back on non chipset specific commands (brctl or arp) if the chipset specific commands like wl or iwconfig are not available. The debug log should tell you which command it will use. In routers with more than one brand of wireless chipset this could be a problem. Even if the wl command is available for the broadcom chip it might not give you any info on the Quantenna wifi chipset.
You can force the plugin to use a generic command (from the instructions on GitHub):I might add Quantenna support in the (not so near) future if i can get some help on the available commands and their syntax from anyone who owns a router like that. That will not solve the issue with different wifi chipsets in one router. Currently i have no plans to solve that. That would make the plugin very complex if you also want to account for different interface names etc.It is now possible to force the plugin into using generic tools. This is not the preferred way, but can be usefull in some situations. Because the plugin is already using all avaiable settings fields i combined this setting with the 'WiFi Router IP address' field. If you add '#forcegeneric' behind the address it will skip the detection of chipset specific tools (eg 192.168.0.1#forcegeneric)
If you have the python and shell scripting skills you could hardcode some router-specific changes in the plugin(?)
Help on expanding the plugin from people with the programming skills and access to the router is always welcome!
Indeed the RT-AC87U has 2 different chipsets for 2.4G and 5G wifi.
I have edited your plugin, and I got it working
This is what I changed / added:
1. Added an import
Code: Select all
import re
Code: Select all
test=$(which qcsapi_sockrpc > /dev/null 2>&1)
if [ $? == 0 ]; then
printf "qcsapi_sockrpc@"
test=$(qcsapi_sockrpc get_count_assoc wifi0)
if [ $? == 0 ]; then
printf "$test "
fi
fi
Code: Select all
if success:
#gotinfo = sshdata.decode("utf-8").split("@")
gotinfo = re.split("[@ ]",sshdata.decode("utf-8"))
gotinfocount = len(gotinfo) - 1
method = gotinfo[0]
interfaces = gotinfo[1]
Domoticz.Debug("Parsed data from router: " + str(gotinfo))
if method=="qcsapi_sockrpc":
Domoticz.Status("Using chipset specific (qcsapi_sockrpc and wl) command on router for interfaces ")
pollscript="export PATH=/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:$PATH"
Domoticz.Status("Using chipset specific (qcsapi_sockrpc) command on router for interfaces ")
for count in range(int(interfaces)):
pollscript=pollscript + ";qcsapi_sockrpc get_station_mac_addr wifi0 " + str(count)
Domoticz.Status("Using chipset specific (wl) command on router for interface " + str(gotinfo[3]))
pollscript=pollscript + ";wl -i " + gotinfo[3] + " assoclist | cut -d' ' -f2"
pollscript=pollscript + ";exit"
elif method=="wl":
etc.
-
- 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
Hi Melotron,
I have just modified the plugin to no longer require python3.5, so if you update plugin.py to the latest version on GitHub you should be fine.
You can see the python version domoticz is using under Settings > About in the Domoticz web interface. It can stil be using 3.4 even if 3.5 is installed and starts from the command line. Rebooting in between (or at least restarting Domoticz) can also make a difference. If you update the plugin that should no longer be an issue.
I would love to hear if the new version works for you and what version of python Domoticz is using.
I have just modified the plugin to no longer require python3.5, so if you update plugin.py to the latest version on GitHub you should be fine.
You can see the python version domoticz is using under Settings > About in the Domoticz web interface. It can stil be using 3.4 even if 3.5 is installed and starts from the command line. Rebooting in between (or at least restarting Domoticz) can also make a difference. If you update the plugin that should no longer be an issue.
I would love to hear if the new version works for you and what version of python Domoticz is using.
-
- 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
Hey wizzard72,
Great! I'm glad you have got it working.
Your code is also a good starting point for modification of the plugin. However, it is very specific to your router. I can not just assume other routers that have the qcsapi_sockrpc command will also have the wl command. It will be much more complicated to really detect the capabilities of a router that has more than one brand of wifi chip.
The plugin would first have to detect multiple chipsets are present, then detect the capabilities of each chipset and determine which interface names belong to which chipset. The plugin must be modified to handle these separate commands as well. All in all it will be a major rewrite. This might become more urgent in the future, with more routers using different chipsets. For now the fall back to the generic commands will have to do... or your creative patch off course
Great! I'm glad you have got it working.
Your code is also a good starting point for modification of the plugin. However, it is very specific to your router. I can not just assume other routers that have the qcsapi_sockrpc command will also have the wl command. It will be much more complicated to really detect the capabilities of a router that has more than one brand of wifi chip.
The plugin would first have to detect multiple chipsets are present, then detect the capabilities of each chipset and determine which interface names belong to which chipset. The plugin must be modified to handle these separate commands as well. All in all it will be a major rewrite. This might become more urgent in the future, with more routers using different chipsets. For now the fall back to the generic commands will have to do... or your creative patch off course
-
- Posts: 62
- Joined: Tuesday 22 November 2016 21:04
- Target OS: Linux
- Domoticz version: 2020.2
- Location: Gothenburg
- Contact:
Re: Python plugin: Presence detection from wireless router
Thank you so much !!EscApe wrote: ↑Tuesday 14 August 2018 17:08 Hi Melotron,
I have just modified the plugin to no longer require python3.5, so if you update plugin.py to the latest version on GitHub you should be fine.
You can see the python version domoticz is using under Settings > About in the Domoticz web interface. It can stil be using 3.4 even if 3.5 is installed and starts from the command line. Rebooting in between (or at least restarting Domoticz) can also make a difference. If you update the plugin that should no longer be an issue.
I would love to hear if the new version works for you and what version of python Domoticz is using.
I'am so happy that its working.
I've been testing so many scripts to get it to work.
We have 2 Huawei P20 PRO that are really annoying to get any kind of presence going on.
Domoticz app works sometimes, Tasker dosent work, when you ping the phone it can be offline for up to 2hr even when the phone are on.
Now I don't have to turn on and off the presence switches all the time.
The Domoticz info are :
Code: Select all
About Domoticz
Version: 4.9857
Build Hash: 5936d708
Compile Date: 2018-08-13 09:00:46
dzVents Version: 2.4.7
Python Version: 3.4.2 (default, Oct 19 2014, 14:03:53) [GCC 4.9.1]
-
- Posts: 443
- Joined: Thursday 12 November 2015 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
Hi wizzard72,wizzard72 wrote: I have edited your plugin, and I got it working
[...]
Maybe you can add it to the plugin and make the code better.
I also have an AC87U router. The plugin kind-of works with the #forcegeneric flag, but it is slow to respond to people coming home. Is this solved with your changes?
Can you please explain in more detail where your edits should be inserted exactly? Or PM me the files... Thanks!
P.S. It does detect one phone without the #forcegeneric flag, but it doesn't see the three others. I have one complicating factor: I have a second access point in my house, phones connected to that wireless network are seen as wired devices by my Asus router. Could that be a problem?
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
-
- Posts: 116
- Joined: Friday 20 December 2013 7:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Presence detection from wireless router
I didn't try out the #forcegeneric option. The plugin without the #forcegeneric only sees the 2.4G Wi-Fi. So that can explain why you only see one phone. For the plugin it doesn't matter if the phone uses wireless or wired connectivity.mvzut wrote: ↑Thursday 16 August 2018 14:55Hi wizzard72,wizzard72 wrote: I have edited your plugin, and I got it working
[...]
Maybe you can add it to the plugin and make the code better.
I also have an AC87U router. The plugin kind-of works with the #forcegeneric flag, but it is slow to respond to people coming home. Is this solved with your changes?
Can you please explain in more detail where your edits should be inserted exactly? Or PM me the files... Thanks!
P.S. It does detect one phone without the #forcegeneric flag, but it doesn't see the three others. I have one complicating factor: I have a second access point in my house, phones connected to that wireless network are seen as wired devices by my Asus router. Could that be a problem?
I pm you the file you need to override.
-
- 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
Strange. I would expect the plugin to respond slow to people leaving the house, but it should respond quickly to people coming home.
Arp or brctl should immediately see newly connected mac addresses, but it depends on the router how quickly disconnected devices disappear from the list(s).
Maybe the bridging between chipsets comes into play here? Are you sure it is the coming home part that is sow?
Arp or brctl should immediately see newly connected mac addresses, but it depends on the router how quickly disconnected devices disappear from the list(s).
Maybe the bridging between chipsets comes into play here? Are you sure it is the coming home part that is sow?
-
- Posts: 443
- Joined: Thursday 12 November 2015 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
You're right, it is indeed when people leave the house that it responds slowly. Sorry for the confusion, it was just a typo.EscApe wrote: ↑Thursday 16 August 2018 18:01 Strange. I would expect the plugin to respond slow to people leaving the house, but it should respond quickly to people coming home.
Arp or brctl should immediately see newly connected mac addresses, but it depends on the router how quickly disconnected devices disappear from the list(s).
Maybe the bridging between chipsets comes into play here? Are you sure it is the coming home part that is sow?
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
-
- 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
I will be away for a couple of weeks, but when i get back i will have a look at supporting more than one wireless chipset in a router. Who of you AC87 owners is willing to test experimental versions and do you have the python/shell skills to help me debug? Developing something for a router i have no access to is going to be a challenge. Obviously the changes should not break the current functionality.
You could also try to get a head start in the mean time
The code by wizzard72 seems a very good starting point.
I think the shell (router) part of the capabilities detection should allow for more commands to be recognized and return multiple commands and interfaces with an extra delimiter character, skipping the arp and brctl if it found any other command. The python part should allow one or more of these combinations to be constructed into one shell command for mac detection. The constructed shell command should always return a (similar) list of mac addresses. Very similar to wizzard72's code, but without assuming wl is always combined with qcsapi_sockrpc.
I'm also not sure if every Quantenna based router will have the name wifi0 and the same indexes.
If we can achieve this, than any combination of chipsets should be supported.
Another option would be trying to detect router models (is possible from nvram for my Asus ac86u) and just hardcode a command for known routers.If it is not a know router the plugin can use the current approach. The downside is that this would require an ever growing 'database' of known routers and a lot of maintenance (firmware changes might break things).
You could also try to get a head start in the mean time
The code by wizzard72 seems a very good starting point.
I think the shell (router) part of the capabilities detection should allow for more commands to be recognized and return multiple commands and interfaces with an extra delimiter character, skipping the arp and brctl if it found any other command. The python part should allow one or more of these combinations to be constructed into one shell command for mac detection. The constructed shell command should always return a (similar) list of mac addresses. Very similar to wizzard72's code, but without assuming wl is always combined with qcsapi_sockrpc.
I'm also not sure if every Quantenna based router will have the name wifi0 and the same indexes.
If we can achieve this, than any combination of chipsets should be supported.
Another option would be trying to detect router models (is possible from nvram for my Asus ac86u) and just hardcode a command for known routers.If it is not a know router the plugin can use the current approach. The downside is that this would require an ever growing 'database' of known routers and a lot of maintenance (firmware changes might break things).
-
- Posts: 116
- Joined: Friday 20 December 2013 7:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Presence detection from wireless router
Hi EscApe,EscApe wrote: ↑Friday 17 August 2018 0:06 I will be away for a couple of weeks, but when i get back i will have a look at supporting more than one wireless chipset in a router. Who of you AC87 owners is willing to test experimental versions and do you have the python/shell skills to help me debug? Developing something for a router i have no access to is going to be a challenge. Obviously the changes should not break the current functionality.
You could also try to get a head start in the mean time
The code by wizzard72 seems a very good starting point.
I think the shell (router) part of the capabilities detection should allow for more commands to be recognized and return multiple commands and interfaces with an extra delimiter character, skipping the arp and brctl if it found any other command. The python part should allow one or more of these combinations to be constructed into one shell command for mac detection. The constructed shell command should always return a (similar) list of mac addresses. Very similar to wizzard72's code, but without assuming wl is always combined with qcsapi_sockrpc.
I'm also not sure if every Quantenna based router will have the name wifi0 and the same indexes.
If we can achieve this, than any combination of chipsets should be supported.
Another option would be trying to detect router models (is possible from nvram for my Asus ac86u) and just hardcode a command for known routers.If it is not a know router the plugin can use the current approach. The downside is that this would require an ever growing 'database' of known routers and a lot of maintenance (firmware changes might break things).
I can and will help you
Maybe it's not that hard to implement multiple different chipsets per device. The outcome of the code from the plugin are multiple supported ways, for example the RT-AC87U support 'wl' and 'qcsapi_sockrpc'. The part of the plugin that detects de capabilities does show the different ways the router support. The outcome of the capabilities is:
Code: Select all
qcsapi_sockrpc@4 wl@eth1
I was looking for ways to loop through the methods that were found. I'm new to Phyton, but I know the basic's of programming. So if we could made some array like this:
method[1] = qcsapi_sockrpc, 4
method[2] = wl, eth1
then you could do a loop through those 2 items. The pollscript part of the plugin is already very good and need less adjusting. Through the loop you can do the pollscript for the 'qcsapi_sockrpc' part and the 'wl' part.
-
- Posts: 443
- Joined: Thursday 12 November 2015 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Python plugin: Presence detection from wireless router
Sounds great guys! I have very limited Python skills, but I am willing to test early versions on my AC87U router.
I also have a request if I may:
Would it be possible to incorporate polling the "eth" interface as well somehow? I have an old router which I use as an extra wireless acces point in the attic. Of course without DHCP functionality, that runs all on my primary router. But devices connected to that extra access point are seen as wired devices by my Asus router. Would be great if future versions of the script can also detect phones on that interface. Using the #forcegeneric flag, this already works fine, but this has the limitations as described (lagginess for leaving the house).
Thanks for your efforts!
I also have a request if I may:
Would it be possible to incorporate polling the "eth" interface as well somehow? I have an old router which I use as an extra wireless acces point in the attic. Of course without DHCP functionality, that runs all on my primary router. But devices connected to that extra access point are seen as wired devices by my Asus router. Would be great if future versions of the script can also detect phones on that interface. Using the #forcegeneric flag, this already works fine, but this has the limitations as described (lagginess for leaving the house).
Thanks for your efforts!
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
-
- 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
@wizzard72:
If I understand correctly the number (4 in your example) is the number of connected devices. If so, then this number would change on every connect/disconnect and can not be determined only at startup.
Is this correct?
The loop should be in the router shell script. Seems very well possible, but will need some experimenting.
On every hearbeat the shell script on the router should get the number of connected devices and then loop through the indexes.
The capabilities detection should not get that number, but the names of the interfaces to check (wifi0 on the ac87).
If this is correct your patch might also fail if the number of connections rises. It might already throw some (unseen) errors when trying an index that no longer exists.
@mvzut:
Unfortunately that will never work, since the script is directly communicating with the wireless interfaces and e.g the am command on router1 does not see connections on router2. Maybe you can install theplugin twice (once for each router) and make the override button on one a slave to the anyone home device on the other router (discribed earlier in this thread)
If I understand correctly the number (4 in your example) is the number of connected devices. If so, then this number would change on every connect/disconnect and can not be determined only at startup.
Is this correct?
The loop should be in the router shell script. Seems very well possible, but will need some experimenting.
On every hearbeat the shell script on the router should get the number of connected devices and then loop through the indexes.
The capabilities detection should not get that number, but the names of the interfaces to check (wifi0 on the ac87).
If this is correct your patch might also fail if the number of connections rises. It might already throw some (unseen) errors when trying an index that no longer exists.
@mvzut:
Unfortunately that will never work, since the script is directly communicating with the wireless interfaces and e.g the am command on router1 does not see connections on router2. Maybe you can install theplugin twice (once for each router) and make the override button on one a slave to the anyone home device on the other router (discribed earlier in this thread)
Who is online
Users browsing this forum: No registered users and 0 guests