Device status not updating until I refresh manually

Hello Ladies and Gents,
I have two Aeotec Smart Switch 6 devices. One is on and one is off. I want the one that is on steer the one that is off by power draw. Meaning that if something gets plugged into Plug A and draws power then Plug B should turn on.
This is intended for a dryer booster/fan I have installed. Basically, when the dryer turns on I want the dryer booster/fan to turn on as well … automatically. Same for turning off.

I came up with this code based on a modified smartthings template for energy metering.


preferences {
section {
input(name: “meter”, type: “capability.powerMeter”, title: “When the dryer turns on…”, required: true, multiple: false, description: null)
input(name: “threshold”, type: “number”, title: “Set power threshold…”, required: true, description: “in either watts or kw.”)
}
section {
input(name: “switches”, type: “capability.switch”, title: “Turn On the booster fan”, required: true, multiple: true, description: null)
}
}

def installed() {
log.debug "Settings applied: ${settings}"
initialize()
}

def updated() {
log.debug "Settings updated: ${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 fan on."
switches.on()
}
if (meterValue < thresholdValue) {
log.debug "${meter} reported energy consumption below ${threshold}. Turning fan off."
switches.off()
}
}

Everything works as intended but I have to stay in the app and press refresh on Plug A in order for it to work. Same when the load is removed, Plug B will remain turned on until refresh Plug A. Maybe it’s just a local problem here with me but if anybody has any ideas on how to remedy this, I would appreciate it.

1 Like

help bump please