//Create a class for contact sensor package ContactSensor public class Contacts { private int id private String displayName private String contactCurrentValue private String contactLatestValue Contacts(int id, String displayName, String contactCurrentValue, String contactLatestValue) { this.id = id this.displayName = displayName this.contactCurrentValue = contactCurrentValue this.contactLatestValue = contactLatestValue } def setValue(String value) { this.contactLatestValue = contactCurrentValue println("the contact sensor with id:$id is triggered to $value!") this.contactCurrentValue = value } def currentValue(String deviceFeature) { if (deviceFeature == "contact") { return contactCurrentValue } } def latestValue(String deviceFeature) { if (deviceFeature == "contact") { return contactLatestValue } } }