be77c046b78c1ee08be3c0c5ec52774ab1810d11
[smartthings-infrastructure.git] / BeaconSensor / BeaconSensor.groovy
1 //Create a class for beacon sensor
2 package BeaconSensor
3 import SmartThing.SmartThing
4
5 public class BeaconSensor extends SmartThing {
6         // id, label, and display name of the device
7         StringBuilder id = new StringBuilder()
8         StringBuilder label = new StringBuilder()
9         StringBuilder displayName = new StringBuilder()
10         // Features with string values
11         StringBuilder currentPresence = new StringBuilder()
12         // Maps from features to values
13         HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
14
15         BeaconSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentPresence) {
16                 deviceValuesMap = deviceValueSmartThing
17                 idSmartThing = id
18                 labelSmartThing = label
19                 displayNameSmartThing = displayName
20                 sendEventSmartThings = sendEvent
21
22                 // Initialization
23                 this.id = id
24                 this.label = label
25                 this.displayName = displayName
26                 this.currentPresence = currentPresence
27                 
28                 deviceValuesMap.put("beacon", currentPresence)
29         }
30
31         // Methods to return values
32         def getCurrentPresence() {
33                 return currentPresence.toString()
34         }
35 }