Hi,
I found the OpenHab Project at Klenzel.de. A nice german page with interesting hints to bind different “Things”…
on https://klenzel.de/3328 is described a solution to detect the presence via ping and Bluetooth.
Due to the fact, that my openHab-RapberryPI is located in the basement and the WiFi-router in the livingroom, the Wifi-connection of our smartphones is supposed to be much more reliable than the Bluetooth. Therefore I tried to implement just the Ping (WiFi) solution. but it doesn’t works.
The problem is the website isn’t supported anymore. Therefore I won’t get any answers at their discussion board.
Maybe someone knows the page and that solution?!
How can I debug the script? The site and the RESTservice shows both OFF. When I’m logged in as the “pi” user and try the script, it shows the expected state (ON). Some one on the discussion of the source site supposed that openHAB user has no access (permission) to call a ping!?
I won’t believe that, who is not permitted to call a PING !?
In the meanwhile I found a comment to call Linux commands on behalf other users. When I tried the script as openHAB user, it shows the expected state (ON). Therefore I think it is not a permission problem…??
But how could I debug?
bash script located: /scripts/ping.sh
#!/bin/bash
if [ -z "$1" ] ;then
echo "parameter missing"
exit 1;
fi
ping -c1 $1 > /dev/null
if [ $? -ne 0 ]; then
echo "OFF"
else
echo "ON"
fi
the related items/binding:
Switch Phone1_WLAN "Her mobile" (gPresencePhone) {exec="<[/scripts/ping.sh 192.168.1.1:60000:REGEX((.*?))]"}
Switch Phone2_WLAN "His mobile" (gPresencePhone) {exec="<[/scripts/ping.sh 192.168.1.115:60000:REGEX((.*?))]"}
As you can see, it tests the ip of the my router (192.168.1.1) just to make sure it is a valid and active IP.
And finally the sitemap like this:
Frame label="SmartPhone presence"
{
Text item=Phone1_WLAN label="Her mobile [MAP(praesenz.map):%s]" icon="present"
Text item=Phone2_WLAN label="His mobile [MAP(praesenz.map):%s]" icon="present"
}
Again, my question, where could the be problem? How to debug this solution???
Thx in advance!