Help with a Garage Dust Collector Management app?


#1

I’ve modified the SmartThings energy app (normally turns off switches if an energy threshold is exceeded) to turn on switches if a set threshold is exceeded. Otherwise, it turns them off.

Normally you would use a remote, or a load sensing outlet to manage a dust collector (vacuum) when a power tool is powered up. I’d like to use a few of these: Aeon Labs DSC06106-ZWUS - Z-Wave Smart Energy Switches to manage the dust collector automatically. I have this working right now with the SmartThings smart plugs, however they are only rated for 12amps.

Right now, this app turns on one or multiple switches ( connected to dust collector(s)) if one SmartPlug (with energy monitoring) exceeds the user-set threshold. It would be about perfect if you could monitor multiple smart plugs (each connected to a power tool) and turn on one or more switches for the dust collector(s). I’m wondering if one of you could modify this code so that you can choose multiple Smart Plugs so that if any of them exceeded the set threshold, the switches would power up. All of the Smartplugs would be need to report below the threshold to trigger all of the switch(s) to power-off.

This way if you have 2 or 3 machines powered by smart plugs and connected to the dust management tubes, any of them powered up would in turn power on all the dust management switch(s). If all of the smart plugs are reporting below the set threshold, ideally you would wait about 5 seconds, then power all of the dust collector switches off.

I’m a code newbee…so was hoping one of you wizards could help me out :slight_smile: Hope that makes sense. If this is a license issue, let me know. Doing this in RM is super easy, but as it is currently not an option for new users, I figured a Smart App would be nice. Cheers, Dennis.

/**
 *  Energy Saver
 *
 *  Copyright 2014 SmartThings
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Dust Collector Smart Plugs",
    namespace: "smartthings",
    author: "SmartThings, modified by Dennis Wood",
        description: "Dust collector plug management",
    category: "Green Living",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png"
)

preferences {
    section {
        input(name: "meter", type: "capability.powerMeter", title: "When This Plug...", required: true, multiple: false, description: null)
        input(name: "threshold", type: "number", title: "Reports Above...", required: true, description: "in either watts or kw.")
    }
    section {
        input(name: "switches", type: "capability.switch", title: "Turn On These Switches (otherwise off)", required: true, multiple: true, description: null)
    }
}

def installed() {
    log.debug "Installed with settings: ${settings}"
    initialize()
}

def updated() {
    log.debug "Updated with settings: ${settings}"
    unsubscribe()
    initialize()
}

def initialize() {
    subscribe(meter, "power", meterHandler)
}

def meterHandler(evt) {
    def meterValue = evt.value as double
    def thresholdValue = threshold as int
    if (meterValue > thresholdValue) {
        log.debug "${meter} reported energy consumption above ${threshold}. Turning on switches."
        switches.on()
         } else {
            switches.off()
        }
    
}

#2

Apparently I was overthinking the room. Groovy is managing the array of smartplugs with no need for more programming. I did some reading, and copy/pasted/mod’d the code from samples.

If tools are plugged into one or more selected smart plugs, powering up any tool will trigger selected switches (to remotely turn on dust collectors or vacuums), providing tool power draw is above the threshold you select. You can also set an off delay so the dust collector can clear the dust collection tubes after you power off the tool. This frees you to plug tools and vacuums/collectors into separate circuits to avoid popping breakers. This bit of code and a few smartplugs effectively replaces devices like this without the need to run extension cords from separate circuits.

/**
* Shop Dust Management Control
*
* Copyright 2016 Dennis Wood
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "Dust Collector Switch Control",
namespace: "denniswood",
author: "Dennis Wood",
description: "App to Manage Dust Collector",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")

preferences {
	section {
		input(name: "meter", type: "capability.powerMeter", title: "When any of These SmartPlugs...", required: true, multiple: true, description: null)
        input(name: "threshold", type: "number", title: "Reports Power use Above...", required: true, description: "in either watts or kw.")
        input(name: "switches", type: "capability.switch", title: "Turn On These Switches", required: true, multiple: true, description: null)
        input(name: "offdelay", type: "number", title: "Off Delay when Power Drops (seconds)", required: true )
	}
}

def installed() {
log.debug "Installed with settings: ${settings}"
unsubscribe()
initialize()
}

def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}


def initialize() {
	subscribe(meter, "power", meterhandler)
}

def meterhandler(evt) {
    def meterValue = evt.value as double
    def thresholdValue = threshold as int
log.debug "$evt.displayName is $evt.value"
if (meterValue > thresholdValue) {
	switches.on()
}
else {
	def delay = offdelay * 1000
    log.debug "Delay is ${delay} ms"
	switches.off(delay: delay)
}

}