1 //Create a class for presence sensor
3 import Timer.SimulatedTimer
5 public class PresenceSensor {
8 private String displayName
9 private String presenceState
10 private String currentPresence
11 private String presenceLatestValue
13 PresenceSensor(int id, String label, String displayName, String presenceState, String presenceLatestValue) {
16 this.displayName = displayName
17 this.presenceState = presenceState
18 this.currentPresence = presenceState
19 this.presenceLatestValue = presenceLatestValue
22 def setValue(String value) {
23 this.presenceLatestValue = presenceState
24 println("the presence sensor with id:$id is triggered to $value!")
25 this.presenceState = value
26 this.currentPresence = value
30 def currentValue(String deviceFeature) {
31 if (deviceFeature == "presence") {
36 def latestValue(String deviceFeature) {
37 if (deviceFeature == "presence") {
38 return presenceLatestValue