- MotionSensors(Closure sendEvent, int deviceNumbers) {
- this.sendEvent = sendEvent
- this.deviceNumbers = deviceNumbers
- this.motionSensors = []
-
- def init = Verify.getBoolean()
- if (init) {
- this.motion = "inactive"
- this.motionLatestValue = "inactive"
- } else {
- this.motion = "active"
- this.motionLatestValue = "active"
- }
- motionSensors.add(new MotionSensor(id, label, displayName, this.motion, this.motionLatestValue))
- }
-
- //By Model Checker
- def setValue(LinkedHashMap eventDataMap) {
- if (eventDataMap["value"] != motionSensors[0].motion) {
- motionSensors[0].setValue(eventDataMap["value"])
- this.motionLatestValue = motionSensors[0].motionLatestValue
- this.motion = motionSensors[0].motion
- this.currentMotion = motionSensors[0].motion
- sendEvent(eventDataMap)
- }
- }
-
- //Methods for closures
- def count(Closure Input) {
- motionSensors.count(Input)
- }
- def size() {
- motionSensors.size()
- }
- def each(Closure Input) {
- motionSensors.each(Input)
- }
- def find(Closure Input) {
- motionSensors.find(Input)
- }
- def collect(Closure Input) {
- motionSensors.collect(Input)
- }
-
+ MotionSensors(Closure sendEvent, boolean init) {
+ // Only initialize one time since we only have one device for each capability
+ motionSensors = smartThings