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