1 //Create a class for SmartThings
4 public class SmartThings {
5 List smartThings = new ArrayList()
7 // Methods for closures
8 def count(Closure Input) {
9 smartThings.count(Input)
16 def each(Closure Input) {
17 smartThings.each(Input)
20 def find(Closure Input) {
21 smartThings.find(Input)
24 def sort(Closure Input) {
25 smartThings.sort(Input)
28 def collect(Closure Input) {
29 smartThings.collect(Input)
32 // Methods to handle events
33 def eventsSince(Date dateObj) {
34 return smartThings[0].eventsSince()
37 def statesSince(String info, Date dateObj) {
38 return smartThings[0].statesSince()
41 // Methods to return states of the devices
42 def propertyMissing(String currentProperty) {
43 if (smartThings[0] == null)
45 List tmpValues = new ArrayList()
46 tmpValues.add(smartThings[0].getProperty(currentProperty))
50 def currentState(String deviceFeature) {
51 List tmpValues = new ArrayList()
52 tmpValues.add(smartThings[0].currentState(deviceFeature))
56 def currentValue(String deviceFeature) {
57 List tmpValues = new ArrayList()
58 tmpValues.add(smartThings[0].currentValue(deviceFeature))
62 def latestValue(String deviceFeature) {
63 List tmpValues = new ArrayList()
64 tmpValues.add(smartThings[0].latestValue(deviceFeature))