1 //Create a class for contact sensor
3 import SmartThing.SmartThings
5 public class ContactSensors extends SmartThings {
6 List contacts = new ArrayList()
8 ContactSensors(Closure sendEvent, boolean init) {
9 // Only initialize one time since we only have one device for each capability
10 contacts = smartThings
13 StringBuilder id = new StringBuilder("contactID0")
14 StringBuilder label = new StringBuilder("contact")
15 StringBuilder displayName = new StringBuilder("contact0")
16 StringBuilder currentContact = new StringBuilder()
19 currentContact.append("closed")
21 currentContact.append("open")
23 contacts.add(new ContactSensor(sendEvent, id, label, displayName, currentContact))
26 // Methods to return values
27 def getCurrentContact() {
28 List tmpValues = new ArrayList()
29 tmpValues.add(contacts[0].getCurrentContact())