//Create a class for presence sensor package PresenceSensor import Timer.SimulatedTimer public class PresenceSensor { private String id private String label private String displayName private String presence private String currentPresence private String presenceLatestValue PresenceSensor(String id, String label, String displayName, String presence, String presenceLatestValue) { this.id = id this.label = label this.displayName = displayName this.presence = presence this.currentPresence = presence this.presenceLatestValue = presenceLatestValue } def setValue(String value) { println("the presence sensor with id:$id is triggered to $value!") this.presenceLatestValue = value this.presence = value this.currentPresence = value } def currentState(String deviceFeature) { return [rawDateCreated: [time: System.currentTimeMillis()]] } def currentValue(String deviceFeature) { if (deviceFeature == "presence") { return presence } } def latestValue(String deviceFeature) { if (deviceFeature == "presence") { return presenceLatestValue } } }