Australian approved light switches


#43

Still no joy, code now:

/**
*

  • 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 Single Gang 1.1", namespace: "Hubitat", author: "George Castanza") {
capability "Actuator"
capability "Configuration"
capability "Refresh"
capability "Health Check"
capability "Switch"

    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"
	

command "on"
command "off"


    
    attribute "switch","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: 0x0B])

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 == 0x0B)
    {
    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")
    }
}

}
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 == "0B") {
	resultMap = createEvent(name: "switch", value: "off")
} 
    
else if (descMap.cluster == "0006" && descMap.attrId == "0000" && descMap.value =="01" && descMap.endpoint == "0B") {
	resultMap = createEvent(name: "switch", value: "on")
}

return resultMap

}

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

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

def refresh() {
log.debug "refreshing"
[
"st rattr 0x${device.deviceNetworkId} 0x0B 0x0006 0x0", "delay 1000",

]

}

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

}


#44

Looks like I had put the 1 gang driver on the 2 gang device so now have the 1 gang working.

Now to get the 2 gang working...


#45

The 2-gang works using the 3 gang driver and a change of endpoints :slight_smile:


#46

I just picked one of these up. I am not in Australia but they are selling them state side now. They are the cheapest zigbee wall switch with safety certification.

I had to modify the code with the same endpoints as @bf1.

I am not familiar with GitHub but was trying to create a modified version for others running into the same 0B endpoint issue.


#47

I have installed a "HUI ZigBee Wall Switch 3 Gang V.3.3" and thanks to the information in this post have it working as a device. Within the device I can switch on and off the three lights - seperately or as a group.

I am quite new to Hubitat.

What I cannot figure out how to do is create 3 virtual devices, one for each of the gangs (Lights) in the 3 gang switch. Can someone describe how to do this? Thanks.


#48

Download the app 'virtual device sync'. Make sure you save it as an app, then install it as an app.

Then open the app and select the zigbee light switch. The app will then create the three virtual switches for you. You'll need to name the app and the switches as well.


#49

OK tried what you said (And thanks for the quick response) but I have an error that makes no sense to me.

I have attached 5 images

  1. The Apps code screen
  2. The app itself (from Apps())
  3. The Virtual Sync (from the Apps page)
  4. The screen just prior top the error message being show as in 5 below
  5. The error message which occurs

Any suggestions?


#50

OK I found the problem, I had to install a driver for the switch. Found this at [RELEASE] Virtual Device Sync

All now works, Thanks.


#51

We're going to pick up a couple Australian frequency devices for internal development and testing.
Mostly interested in line powered zwave, but will entertain anything really.
Any suggestions?
Also a source for them that would ship to US


#52

Mike, are you specifically looking for devices that don't work with current drivers, or even those that do? I use Aeotec, Fibaro, Qubino and Dome devices (AU freq Z-Wave) in my Australian home, and they seem to work fine with existing drivers.


#53

That's a good list of does work, maybe something that doesnt


#54

There are some 3asmarthome lights that are zigbee. I've got a few of them, and have mashed up a driver for them. I'm sure it's 95% bodgy. They did change the endpoints a few months ago, which caused issues for the newbies. They are relatively cheap by Australian prices, and are getting a fair few questions on the Aussie smart-tech forums I follow.

https://www.ebay.com.au/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=zigbee+light+switch&_sacat=0

https://3asmarthome.com/


#55

The went up in price!

I got mine off of Amazon and they were selling for cheap. I am using the code above and modified the endpoints as instructed in this thread. It would be nice to have an official driver.


#56

Did anyone customise @mike's code for the 2 gang switches?


#57

@mike, if you could customise for two gang, I'll buy you one :pray:


#58

Try in there. I've added in the double gang which I worked on a few weeks ago. It works for me. You may need to adjust the endpoints like you did for the triple (not sure). Also, I renamed the github repo as it now has all of them (3).

I thought you were looking for the dimmer yesterday, so didnt upload it then.