1 //Create a class for contact sensor
4 public class Contacts {
6 private String displayName
7 private String contactCurrentValue
8 private String contactLatestValue
10 Contacts(int id, String displayName, String contactCurrentValue, String contactLatestValue) {
12 this.displayName = displayName
13 this.contactCurrentValue = contactCurrentValue
14 this.contactLatestValue = contactLatestValue
17 def setValue(String value) {
18 this.contactLatestValue = contactCurrentValue
19 println("the contact sensor with id:$id is triggered to $value!")
20 this.contactCurrentValue = value
23 def currentValue(String deviceFeature) {
24 if (deviceFeature == "contact") {
25 return contactCurrentValue
29 def latestValue(String deviceFeature) {
30 if (deviceFeature == "contact") {
31 return contactLatestValue