Author Topic: Any way to tap into Vera's geofencing?  (Read 1093 times)

Offline TheRedPill

  • Full Member
  • ***
  • Posts: 110
  • Karma: +0/-3
Any way to tap into Vera's geofencing?
« on: July 17, 2016, 01:45:05 pm »
I use the Vera app for geofencing but I need a bit more control than just setting house to away / home based on users being out (eg sometimes we have sitters and dont want to do this). As a result I was wondering if anyone has found a way to tap into the Geofencing via LUA, so that I can set a virtual switch and use in PLEG instead?

Thanks

Offline flaquito

  • Jr. Member
  • **
  • Posts: 78
  • Karma: +5/-0
Re: Any way to tap into Vera's geofencing?
« Reply #1 on: September 25, 2016, 10:27:57 pm »
There is! At least, as of this weekend there is. It doesn't seem to be documented anywhere, but I'm using a vswitch for "guest". Toggling that executes Luup that spoofs a Geofence enter/exit for a third user set up on my Vera.

The conversation I had with myself about it is here, but I'll summarize:
  • Create a new basic user on your Vera.
  • Log out of the app on your phone, then log in as the new user.
  • Create a Geofence and set it as home.
  • Log out and log back in as your regular user.
  • Go to http://<Vera_IP>:3480/data_request?id=user_data&output_format=xml
  • Find the <users> section, and note the id of the user you created.
  • Create a virtual switch for Home/Away for your new user, and call it whatever you want.
  • Create a scene triggered by turning on the virtual switch. In your Luup code, put the following (replace <id> with the id you got before):
Code: [Select]
luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","SetGeoFence",
{
["serviceId"] = "urn:micasaverde-com:serviceId:HomeAutomationGateway1",
["action"] = "SetGeoFence",
["userId"] = <id>,
["event"] = "Enter",
["GeofenceId"] = 1
},0)
  • Do the same for turning off the virtual switch, but replace "Enter" with "Exit".

That should do it!

Offline TheRedPill

  • Full Member
  • ***
  • Posts: 110
  • Karma: +0/-3
Re: Any way to tap into Vera's geofencing?
« Reply #2 on: September 26, 2016, 05:20:05 am »
Nice work! I will give it a try, thanks  ;)

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 157
  • Karma: +5/-0
Re: Any way to tap into Vera's geofencing?
« Reply #3 on: February 09, 2018, 05:55:48 am »
This is great! But how do I know if the luup code works? It runs successfully, but I can't see that the ishome setting is changed in the XML.

UPDATE:
Nevermind I had to login with my new guest user in the app again, it hadn't send an enter command to the server yet.

BTW. Don't forget to validate the new user first.
« Last Edit: February 09, 2018, 06:03:13 am by RHCPNG »