Infrastruction modification
[smartthings-infrastructure.git] / BeaconSensor / BeaconSensors.groovy
1 //Create a class for beacon sensor
2 package BeaconSensor
3 import SmartThing.SmartThings
4
5 public class BeaconSensors extends SmartThings {
6         List beaconSensors = new ArrayList()
7
8         BeaconSensors(Closure sendEvent, boolean init) {
9                 beaconSensors = smartThings
10
11                 // Initialization
12                 StringBuilder id = new StringBuilder("beaconID0")
13                 StringBuilder label = new StringBuilder("beacon")
14                 StringBuilder displayName = new StringBuilder("beacon0")
15                 StringBuilder presence = new StringBuilder()
16
17                 if (init)
18                         presence.append("not present")
19                 else
20                         presence.append("present")
21
22                 beaconSensors.add(new BeaconSensor(sendEvent, id, label, displayName, presence))
23         }
24
25         // Methods to return values
26         def getCurrentPresence() {
27                 List tmpValues = new ArrayList()
28                 tmpValues.add(beaconSensors[0].getCurrentPresence())
29                 return tmpValues
30         }
31 }