Z-Wave Smart Fan Control Custom Device Type

So I’m trying to create virtual fan control using this device type and I’m running into an issue. My use case is I would like to have a Master Fan Control that would control all 5 fans in my house. Utilizing Rule Machine I would control all of the fans based on this virtual fan control. The issue I’m having is once I’ve create a new device using this device type it constantly states that it’s adjusting and never goes On/Off or changes levels. I’ve done something similar using virtual dimmer and Rule Machine with great success. I’ve tried to hack this device type code but I’m a complete newbie to all of this and I’m hoping someone can provide some direction. Thanks in advance for any help.

You’ll need to really edit it down to work as a virtual device and add sendEvent() code to each of the commands (on/off/setLevel). The top part can stay as is, but starting with the parse() section, you can eliminate most if not all the code. Try this below.

1 - You can remove refresh() and poll() from both the body and the UI since you can’t really refresh a virutal device. 2 - You can probably remove the indicator status stuff as well unless you were going to use a custom app to relay changes from the virtual device out to the slaves for that.

def parse(String description) {

def on() {
	log.info "on"
	sendEvent(name: "switch", value: "on")

def off() {
	log.info "off"
	sendEvent(name: "switch", value: "off")
sendEvent(name: "currentState", value: "OFF" as String)

def setLevel(value) {
	sendEvent(name: "currentState", value: "changingState" as String, displayed: false)
	def level = Math.min(value as Integer, 99)
	log.trace "setLevel(value): ${level}"
	sendEvent(name: "level", value: level)
    if (level > 0 && device.currentValue("switch") == "off") { 
     sendEvent(name: "switch", value: "on")

    def setLevel(value, duration) {
	sendEvent(name: "currentState", value: "changingState" as String, displayed: false)
	def level = Math.min(value as Integer, 99)
	sendEvent(name: "level", value: level)
def findSpeed(value) {
def lowThresholdvalue = (settings.lowThreshold != null && settings.lowThreshold != "") ? settings.lowThreshold.toString() : "33"
def medThresholdvalue = (settings.medThreshold != null && settings.medThreshold != "") ? settings.medThreshold.toString() : "67"
def highThresholdvalue = (settings.highThreshold != null && settings.highThreshold != "") ? settings.highThreshold.toString() : "99"

if (value <= lowThresholdvalue) {
		sendEvent(name: "currentState", value: "LOW" as String)
	if (value >= lowThresholdvalue+1 && item2.value <= medThresholdvalue) {
		sendEvent(name: "currentState", value: "MED" as String)
	if (value >= medThresholdvalue+1) {
		sendEvent(name: "currentState", value: "HIGH" as String)

def lowSpeed() {
	def lowThresholdvalue = (settings.lowThreshold != null && settings.lowThreshold != "") ? settings.lowThreshold.toString() : "33"

def medSpeed() {
	def medThresholdvalue = (settings.medThreshold != null && settings.medThreshold != "") ? settings.medThreshold.toString()  : "67"

def highSpeed() {
	def highThresholdvalue = (settings.highThreshold != null && settings.highThreshold != "") ? settings.highThreshold.toString() : "99"

def poll() {

def refresh() {

def indicatorWhenOn() {
	sendEvent(name: "indicatorStatus", value: "when on", display: false)

def indicatorWhenOff() {
	sendEvent(name: "indicatorStatus", value: "when off", display: false)

def indicatorNever() {
	sendEvent(name: "indicatorStatus", value: "never", display: false)

First off, thanks. I switched from the old code to this, and it’s improved nicely.
One issue however, is the never lit indicator seems to act more like when on. Anyone else have this? Could this be code related somehow?

Thanks for the really good direction @Sticks18. I will give this a try today.

It’s most likely the device. A lot of these zwave switches have an issue with the never lit parameter (none of my 7 dimmers, switches, fan controls work). You can try this SmartApp to manage the indicator. It switches the indicator setting when the fan is turned on/off to emulate the never lit option. You’ll need to install a new instance for each fan/switch you want to manage. I use it for two fans since we sometimes sleep with it on and sometimes off.

Thanks, I’ll give this a try. Almost all of my switches work fine, except the two fan controllers. Actually, one of the two might work I’ll have to recheck.

so I am a complete noob at this. Just got my SmartThings Hub today and hooked up the GE Smart Fan Controller. What I was wondering is how do i go about implementing this so my app looks/does what this codes does.

FYI I am using an iOS device for the SmartThings App

well i guess it helps not doing this at 2 in the morning. after some sleep and reading so more on the forums i was able to figure it out


Very nicely done! Big thanks to @johnconstantelo @Sticks18 @ChadCK for a great job. Love the little tweaks to keep it improving

UPDATE: Thermostat control of Ceiling Fan @ChadCK @johnconstantelo
Just wanted to say how much I appreciated all the effort and awesome work on your device handlers! I just uploaded a smartapp that I use with your device handler and it is working really well for automatically controlling the fan low, medium, high speeds based on any temperature input with the option of having motion control.

1 Like

Great thread and work being done here! I bought the GE 12730 Fan Control but want to use it for a different purpose… Specifically I want to use it to control this fan: http://www.amazon.com/GE-12730-Z-Wave-Smart-Control/dp/B00PYMGVVQ

That is a variable speed fan that goes into duct work. According to the manufacturer the fan is “100% speed controllable”. I take this to mean that instead of having a low/medium/high market like typical ceiling fans have, this duct fan can be set to run at speeds on a sliding scale.

Do you think I will be able to use the GE12730 to have this fine level of speed control, where it can be anywhere from say 0-100% speed (or something close to that)? Or do you think the GE 12730 will not send the incremental changes on the slider - but only signal it when it cross thresholds like what it considers slow/med/high speed? In other words - is the reason that the slider only works for three speeds a function of the ceiling fans, or a function of the GE device itself. If this is a limitation of the GE 12730, is there any other z-wave switch out there that will allow me to run my duct fan at a full range of speeds?

If I am stuck with just three speeds low/med/high, then hopefully I can still set the thresholds low? For instance I may need to only run the fan at 10%, 25% or 50% but never close to max speed.

Also on a related note- Will I be able to use Smart Rules or something like it to create commands like:
if motion is detected then
if temperature is < 30 degrees then
tell GE 12730 to run the fan at 10%
else if temperature is >=30 and temperature is < 50 then
tell GE 12730 to run the fan at 20%
etc etc

Thank you!

Hi @HDGuy. No, you won’t be able to that, so I think you’re stuck, and stuck with the defaults for low/med/high. I got the switch when it first came out, and in my testing while writing the first version of the device handler the switch would only change at set thresholds for low, med, and high. Those are set internally at the switch, not via ST.

I’ve tried incrementing the levelset values by 1% from 0 to 100, but the switch would not change until the built in values were met. I did not investigate if there are configuration parameters that could be tweaked to override the defaults (like what can be done for ramp rates for the GE dimmers).

With regards to your rules question, yes - assuming you can find a device that has the range and flexibility of a dimmer switch, but is designed for motor control.

Thanks John! I assume the way the duct fan work is that based on the amount of voltage it gets it ramps from 0 to 100% speed. Further I assume that the GE 12730 puts out a fixed voltage at low, medium and high. So I guess its correct to assume that whatever speed the fan spins at for those three voltages are my only options. Do I understand correctly that’s how it will be? I assume you don’t know of a Z-Wave device that supports variable speed or you would have mentioned it. I’ll try calling GE tomorrow (assuming I can even find the phone number to their Z-Wave controls group) to see if there is any way to override that fixed-preset behavior, but its unlikely.

So assuming there is no workaround for the GE device and no other device that can do it - I’m thinking now about possible work-arounds. This could be VERY cludgy but what do you think about the idea of having a group of these devices: http://amzn.com/B00EVYGPJQ

Say I had 3 of them. Each one would be manually set to give me the desired fan speed for three difference “presets” / scenarios. Then somehow wire these with a Z-Wave relay/switch so that it would give power to only one of the three (z-wave selectable) which would then feed the duct fan. Even tho this limits me to three fixed fan speeds, at least the 3 speeds would be what I wanted (instead of whatever speed those GE presets would run the fan at, the fastest of which I already know will be too fast).

Does that sound like a viable workaround? Any thoughts on what Z-Wave controls I could buy to work do the switching between the three Vantech manual switches and how they could be wired up to all feed the duct fan? Thanks!!

Could you not just use an actual Zwave Dimmer and not the fan control?

GE Z-Wave Smart Dimmer (In-Wall), 12724 https://www.amazon.com/dp/B006LQFHN2/ref=cm_sw_r_cp_awd_KDt2wbB75DHEF

I do not have one myself but I believe that provides the additional stepping you are wanting.

Maybe I’m missing something from what you are asking or someone else can chime in about a normal dimmer.

Chad - I am not sure about this, but someone told me that dimmers may work by regulating the wattage, whereas the fan switch may work by regulating the voltage. And that for some perhaps all variable speed fans, the voltage needs to be regulated not the fan. I am not sure about any of this so don’t go by me, but that was what I heard. If that indeed is the case (anyone know?) then to regular my fan speed I would not be able to use a dimmer.

You should definitely not use a dimmer to regulate most fans.

Here is an excellent write-up done by the very helpful @JDRoberts that will explain why this is such a bad idea:

1 Like

Thanks guys. Since the Smart Fan Control is not appropriate for my project I’ve started a new thread (to keep this one on-topic) to see if anyone is aware of a control that will do what I am looking for, and if not perhaps this could be achieved by with a combination of Z-wave and old-school parts. The thread is here Z-Wave device for TRUE variable speed fan control? and comments and suggestions are welcome and appreciated there. Thanks again!

1 Like

Having issues copying the code to SmartApps. Not sure what I’m doing wrong here. Here’s the error: No signature of method: script**********************.metadata() is applicable for argument types: (script**********************$_run_closure1) values: [script**********************$_run_closure1@595d88d] Possible solutions: getMetadata(), getState(), setState(java.lang.Object), metaClass(groovy.lang.Closure)

Hi @maelstromm,

Make sure you are adding the code as a device handler, not as a smartapp, and you’ll be in great shape!

1 Like

I’m not seeing the fan level % indicated anymore on the UI (IOS) for both my fans. I’m pretty sure it was there previously so I’m wondering if anything changed recently?

Hi @Roadrider,

Version 2.1.0 of the iOS and Android app hosed it.