Help with a new zigbee device handler for ceiling fan/light controller


(Dale C) #1

I am in the final stages of modifying a zigbee ceiling fan/light controller that Home Depot sells as Wink Enabled. I am brand new to working with device handlers but have really enjoyed all that I have learned in the past couple of weeks tweaking the code to better fit my use case that I can share with others of similar needs. :slight_smile:

Here is the “problem”, this zigbee hardware is basically a combination device of both fan speed control plus dimming light control in one unit. The best I can tell ST sees this zigbee hardware as only a single device which is a light dimmer, not an on-off for the fan motor speeds.

Is there something I can do in the code to let ST off the shelf smartapps interact with the fan speed hardware as if it was separate devices as I list below or what are my options? I was trying to see how the dht are written for dual relays devices because that seems to be similar issue?

  1. light dimming switch (this is currently how ST sees the hardware)
  2. fan low speed switch
  3. fan med speed switch
  4. fan high speed switch

(Michael) #2

I think you’ll find this thread very helpful.


(Michael) #3

Oh, you’re already involved in that. Carry on!


(Dale C) #4

That is the one I am modifying :grinning:


(Dale C) #5

Why isn’t the tile displaying transitioning state background blue color #2179b8?

I am trying to match the tile operational technique exactly that @ChadCK and @johnconstantelo did on the Z-Wave Smart Fan Control Custom Device Handler I must not be understanding the correct syntax on the state parameters?

On the GE Smart Fan device code below it works perfectly if I tap any standard speed tile, the background changes to blue simultaneously as the main multiAttribute tile changes to blue/ADJUSTING while it changes speed that I just pressed.

	multiAttributeTile(name: "switch", type: "lighting", width: 6, height: 4, canChangeIcon: true) {
		tileAttribute ("device.currentState", key: "PRIMARY_CONTROL") {
			attributeState "default", label:'ADJUSTING', action:"refresh.refresh", icon:"st.Lighting.light24", backgroundColor:"#2179b8", nextState: "turningOff"
			attributeState "HIGH", label:'HIGH', action:"switch.off", icon:"st.Lighting.light24", backgroundColor:"#486e13", nextState: "turningOff"
			attributeState "MED", label:'MED', action:"switch.off", icon:"st.Lighting.light24", backgroundColor:"#60931a", nextState: "turningOff"
			attributeState "LOW", label:'LOW', action:"switch.off", icon:"st.Lighting.light24", backgroundColor:"#79b821", nextState: "turningOff"
			attributeState "OFF", label:'OFF', action:"switch.on", icon:"st.Lighting.light24", backgroundColor:"#ffffff", nextState: "turningOn"
			attributeState "turningOn", action:"switch.on", label:'TURNINGON', icon:"st.Lighting.light24", backgroundColor:"#2179b8", nextState: "turningOn"
			attributeState "turningOff", action:"switch.off", label:'TURNINGOFF', icon:"st.Lighting.light24", backgroundColor:"#2179b8", nextState: "turningOff"
		}
		tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
			attributeState "level", label:'${currentValue}%'F
		}
	}
	standardTile("lowSpeed", "device.currentState", inactiveLabel: false, width: 2, height: 2) {
    	state "default", label: 'LOW', action: "lowSpeed", icon:"st.Home.home30", backgroundColor: "#ffffff"
		state "LOW", label:'LOW', action: "lowSpeed", icon:"st.Home.home30", backgroundColor: "#79b821"
		state "ADJUSTING.LOW", label:'LOW', action: "lowSpeed", icon:"st.Home.home30", backgroundColor: "#2179b8"
	}
	standardTile("medSpeed", "device.currentState", inactiveLabel: false, width: 2, height: 2) {
		state "default", label: 'MED', action: "medSpeed", icon:"st.Home.home30", backgroundColor: "#ffffff"
		state "MED", label: 'MED', action: "medSpeed", icon:"st.Home.home30", backgroundColor: "#79b821"
        state "ADJUSTING.MED", label:'MED', action: "medSpeed", icon:"st.Home.home30", backgroundColor: "#2179b8"
	}
	standardTile("highSpeed", "device.currentState", inactiveLabel: false, width: 2, height: 2) {
		state "default", label: 'HIGH', action: "highSpeed", icon:"st.Home.home30", backgroundColor: "#ffffff"
		state "HIGH", label: 'HIGH', action: "highSpeed", icon:"st.Home.home30", backgroundColor: "#79b821"
        state "ADJUSTING.HIGH", label:'HIGH', action: "highSpeed", icon:"st.Home.home30", backgroundColor: "#2179b8"

On my code to mimic this behavior above I do not get any of the blue changing transitioning backgrounds when I tap the standard tiles? When I try to modify the line with [state "ADJUSTING…] I can totally freeze up states being displayed on the device properly. What am I misunderstanding below? (Sorry for clutter of comments but I have it in as I learning what the parts of the code are) The commented out states are things I was trying that totally don’t work.

    tiles(scale: 2) {
    	// FAN SWITCH multiple attributes tile with actions named
		multiAttributeTile(name: "switch", type: "lighting", width: 6, height: 4, canChangeIcon: true) {
        	// All tiles must define a PRIMARY_CONTROL. Controls the background color of tile, and specifies the attribute to show on the Device list views
			tileAttribute ("device.fanMode", key: "PRIMARY_CONTROL") {
            
                //We can use the nextState option in state (single-attribute tiles) or attributeState (Multi-Attribute Tiles) to show 
                //that the device is transitioning to a next state. This is useful to provide visual feedback that the device state is transitioning.
                //When the attribute’s state does change, the tile will be updated according to the state defined for that attribute.
                //To define a transition state, simply define a state for the transition, and reference that state using the nextState option.
              
                attributeState "default", label:'ADJUSTING', action:"refresh.refresh", icon:"st.Lighting.light24", backgroundColor:"#2179b8", nextState: "turningOff"	//light blue bckgrd
				attributeState "fanFour", label:'HIGH', action:"fanOff", icon:"st.Lighting.light24", backgroundColor:"#486e13", nextState: "turningOff"			// green4 bckgrnd
				attributeState "fanThree", label: 'MED-HI', action:"fanOff", icon:"st.Lighting.light24", backgroundColor:"#558216", nextState: "turningOff"		//green3 bckground
				attributeState "fanTwo", label: 'MED', action:"fanOff", icon:"st.Lighting.light24", backgroundColor:"#669c1c", nextState: "turningOff"			//green2 bckground
				attributeState "fanOne", label:'LOW', action:"fanOff", icon:"st.Lighting.light24", backgroundColor:"#79b821", nextState: "turningOff"			//green1 bckgrnd
				attributeState "fanAuto", label:"BREEZE", action:"fanOff", icon:"st.Lighting.light24", backgroundColor:"#00A0DC", nextState: "turningOff"		//blue bckgrd
        		attributeState "fanOff", label:"FAN OFF", action:"fanOne", icon:"st.Lighting.light24", backgroundColor:"#ffffff", nextState: "turningOn"		//gray bckgrnd 
				attributeState "turningOn", action:"fanOne", label:"TURNINGON", icon:"st.Lighting.light24", backgroundColor:"#2179b8", nextState: "turningOn"	//light blue bckgrd
				attributeState "turningOff", action:"fanOff",     label:"TURNINGOFF", icon:"st.Lighting.light24", backgroundColor:"#2179b8", nextState: "turningOff"	//light blue bckgrd
   
            }

           	// LIGHT control dimmer tile with slider actions  
            tileAttribute ("device.level", key: "SLIDER_CONTROL") {
				attributeState "level", action:"switch level.setLevel"
			}         
		}
        
      
    	// LIGHT standard flat tile with actions 
		standardTile("fanLight", "device.switch", width: 2, height: 2, decoration: "flat") {
			state "off", label:'${name}', action: "switch.on",
            	icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Light175xfinal.png", backgroundColor: "#ffffff" //, nextState:"turningOn"
			state "on", label:'${name}', action: "switch.off", 
            	icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Light175xfinal.png", backgroundColor: "#79b821" //, nextState:"turningOff"
//          state "turningOn", label:'Turning on', icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Light175xfinal.png", backgroundColor:"#79b821", nextState: "turningOff"
//   		state "turningOff", label:'Turning off', icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Light175xfinal.png", backgroundColor:"#ffffff", nextState: "turningOn" 
		}   
   
 		// fanSPEED standard tile with actions 
 		standardTile("fanOne", "device.fanMode", inactiveLabel: false, width: 2, height: 2) {
        	state "default", label: 'LOW', action: "fanOne", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#ffffff"
			state "fanOne", label:'LOW', action: "fanOne", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#79b821"
//            state "turningTwo", label:'ADJ MED', action: "fanTwo", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#2179b8"
// 		 	  state "ADJUSTING.LOW", label:'LOW', action: "lowSpeed", icon:"st.Home.home30", backgroundColor: "#2179b8"       
			state "ADJUSTING.fanOne", label:'ADJ_LOW', action: "fanOne", icon:"st.Home.home30", backgroundColor: "#2179b8" 
        }
		
		standardTile("fanTwo", "device.fanMode", inactiveLabel: false, width: 2, height: 2) {
			state "default", label: 'MED', action: "fanTwo", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#ffffff"
			state "fanTwo", label: 'MED', action: "fanTwo", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#79b821"
//           state "turningThree", label:'ADJ MED-HI', action: "fanThree", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#2179b8"
//           state "ADJUSTING.MED", label:'MED', action: "medSpeed", icon:"st.Home.home30", backgroundColor: "#2179b8"
//           state "ADJUSTING.MED", label:'MED', action: "fanTwo", icon:"st.Home.home30", backgroundColor: "#2179b8"        
        }
         
        standardTile("fanThree", "device.fanMode", inactiveLabel: false, width: 2, height: 2) {
			state "default", label: 'MED-HI', action: "fanThree", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#ffffff"
			state "fanThree", label: 'MED-HI', action: "fanThree", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#79b821"
//			state "turningThree", label:'ADJ MED-HI', action: "fanThree", icon:"https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/devicetypes/dcoffing/hampton-bay-universal-ceiling-fan-light-controller.src/Fan175xfinal.png", backgroundColor: "#2179b8"
//			state "ADJUSTING.MED-HI", label:'MED-HI', action: "fanThree", icon:"st.Home.home30", backgroundColor: "#2179b8"   
        }