1 //Create a class for presence sensor
3 import Timer.SimulatedTimer
5 public class PresenceSensor {
8 private String displayName
9 private String presence
10 private String currentPresence
11 private String presenceLatestValue
13 PresenceSensor(String id, String label, String displayName, String presence, String presenceLatestValue) {
16 this.displayName = displayName
17 this.presence = presence
18 this.currentPresence = presence
19 this.presenceLatestValue = presenceLatestValue
22 def setValue(String value) {
23 println("the presence sensor with id:$id is triggered to $value!")
24 this.presenceLatestValue = value
26 this.currentPresence = value
29 def currentState(String deviceFeature) {
30 return [rawDateCreated: [time: System.currentTimeMillis()]]
33 def currentValue(String deviceFeature) {
34 if (deviceFeature == "presence") {
39 def latestValue(String deviceFeature) {
40 if (deviceFeature == "presence") {
41 return presenceLatestValue