Zigbee commands rattr, wattr, cmd


(Nate) #1

Hi,
I found the 3 commands rattr, wattr and cmd all used in the Centralite Zigbee device type examples. I think I have figured out that the rattr command sends an explicit zigbee frame and I can process and use that command. I can not figure out the other 2.

Is there documentation on these commands and any other that are available for working with zigbee devices? Specifically Remote AT Commands with the API frame 17? Sending data to Smartthings with the HA protocol seems to work, but getting Smartthings to send to HA is proving more difficult than it seems it should be.


(Andrew Urman) #2

@natec007 I never thought anyone would find that.

rattr - Read Attribute
watts - Write Attribute
st cmd - Command

They are part of the ZigBee ZCL protocol. You can find more information on a cluster by cluster list of available commands/read/write here:

http://www.zigbee.org/Products/ZigBeeClusterLibraryDownload.aspx


(Nate) #3

Hi Andrew,
Thanks for the info, I was definitely digging around for that. I know its been a while since I asked about the different Zigbee commands, and I noticed they are now listed in the device documentation but I am still having problems with “st cmd”

I can receive the “rattr” command no problem and have been using that in place of “st cmd” The zigbee device I put together which is an irrigation controller joins and fingerprints fine, and I can see every packet that comes through, but when I change the rattr command to st cmd following the example exactly (except correcting the endpoint/cluster) I don’t get anything. Is there something I am missing? Does “st cmd” require binding to work?
Thanks


(Andrew Urman) #4

oohhh I love ZigBee questions. No one ever asks enough of them.

Can you post your device code?

At the base of it, whatever you are trying to do, must be able to accept commands on that cluster.


(Nate) #5

When the on/off commands are issued, I am using the rattr command to send 00 or 01, but on my side instead of responding to read attribute , I am using it as a command because I can’t get “st cmd” to work. During the join process, I get the address requests, active endpoint requests and simple descriptor requests and respond to them, the device joins and is identified correctly. But when I try and use the “st cmd” I don’t have any packets show up.

     capability "Switch"		
            		
                    attribute "switch", "string"
            	attribute "switch2", "string"
            	attribute "switch8", "string"
            	attribute "switch5", "string"
            	attribute "switch3", "string"
            	attribute "switch4", "string"
            	attribute "switch6", "string"
            	attribute "switch7", "string"
            	attribute "status", "string"
            		
                    command "on"
                    command "off"
            	command "z2on"
            	command "z2off"
            	command "z3on"
            	command "z3off"
            	command "z4on"
            	command "z4off"
            	command "z5on"
            	command "z5off"
            	command "z6on"
            	command "z6off"
            	command "z7on"
            	command "z7off"
            	command "z8on"
            	command "z8off"
            
            	fingerprint endpointId: "5", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "4", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "A", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "6", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "D", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "8", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "9", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	fingerprint endpointId: "C", profileId: "0104", deviceId: "2222", deviceVersion: "00", inClusters: "0006"
            	}
            
            	// simulator metadata
            	simulator {
            		// status messages
           		// reply messages    		
            	}
            
            	// UI tile definitions
            	tiles {
                	standardTile("status", "device.status") {			
                        state "off", label: '1', icon: "st.valves.water.closed"
                        state "on", label: '1', icon: "st.valves.water.open"
                        state "z2off", label: '2', icon: "st.valves.water.closed"
                        state "z2on", label: '2', icon: "st.valves.water.open"
                        state "z3off", label: '3', icon: "st.valves.water.closed"
                        state "z3on", label: '3', icon: "st.valves.water.open"
                        state "z4off", label: '4', icon: "st.valves.water.closed"
                        state "z4on", label: '4', icon: "st.valves.water.open"
                        state "z5off", label: '5', icon: "st.valves.water.closed"
                        state "z5on", label: '5', icon: "st.valves.water.open"
                        state "z6off", label: '6', icon: "st.valves.water.closed"
                        state "z6on", label: '6', icon: "st.valves.water.open"
                        state "z7off", label: '7', icon: "st.valves.water.closed"
                        state "z7on", label: '7', icon: "st.valves.water.open"
                        state "z8off", label: '8', icon: "st.valves.water.closed"
                        state "z8on", label: '8', icon: "st.valves.water.open"
                    }
           		
          	standardTile("switch", "device.switch") {			
            	state "off", label: '1', action: "switch.on", icon: "st.valves.water.closed"
                state "on", label: '1', action: "switch.off", icon: "st.valves.water.open"            		}
             standardTile("switch2", "device.switch2") {            
                 state "z2off", label: '2', action: "z2on", icon: "st.valves.water.closed"
                 state "z2on", label: '2', action: "z2off", icon: "st.valves.water.open"            		}        
             standardTile("switch3", "device.switch3", inactiveLabel: false) {			
           	state "z3off", label: '3', action: "z3on", icon: "st.valves.water.closed"
                state "z3on", label: '3', action: "z3off", icon: "st.valves.water.open"
            		}
             standardTile("switch4", "device.switch4", inactiveLabel: false) {            
                state "z4off", label: '4', action: "z4on", icon: "st.valves.water.closed"
                state "z4on", label: '4', action: "z4off", icon: "st.valves.water.open"            		}
              standardTile("switch5", "device.switch5", inactiveLabel: false) {            
                state "z5off", label: '5', action: "z5on", icon: "st.valves.water.closed"
                state "z5on", label: '5', action: "z5off", icon: "st.valves.water.open"            		}
         standardTile("switch6", "device.switch6", inactiveLabel: false) {            
                 state "z6off", label: '6', action: "z6on", icon: "st.valves.water.closed"
                 state "z6on", label: '6', action: "z6off", icon: "st.valves.water.open"            		}
          standardTile("switch7", "device.switch7", inactiveLabel: false) {            
                 state "z7off", label: '7', action: "z7on", icon: "st.valves.water.closed"
                 state "z7on", label: '7', action: "z7off", icon: "st.valves.water.open"            		}
         standardTile("switch8", "device.switch8", inactiveLabel: false) {            
                state "z8off", label: '8', action: "z8on", icon: "st.valves.water.closed"
                state "z8on", label: '8', action: "z8off", icon: "st.valves.water.open"            		}
            		
          	main (["status","switch","switch2","switch3","switch4","switch5","switch6","switch7","switch8"])
          	details(["status","switch","switch2","switch3","switch4","switch5","switch6","switch7","switch8"])
            	}
            }
            
     // Parse incoming device messages to generate events
     def parse(String description) {
     log.debug "Parse description $description"
     def msg = zigbee.parse(description)
     log.trace "catchall: $msg"
                
                
     log.debug zigbee.parse(description)?.sourceEndpoint
     log.debug zigbee.parse(description)?.text
                    
    def EP = zigbee.parse(description)?.sourceEndpoint    
    def name = (EP == 4) ? "switch" : (EP == 12) ? "switch2" : (EP == 6) ? "switch3" : (EP == 8) ?  "switch4" : (EP == 9) ? "switch5" : (EP == 10) ? "switch6" : (EP == 5) ? "switch7" : (EP == 13) ? "switch8" : null    
              
    def set = zigbee.parse(description)?.text
    
                    	
    def value =  ((EP == 4) && (set in ["01"])) ? "on" : ((EP == 4) && (set in ["00"])) ? "off" :  ((EP == 12) && (set in ["01"])) ? "z2on" : ((EP == 12) && (set in ["00"])) ? "z2off" :  ((EP == 6) && (set in ["01"])) ? "z3on" : ((EP == 6) && (set in ["00"])) ? "z3off" : ((EP == 8) && (set in ["01"])) ? "z4on" : ((EP ==8) && (set in ["00"])) ? "z4off" : ((EP == 9) && (set in ["01"])) ? "z5on" : ((EP == 9) && (set in ["00"])) ? "z5off":  ((EP == 10) && (set in ["01"])) ? "z6on" : ((EP == 10) && (set in ["00"])) ? "z6off"  : ((EP == 5) && (set in ["01"])) ? "z7on" : ((EP == 5) && (set in ["00"])) ? "z7off"  : ((EP == 13) && (set in ["01"])) ? "z8on" : ((EP == 13) && (set in ["00"])) ? "z8off"  : null
 log.debug(value)
 def result = createEvent(name: name, value: value, isStateChange: true, display: true)
                    	
 log.debug "Parse returned ${result}"
 return result

                    
    }
                
 def status(value){
 sendEvent(name: "status", value: value)	
 }
                
// Commands to device
def on() {
            sendEvent(name: "status", value: "on")
                "st rattr 0x${device.deviceNetworkId} 4 6 0x01"
                //"st cmd 0x${device.deviceNetworkId} 4 6 0x00 {}"
                //"st cmd 0x${device.deviceNetworkId} 4 6 0 {}"
              }
                

            def off() {
            	//'zcl on-off off'
                sendEvent(name: "status", value: "off")
                "st rattr 0x${device.deviceNetworkId} 4 6 0x00"
                //"st wattr 0x${device.deviceNetworkId} 1 0xB04 0x12"
                
            
            }
            
            def z2on() {
            	sendEvent(name: "status", value: "z2on")
            	"st rattr 0x${device.deviceNetworkId} 12 6 0x01"    
            }
            def z2off() {	
                sendEvent(name: "status", value: "z2off")
                "st rattr 0x${device.deviceNetworkId} 12 6 0x00"    
            }

(Andrew Urman) #7

Read Attributes (st rattr) only ask a device for its state, it can’t send any commands or tell a device to toggle its switch. When you use the Command

“st cmd 0x${device.deviceNetworkId} 12 6 1”

That doesn’t send anything? You may need a hub firmware update. Can you emails support and ask for the zigbee firmware update?


(Nate) #8

I’ll try the zigbee update,

Yeah, I tried every combination I could think of with “st cmd” nothing comes through but rattr comes through fine, so to continue testing, I rewrote the device side to parse the rattr into a command. Basically when the device gets a request for an attribute, it uses it as a command depending on what attribute is being requested. Not the right way to do it, but all that would work. Strange since every other command seems to come through fine.

Thanks


(Nate) #9

@urman

Thanks!! It works now!

Woohoo… made my day


(Andrew Urman) #10

@natec007 the update fixed it? Score.


(Nate) #11

Yup, Jeanette(?) got it updated right away. Thanks!