1 //Create a class for relay switch device
3 import SmartThing.SmartThings
5 public class RelaySwitches extends SmartThings {
6 List relaySwitches = new ArrayList()
8 RelaySwitches(Closure sendEvent, boolean init) {
9 // Only initialize one time since we only have one device for each capability
10 relaySwitches = smartThings
13 StringBuilder id = new StringBuilder("relaySwitchID0")
14 StringBuilder label = new StringBuilder("relaySwitch")
15 StringBuilder displayName = new StringBuilder("relaySwitch0")
16 StringBuilder currentSwitch = new StringBuilder()
19 currentSwitch.append("off")
21 currentSwitch.append("on")
23 relaySwitches.add(new RelaySwitch(sendEvent, id, label, displayName, currentSwitch))
26 // Methods to set values
31 def on(LinkedHashMap metaData) {
36 relaySwitches[0].off()
39 def off(LinkedHashMap metaData) {
43 // Methods to return values
44 def getCurrentSwitch() {
45 List tmpValues = new ArrayList()
46 tmpValues.add(relaySwitches[0].getCurrentSwitch())