SmartThings Presence FOB "integration" with Vera

Hi,

I purchased a SmartThings Controller and have it running standalone alongside my Vera (I’m not using it as secondary zwave controller) to solve the presence issue I had - Android phones with tasker was always a hit an miss.

I will use ST probably for other Zigbee stuff in the future but for now it is a presence detector only ;D

I integrated the 2 by writing a app for SmartThings which will trigger virtual switches on my vera once changes in presence are detected.
In addition ST will send me a notification on the phone.

In case someone is keen to do the same, you will need:

[ul][li]SmartThings Controller - upgraded to lab FW as otherwise the local LAN HTTP push will not work (see the ST forum on how to request this) [/li]
[li]as many presence FOB’s as you need[/li]
[li]the below app which needs to be installed on your ST via the IDE[/li][/ul]

Good luck !

[code]/**

  • Presence Presence Update in Vera & Push Notification
  • Author: SmartThings, adapted by Idefix
  • use network address calculator / ip address calculator to convert your IP
  • (Convert dotted decimal IP-address or mask to binary and hex) and port (Convert decimal to binary and hex) to hex
  • VeraID is the DeviceID of the switch you want to control. Look for it in the Device Advanced tab in Vera
  • Device will be set to ON when presence is detected and OFF upon leaving

*/

preferences {
section(“When a presence sensor arrives or departs this location…”) {
input “presence”, “capability.presenceSensor”, title: “Which sensor?”
}
section(“Set Vera DeviceID…”) {
input “VeraID1”, “number”, title: “DeviceID”
}
}

def installed() {
subscribe(presence, “presence”, presenceHandler)
}

def updated() {
unsubscribe()
subscribe(presence, “presence”, presenceHandler)

}

def presenceHandler(evt) {

def deviceNetworkId = "0A0A000A:D98"  //  "10.10.0.10:3480" update with your Vera IP in hex format
def ip = "10.10.0.10:3480"            // This is the ip and port of the Vera in the network

if (evt.value == "present") {
	log.debug "${presence.label ?: presence.name} has arrived at the ${location}"
		
	sendHubCommand(new physicalgraph.device.HubAction("""GET /data_request?id=lu_action&DeviceNum=${VeraID1}&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1 HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))

	sendPush("${presence.label ?: presence.name} has arrived at the ${location}")

} else if (evt.value == "not present") {
	log.debug "${presence.label ?: presence.name} has left the ${location}"

	sendHubCommand(new physicalgraph.device.HubAction("""GET /data_request?id=lu_action&DeviceNum=${VeraID1}&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0 HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))

	sendPush("${presence.label ?: presence.name} has left the ${location}")
}

}[/code]

nice. funny timing too, because I’ve done something very similar but for the SmartThings Multi-Sensors. I really like them as they act as a door sensor and can measure temperature and orientation…

how accurate are the fobs? are they reasonably reliable and responsive?

so far I had no problems with the FOB. presence status changes within 60 seconds after arrival or departure.
Also the battery drain which got me worried initially (mine dropped to 75% within 2 days) has stopped.
I’m using them for a month now and they at least report still 75%

idefix,

Are the proximity FOBs still working well for you?
Also, do you have any problems with false arrival or departure notification (or any other problems)? Any cloud related downtime?

I’m thinking about doing the same setup as you - z-wave/vera presence detection could really use some improvements. I’m a bit hesitant to move everything to ST though.

I’m also using the ST’s FOBs for presence in Vera, they work nicely for me. My ST hub is at a central location, and Zigbee on average has better range than Z-Wave. Accuracy is good so far.

My primary controller is Vera, but I use ST for the FOBs and the mutli-sensors, they are nifty and flexible. the only shortcoming is that if you lose internet connectivity you lose connection to the ST devices

@Damathon, yes they are still working fine. Initial scare that the batteries will die within a week were unfounded (still going strong).
So far no false positive. Had it once or so that vera did not get the message (no idea what the reason was) other than that working very very well.

idefix, could you please explain the Vera side of the setup you did? I don’t think I understand.

Quick confession: I purchased a Smartthings hub with the plan that I might switch to it entirely. I liked the look of it and the fact that it can talk to so many different types of devices. What I didn’t realize is that Smartthings essentially doesn’t support scenes at all. In fact, it seems like it’s actually impossible to set up something that will set individual dim levels. I actually looks like you have to turn all the dimmers in a “scene” (it looks like they call them “modes”) to the same dim level. Absurd.

Anyway, I was just about to send the thing back when I saw this post, and I’m very interested in giving it a try! I’m just not sure how to work the Vera end of it.

Hi, the vera side is extremely straight forward. For max flexibility I suggest just simply install a virtual switch (plugin from the vera apps), check the device id of that switch once it is created and use this ID in ST when you associate the presence fob.
ST will now toggle the switch ON when the fob is present and off when it is gone.
You can now use this switch in vera the same way you would use any other switch to start scenes or as trigger for PLEG.

More FOB’s? Simply add more virtual switches and you can control scenes depending on each fob’s presence.

Thanks! I’ll have to play around with this. Would this work for my phone, which is listed as a presence sensor in ST?

I have not tested this yet. But if you can run the st app and select the phone as presence sensor it should work.

Thanks! BTW, do you know if I still need to request a different firmware? I only ask because it’s been a while since your first post about this.

Actually I don’t know :-). Probably not as it’s been a while.

Ok I’ll look into it. I’m a little stuck because I can’t figure out how to install the app in your first post. I’m in the ide but I don’t see any way to add an app…

So I think I’ve installed everything correctly. The comments section of the app code, though seems to indicate that I have to enter the device ID there. Is that the case? It seems that this gets entered when I install the app within the app (this gets confusing fast). Is that the case? It seems the only thing I actually change in the code is the IP address for my Vera, and I assume that port 3480 is the correct port.

So far I haven’t been able to get it to work, but I’ll play around a little more. I tried using my phone as the presence sensor and merely turning it off to test it being “away.” That didn’t do anything to the virtual switch I installed. Is there a way to test this other than walking up and down the street with my actual presence sensor? That’ll get old fast…

Oh, and one other thing: it appears that this is for a single sensor controlling a single switch. I was hoping to make use of the “when everyone is gone, do __” capability of the ST system. That, and the “if anyone returns after nobody has been home, do __” Is this possible?

Yes, the device id is set once you install the app.
You need to set both the ip address in decimal (10.0.0.1 or whatever it is) and in hex code (use the online converter). Port does not need to be changed. You can test this by using a virtual presence sensor in the st webpage (saves you the walking…).
One switch per device in vera. Use a scene or PLEG to combine the ones you want to base your final action on (if switch 1, 2 and 3 is away start scene xyz…)

Sent from my Nexus 10 using Tapatalk

Thanks for the clarification. I can’t see how to make a virtual presence sensor, but I’ll test it out with the real thing.

Success! Huzzah! Thanks so much for the help, idefix. It works perfectly, and for both the fob and my phone. That’ll save me money since I can just use the phone presence for my wife and I, and attach my one fob to our kid’s diaper bag. That way we won’t turn off all the lights if we leave our child with a babysitter.

Now I just need to learn how to use PLEG. I didn’t know it would be so complicated. Is there a particularly good thread here that explains it? I ask, because I can’t quite grasp the explanation on the PLEG web site…

Have a look at the pleg wiki. Pretty comprehensive info on how to get started. Good luck.

Thanks! I found the PDF manual in one of the sticky threads and that was very helpful for getting started. I can easily create a PLEG (or whatever it’s called) to carry out an action once all presence sensors have left the house. What I’m struggling with now is how to create an algorithm for the return. I don’t want a simple phrase like “Fob1Returns or Fob2Returns or Fob3Returns.” I mean, I do, but I want it to only trigger when any of those three are true after all three have been away.

In other words, I don’t want to trigger a return scene if only one presence sensor comes back. That would get annoying for the people who never left :slight_smile: I also don’t want to require all three sensors to return.

How do I write this? Have you done something similar?

When I try to paste the code into the Smart App I get “Metadata definition not found”

Thanks