MOES Zigbee Dimmer Switch

Thank you so much will give it a try

I got all 3 to switch on and off :grinning: thank you so much

metadata {
definition (name: "MOES ZigBee V.1.5", namespace: "CPS Smart Home", author: "Christos Psaroudis") {

    command "on1"
    command "off1"
    command "on2"
    command "off2"
    command "on3"
    command "off3"
    capability "Configuration"

fingerprint profileId: "0104", deviceId: "808F", inClusters: "0000,0004,0005,EF00", outClusters: "0019,000A", manufacturer: "_TZE200_9i9dt8is", model: "TS0601", deviceJoinName: "WorksWith Dimmer"
}

tiles(scale: 2) {
    multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true) {
        tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
            attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#79b821", nextState:"turningOff"
            attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
            attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#79b821", nextState:"turningOff"
            attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
       
        }
    }
    standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
    }
    
    main "switch"
    details(["switch", "refresh"])
}

}

// Parse incoming device messages to generate events
def parse(String description) {
Map map = [:]
//def event = zigbee.getEvent(description)

if (description?.startsWith('catchall:')) {
    log.debug description
    // call parseCatchAllMessage to parse the catchall message received
    map = parseCatchAllMessage(description)
    if (map != [:]) {
        log.debug "ok send event: $map.name $map.value"
        sendEvent(name: map.name, value: map.value)
    }
}
else {
    log.warn "DID NOT PARSE MESSAGE for description : $description"
}

}

def off3() {
log.debug "called off1"
zigbee.command(0xEF00, 0x0, "00010101000100")
}

def off2() {
log.debug "called off2"
zigbee.command(0xEF00, 0x0, "00010201000100") //TODO
}

def off1() {
log.debug "called off3"
zigbee.command(0xEF00, 0x0, "00010301000100") //TODO

}

def on3() {
log.debug "called on1"
zigbee.command(0xEF00, 0x0, "00010101000101")
}

def on2() {
log.debug "called on2"
zigbee.command(0xEF00, 0x0, "00010201000101") //TODO
}

def on1() {
log.debug "called on3"
zigbee.command(0xEF00, 0x0, "00010301000101") //TODO
}

def refresh() {
log.debug "called refresh"
zigbee.command(0xEF00, 0x0, "00020100")
//pauseExecution(1000)
//zigbee.command(0xEF00, 0x0, "0002020200")
}

def configure() {
log.debug "Configuring Reporting and Bindings."
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
}

private Map parseCatchAllMessage(String description) {
// Create a map from the raw zigbee message to make parsing more intuitive
def msg = zigbee.parse(description)
Map result = [:]
switch(msg.clusterId) {
case 0xEF00:
def attribute = getAttribute(msg.data)
def value = getAttributeValue(msg.data)

        switch (attribute) {
            case "switch": 
                switch(value) {
                    case 0:
                        result = [
                            name: 'switch',
                            value: 'off',
                            data: [buttonNumber: 1],
                            descriptionText: "$device.displayName button was pressed",
                            isStateChange: true
                        ]
                    break;

                    case 1:
                        result = [
                            name: 'switch',
                            value: 'on',
                            data: [buttonNumber: 1],
                            descriptionText: "$device.displayName button was pressed",
                            isStateChange: true
                        ]
                    break;
                }
            
            break;
            
            case "level": 
                int levelValue = value / 10
                result = [
                    name: 'level',
                    value: levelValue + "%",
                    data: [buttonNumber: 1],
                    descriptionText: "$device.displayName level was modified",
                    isStateChange: true
                ]
            break;
        }
    
    break;
}

return result

}

private String getAttribute(ArrayList _data) {
String retValue = ""
if (_data.size() >= 5) {
if (_data[2] == 1 && _data[3] == 1 && _data[4] == 0) {
retValue = "switch"
}
else if (_data[2] == 2 && _data[3] == 2 && _data[4] == 0) {
retValue = "level"
}
}

return retValue

}

private int getAttributeValue(ArrayList _data) {
int retValue = 0

if (_data.size() >= 6) {
    int dataLength = _data[5] as Integer
    int power = 1;
    for (i in dataLength..1) {
        retValue = retValue + power * _data[i+5]
        power = power * 256
    }
}

return retValue

}

Good to hear that is works!
I am curious about the switch all on/off commands. Did those work too?

def off() {
log.debug "called off"
zigbee.command(0xEF00, 0x0, "000101010001000201000100")
}

def on() {
log.debug "called on"
zigbee.command(0xEF00, 0x0, "000101010001010201000101")
}

Regards,

Christos

I expected those work only for 2-gang in case of 3-gang it will be

def off() {
log.debug "called off all"
zigbee.command(0xEF00, 0x0, "0001010100010002010001000301000100")
}

def on() {
log.debug "called on all"
zigbee.command(0xEF00, 0x0, "0001010100010102010001010301000101")
}

I have a similar Tuya one (not MOES brand though), touch glass with 3 buttons.
The built-in Tuya Zigbee Scene Switch driver works right out of the box.

@mcdull you lucky it has not worked for us but @martinkura has done some grate stuff getting a finished driver.

Hi I created Github account for this driver. For now driver is in development. I tweaking it step by step. But there is no documentation about HE drivers and Im not programmator only IT enthusiast.

5 Likes

well done you have done well

New driver is released. Switch works like expected. Please try if some issue is there :roll_eyes:
Now I will try add functions like presence ....

1 Like

In case of 1-gang switch is there better solution to create child device or not? Any advantage of this solution or none? I want update this code in driver but not sure what solution is better.

For 1-gang switch there is no real benefit to create a child device. This is needed in the case of multi-gang switches to enable automation rules for each of the buttons of the switch (e.g. to create a 2-way switch by pairing one of the buttons of a 3-gang switch to another button of a different switch)

Great progress !! Is it possible to convert this handler to SmartThings Handler. I have 2 gang switch.

  • application: 52
  • endpointId: 01
  • manufacturer: _TZE200_5apf3k9b
  • model: TS0601
  • onOff: catchall
  • zigbeeNodeType: ROUTER

Raw Description :
01 0104 0051 00 05 0000 000A 0004 0005 EF00 01 0019

Would this work for the four gang version?

Thanks so much everyone. I discovered a post from 2 years ago relating to a different switch an his custom driver worked perfectly with my switch.

I can't post a link, but if you search "Zemismart ZigBee Wall Switch Multi-Gang". That's what solved it for me.

In case 4-gang switch there you need edit driver. I can help you with this but I need fingerprint of your switch.

Please i want your help to convert this drivers for Smartthings

i have create this thread
"moes 3 gang zigbee wall swithc need a handler that used for cluster ef00"
not aloud to use link search for this title on smartthings comunity i will donate for a solution

Hi @rs125cc,
I do not have a Smartthings device and therefore I cannot help you much.
I can only provide my input about the format of the commands of Tuya devices (which you can find at the first comments of this topic).
Maybe you can use that information at a Smartthings forum to help someone create the driver for you (or you can try doing it yourself if you have some programming knowledge).

Alternatively, you can buy a HE device :wink:

1 Like

thanks for your help... i think you are Greek i am Greek too
the smartthings code is very similar i think is not hard for you to convert it my knoledge is not good so propably i can't i willl try to convert your code as the martinkura code is more complex and i not have luck

is any way to send pm to you in this forum?

Yours code work as it is but not Martin Propably have some changes about childs

:+1:
@martinkura's code is for a multi-button switch, not a dimmer switch