I’m trying to use the GeoFency/Locative apps for tracking presence and triggering events when I leave work. Both apps can call a HTTP URL when a geofence (GPS location) is entered/left. Unfortunately both apps insist on posting the whole location data instead of just calling my URL (https://my.openhab.org/CMD?Presence_Fence1=ON). When calling the URL from the command line (with curl and HTP basic auth) it works.
GeoFency does not do anything (It just displays “Forbidden”, probably because it’s doing a POST request why my.openhab expects GET), Locative does a GET request but puts additional parameters in the URL (id, longitude, latitude and device) which is interpreted as additional items, which are then not found.
I could write a simple PHP proxy script that receives the data from the app and then makes the request to my.openhab, but then this script has to be deployed and updated and every year get a new SSL certificate. I’d rather have some other option to do this. Any ideas?
The following alternatives are rather undesirable:
use OwnTracks/MQQitude. I don’t want detailed tracking and an additional cloud/server component.
Create “id”, “device”, “longitude”, “latitude” items. I don’t want to pollute my item file.
I tried something similar.
I wrote a two php scripts: one for entering (IN.php) and one for leaving (OUT.php) and used the webhook to get them executed on my home server. The IN sript wrote “Anwesend” and the OUT scrpit “Abwesend” in a thrird file (Presence.php).
Via exec binding I evaluated this file every minute to detect the location and used a text item to visualize it in the sitemap.
It work good.
However: For this to work, I had to drill a hole in my router by opening up a port. I have openhab running on a Netgear NAS and could block certain folders as well as create password use (Geofency allows this). Nevertheless, I believed so far the risk to high, that someone work highjack my server.
Please advise how you intend to use the SSL certificate with Geofency?
This link provides a very extensive a solid description on how to accomplish a VPN-on-demand connection to the server; client is an iphone.
Using this method, the Geofency app (which is really a fantastic presence locator and much more) will automatically set up a VPN connection when I leave a location and execute a php script on my server changing my status from “Anwesend” to “Abwesend” or “Arbeit” or what ever locations you have defined.
Note: I cannot determine any increase in power consumption or of battery life of my iphone.
I wrote one php script and used the webhook to get them executed on my web server. the script only wrote on or off in a log file on my webserver. every 1 minute i check with openhab the LOG file. so nothing is open on my openhab server.
You could post a tutorial in the Solutions&Tutorials topic with a set-by step of the set-up and examples of code.
There are excellent examples on the forum already MQTT 101 being one of them
I followed the same structure for my tutorial on MQTT and SSL
my daugther lately switched from Android to iOS and I have the mess that my easy PHP script that I could call via a simple weblink from Android does not work anymore as the apps on iOS (Locative and Geofency) only work with wehooks.
I am absolutely no programmer and hence I would just simply like to further use my simple scripts that get triggered by the incoming webhook POST message.
Hence I kindly ask you to share your script which seems to do what I would need. Maybe I completely adopt your smart approach with the decoupled log file
At a minimum I hope to learn from your PHP script how to trigger my existing PHP scripts to set the item state of the presence detection (even though it is less secure …)
Thank you for sharing your knowledge with a newbie