HUI ZigBee Wall Switch 3 Gang V.3.3

I'm using this driver for the 3 gang switch but when I physically press switch 1 on/off it also turns on/off switch 2 and 3. Any tips, @mike?

/**
*

  • 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.
  • Based on on original by Lazcad / RaveTam
  • Mods for Hui 3 Gang Switch by Netsheriff
    */

metadata {
definition (name: "HUI ZigBee Wall Switch 3 Gang V.3.3", namespace: "George Castanza", author: "George Castanza") {
capability "Actuator"
capability "Configuration"
capability "Refresh"
capability "Switch"
capability "Health Check"

    fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006"
    fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "0003, 0006, 0019, 0406", manufacturer: "Leviton", model: "ZSS-10", deviceJoinName: "Leviton Switch"
    fingerprint profileId: "0104", inClusters: "0000, 0003, 0006", outClusters: "000A", manufacturer: "HAI", model: "65A21-1", deviceJoinName: "Leviton Wireless Load Control Module-30amp"
    fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15A", deviceJoinName: "Leviton Lumina RF Plug-In Appliance Module"
    fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15S", deviceJoinName: "Leviton Lumina RF Switch"


    
    attribute "lastCheckin", "string"
    attribute "switch", "string"
    attribute "switch1", "string"
	attribute "switch2", "string"
    attribute "switch3", "string"
    command "on0"
	command "off0"
	command "on1"
	command "off1"
	command "on2"
	command "off2"
	command "on3"
	command "off3"  
    command "on"
    command "off"
    
    
    attribute "switch1","ENUM",["on","off"]
    attribute "switch2","ENUM",["on","off"]
    attribute "switch3","ENUM",["on","off"]    
    attribute "switchstate","ENUM",["on","off"] 

}

}

// Parse incoming device messages to generate events

def parse(String description) {
log.debug "Parsing '${description}'"

def value = zigbee.parse(description)?.text
log.debug "Parse: $value"
Map map = [:]

if (description?.startsWith('catchall:')) {
map = parseCatchAllMessage(description)
}
else if (description?.startsWith('read attr - ')) {
map = parseReportAttributeMessage(description)
}
else if (description?.startsWith('on/off:')){
log.debug "onoff"

def refreshCmds = zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: 0x01]) +
zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: 0x02]) +
zigbee.readAttribute(0x0006, 0x0000, [destEndpoint: 0x03])

return refreshCmds.collect { new hubitat.device.HubAction(it) }
//def resultMap = zigbee.getKnownDescription(description)
//log.debug "${resultMap}"

    //map = parseCustomMessage(description) 
}

log.debug "Parse returned $map"
//  send event for heartbeat    
def now = new Date()

sendEvent(name: "lastCheckin", value: now)

def results = map ? createEvent(map) : null
return results;

}

private Map parseCatchAllMessage(String description) {
Map resultMap = [:]
def cluster = zigbee.parse(description)
log.debug cluster

if (cluster.clusterId == 0x0006 && cluster.command == 0x01){
	if (cluster.sourceEndpoint == 0x01)
    {
    log.debug "Its Switch one"
	def onoff = cluster.data[-1]
    if (onoff == 1)
    	resultMap = createEvent(name: "switch", value: "on")
    else if (onoff == 0)
        resultMap = createEvent(name: "switch", value: "off")
        }
        else if (cluster.sourceEndpoint == 0x02)
        {
        log.debug "Its Switch two"
	def onoff = cluster.data[-1]
    if (onoff == 1)
    	resultMap = createEvent(name: "switch2", value: "on")
    else if (onoff == 0)
        resultMap = createEvent(name: "switch2", value: "off")
        }
 else if (cluster.sourceEndpoint == 0x03)
        {
        log.debug "Its Switch three"
	def onoff = cluster.data[-1]
    if (onoff == 1)
    	resultMap = createEvent(name: "switch3", value: "on")
    else if (onoff == 0)
        resultMap = createEvent(name: "switch3", value: "off")
        }					

//
}

return resultMap

}
//
private Map parseReportAttributeMessage(String description) {
Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
//log.debug "Desc Map: $descMap"

Map resultMap = [:]

if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="00" && descMap.endpoint == "01") {
	resultMap = createEvent(name: "switch1", value: "off")
} 
    
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "01") {
	resultMap = createEvent(name: "switch1", value: "on")
}
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="00" && descMap.endpoint == "02") {
	resultMap = createEvent(name: "switch2", value: "off")
} 
    
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "02") {
	resultMap = createEvent(name: "switch2", value: "on")
}
if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="00" && descMap.endpoint == "03") {
	resultMap = createEvent(name: "switch3", value: "off")
} 
    
else if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "03") {
	resultMap = createEvent(name: "switch3", value: "on")
}


return resultMap

}

def off1() {
log.debug "off()"
sendEvent(name: "switch1", value: "off")
"he cmd 0x${device.deviceNetworkId} 0x01 0x0006 0x0 {}"
}

def on1() {
log.debug "on()"
sendEvent(name: "switch1", value: "on")
"he cmd 0x${device.deviceNetworkId} 0x01 0x0006 0x1 {}"
}
def off2() {
log.debug "off2()"
sendEvent(name: "switch2", value: "off")
"he cmd 0x${device.deviceNetworkId} 0x02 0x0006 0x0 {}"
}

def on2() {
log.debug "on2()"
sendEvent(name: "switch2", value: "on")
"he cmd 0x${device.deviceNetworkId} 0x02 0x0006 0x1 {}"
}

def off3() {
log.debug "off3()"
sendEvent(name: "switch3", value: "off")
"he cmd 0x${device.deviceNetworkId} 0x03 0x0006 0x0 {}"
}

def on3() {
log.debug "on3()"
sendEvent(name: "switch3", value: "on")
"he cmd 0x${device.deviceNetworkId} 0x03 0x0006 0x1 {}"
}

def off0() {
log.debug "off0()"
sendEvent(name: "switch", value: "off")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x0 {}"

}

def on0() {
log.debug "on0()"
sendEvent(name: "switch", value: "on")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x1 {}"

}

def off() {
log.debug "off()"
sendEvent(name: "switch", value: "off")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x0 {}"

}

def on() {
log.debug "on()"
sendEvent(name: "switch", value: "on")
"he cmd 0x${device.deviceNetworkId} 0xFF 0x0006 0x1 {}"

}

def refresh() {
log.debug "refreshing"
[
"he rattr 0x${device.deviceNetworkId} 0x01 0x0006 0x0", "delay 1000",
"he rattr 0x${device.deviceNetworkId} 0x02 0x0006 0x0", "delay 1000",
"he rattr 0x${device.deviceNetworkId} 0x03 0x0006 0x0", "delay 1000",

]

}

private Integer convertHexToInt(hex) {
Integer.parseInt(hex,16)
}

private Map parseCustomMessage(String description) {
def result
if (description?.startsWith('on/off: ')) {
if (description == 'on/off: 0')
result = createEvent(name: "switch", value: "off")
else if (description == 'on/off: 1')
result = createEvent(name: "switch", value: "on")
}

return result

}

I dont know how it could have anything to do with the driver, I don't see any bindings or reporting configuration, does this driver spit out anything when you activate it physically?
If it does, then add return as the first line in your parse(description) method, this will basically ignore everything the device sends, if the problem stops, it's the driver, if not, it's the device.
This doesn't mean the device is broken, just perhaps it has the factory default settings and this is the way they set it up.

Ah yes, I haven't done anything programmatic with the switches yet so i'm thinking its a wiring issue...

Sorry, I'm not sure what's going on.

However, it's working fine at my house. I can turn it all on/off via a switch in the device page. I can switch any of the three lights on/off via the physical switch and the device page, and call them individually from RM.

I not sure if you can distinguish physical and programmatic.

If you are switching a switch on at the wall, and all 3 lights are turning on, then it's something wrong with the wiring.

Did you resolve this issue. I just installed a 2 gang switch and can only switch both on or off via hubitat device, not individually. I can physically turn each off or on.
Edit
Edited the endpoints to 0B and 0C in the various places in the script for the 3 gang driver.
Working now!

1 Like

Yes, it appears that 3asmarthome have a new batch of devices. This new batch has a different set of endpoints.

Norm, I'm stumped on the same endpoint piece, i tried the endpoint changes you did but clearly not exactly as didn't work can you tell me what you did?
Mike

There are 3 places to change each of the endpoints, that's what stumped me at first.
In the device details it will show what the endpoint actually is. Near the bottom under Data.
It seems it will be either 10, 01 or 0B as with my switch.

Thanks Norm, worked it out, added two endpoints was the trick.
Cheers
Mike

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.