Generic Zigbee Devices (pushbuttons and motion detectors) that work well with Hubitat Elevation

Hi folks,

I've invested a lot of time searching for cheap Zigbee devices below the $20AUD mark that profess to be Zigbee compatible. Most of them say you need to buy a special hub to allow the device to work and do not provide a model number we can use to see if there is a proper driver available. Often you need to get the device and do a lot of playing around to find the right driver, if one is available at all!

Anyway, I have done a lot of the legwork and found some that definitely work on the Hubitat Elevation, albeit with some additional modified drivers (which I will add to this post). I haven't had time to adjust the drivers to auto-detect the devices, but you can manually choose the driver for the device yourself. I am not in any way affiliated with these sellers - this post is purely to help you avoid wasting money on sensors that do not work or time on sensors that do not have a driver.

So here it is, and I hope this helps. All of the devices below I have proven to work well:

Motion Sensors

TS0202 – on stand, CR2450 & TS0202 – small round, CR2450

Use “TS0202 RH3040 Tuya ZigBee Motion Sensor.groovy” by Mikhail Diatchenko

RH3040 – flat top on stand, CR2450

Use “TS0202 RH3040 Tuya ZigBee Motion Sensor.groovy” by Mikhail Diatchenko

RH3040 (3xAAA rechargeable batteries)

Use “TS0202 RH3040 Tuya ZigBee Motion Sensor.groovy” by Mikhail Diatchenko.

Note that all these devices seem to suffer from mechanical connectivity problems with the batteries so you have to juggle the batteries around a bit to get them to stay in. Given AAAs are much longer lasting and easy to get rechargeable ones (and better for the planet not creating extra toxic waste) I am going to persevere with these and add a little solder to make the batteries connect better.

Aqara PIR – on stand (CR2450) – Model = lumi.sensor_motion.aq2

Driver: “Zigbee – Xiaomi Aqara Motion Sensor.groovy” by Markus Liljergren


TS0044 Black or white 4 gang pushbuttons.

Use the inbuilt 'Tuya Zigbee Scene Switch' driver.

TS0043 Pushbuttons, 3 gang Pushbuttons.

Use the inbuilt ‘Tuya Zigbee Scene Switch’ driver.

6 gang Pushbutton Aqara OPPLE. Model=lumi.remote.b686opcn01

Use the “Zigbee - Xiaomi Aqara Opple Button Switch Remote.groovy” driver by Markus Liljergren
I have to say this 6 button switch, while more expensive, has been my favourite because it has six different options for activating flows and has a magnetic clip so you can make it portable if you wish. It is not designed to easily replace the button battery but there are some tutorials around to help you do this via removing the button panels.


TS0202 RH3040 Tuya ZigBee Motion Sensor.groovy

All credit to Mikhail Diatchenko's good efforts to get this working.

 *  Konke ZigBee Motion Sensor
 *  Device Driver for Hubitat Elevation hub
 *  Version 1.0.2
 *  Based on code from Robert Morris and ssalahi.
 *  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:
 *  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.


import hubitat.zigbee.clusters.iaszone.ZoneStatus
import com.hubitat.zigbee.DataType

metadata {
	definition (name: "TS0202 RH3040 Tuya ZigBee Motion Sensor", namespace: "muxa", author: "Mikhail Diatchenko") {
		capability "MotionSensor"
		capability "Battery"
//        capability "PushableButton"
		capability "Configuration"
        capability "Refresh"
        capability "Sensor"
		capability "Motion Sensor"

        command "active"
        command "inactive"        
        fingerprint endpointId: "01", profileId: "0104", inClusters: "0000,0001,0003,0500", outClusters: "0000,0001,0003,0500", manufacturer: "_TYZB01_dl7cejts", model: "TS0202", application:"21"      
        fingerprint endpointId: "01", profileId: "0104", inClusters: "0001,0500,0003,0000", outClusters: "1000,0006,0019,000A", manufacturer: "_TZ3000_mmtwjmaq", model: "TS0202", application:"43"      

	preferences {
		input "motionreset", "number", title: "After motion is detected, wait ___ second(s) until resetting to inactive state. Default = 16 seconds (Hardware resets at 15 seconds)", description: "", range: "1..7200", defaultValue: 16
        input "batteryReportingHours", "number", title: "Report battery every ___ hours. Default = 12h (Minimum 2 h)", description: "", range: "2..12", defaultValue: 12
		input name: "infoLogging", type: "bool", title: "Enable info message logging", description: ""
		input name: "debugLogging", type: "bool", title: "Enable debug message logging", description: ""

// Parse incoming device messages to generate events
def parse(String description) {

    Map map = [:]
    // logDebug("Parsing: $description")
	if (description?.startsWith('zone status')) {	
         logDebug("Zone status: $description")    
        def zs = zigbee.parseZoneStatus(description)
        map = parseIasMessage(zs)
    else if (description?.startsWith("catchall") || description?.startsWith("read attr"))
        Map descMap = zigbee.parseDescriptionAsMap(description)        
        if (descMap.clusterInt == zigbee.POWER_CONFIGURATION_CLUSTER && descMap.attrInt == 0x0020) {
            map = parseBattery(descMap.value)
        } else if (descMap.command == "07") {
            // Process "Configure Reporting" response            
            if ([0] == "00") {
                switch (descMap.clusterInt) {
                    case zigbee.POWER_CONFIGURATION_CLUSTER:
                        logInfo("Battery reporting configured");                        
                        log.warn("Unknown reporting configured: ${descMap}");
            } else {
                log.warn "Reporting configuration failed: ${descMap}"
        } else if (descMap.clusterInt == 0x0500 && descMap.attrInt == 0x0002) {
            logDebug("Zone status repoted: $descMap")
            def zs = new ZoneStatus(Integer.parseInt(descMap.value, 16))
            map = parseIasMessage(zs)        
        } else if (descMap.clusterInt == 0x0500 && descMap.attrInt == 0x0011) {
            logInfo("IAS Zone ID: ${descMap.value}")
        } else if (descMap.profileId == "0000") {
            // ignore routing table messages
        } else {
            log.warn ("Description map not parsed: $descMap")            
    //------IAS Zone Enroll request------//
	else if (description?.startsWith('enroll request')) {
		logInfo "Sending IAS enroll response..."
		return zigbee.enrollResponse()
      else {
        log.warn "Description not parsed: $description"
    if (map != [:]) {
		return createEvent(map)
	} else
		return [:]

// helpers -------------------

def parseIasMessage(ZoneStatus zs) {
        if ((zs.alarm1 || zs.alarm2) && zs.battery == 0 && zs.trouble == 0) {
            // Motion detected
	        return handleMotion(true)
        else if (zs.tamper == 1 && zs.battery == 1 && zs.trouble == 1 && == 1) {
            logDebug "Device button pressed"
            map = [
		        name: 'pushed',
		        value: 1,
                isStateChange: true,
                descriptionText: "Device button pushed"
        else {
//            log.warn "Zone status message not parsed"
//            if (debugLogging) {
//                logDebug "zs.alarm1 = $zs.alarm1"
//                logDebug "zs.alarm2 = $zs.alarm2"
//                logDebug "zs.tamper = $zs.tamper"
//                logDebug "zs.battery = $zs.battery"
//                logDebug "zs.supervisionReports = $zs.supervisionReports"
//                logDebug "zs.restoreReports = $zs.restoreReports"
//                logDebug "zs.trouble = $zs.trouble"
//                logDebug " = $"
//                logDebug "zs.test = $zs.test"
//                logDebug "zs.batteryDefect = $zs.batteryDefect"
//            }

private handleMotion(motionActive) {    
    if (motionActive) {
        def timeout = motionreset ?: 16
        // The sensor only sends a motion detected message so reset to motion inactive is performed in code
        runIn(timeout, resetToMotionInactive)        
        if (device.currentState('motion')?.value != "active") {
            state.motionStarted = now()
	return getMotionResult(motionActive)

def getMotionResult(motionActive) {
	def descriptionText = "Detected motion"
    if (!motionActive) {
		descriptionText = "Motion reset to inactive after ${getSecondsInactive()}s"
	return [
			name			: 'motion',
			value			: motionActive ? 'active' : 'inactive',
			descriptionText : descriptionText

def resetToMotionInactive() {
	if (device.currentState('motion')?.value == "active") {
		def descText = "Motion reset to inactive after ${getSecondsInactive()}s"
			// isStateChange: true,
			descriptionText: descText

def getSecondsInactive() {
    if (state.motionStarted) {
        return Math.round((now() - state.motionStarted)/1000)
    } else {
        return motionreset ?: 16

def active() {
    sendEvent(name: "motion", value: "active")
    runIn(12, off)

def inactive() {
    sendEvent(name: "motion", value: "inactive")

// Convert 2-byte hex string to voltage
// 0x0020 BatteryVoltage -  The BatteryVoltage attribute is 8 bits in length and specifies the current actual (measured) battery voltage, in units of 100mV.
private parseBattery(valueHex) {
	//logDebug("Battery parse string = ${valueHex}")
	def rawVolts = Integer.parseInt(valueHex, 16) / 10 // hexStrToSignedInt(valueHex)/10
	def minVolts = voltsmin ? voltsmin : 2.5
	def maxVolts = voltsmax ? voltsmax : 3.0
	def pct = (rawVolts - minVolts) / (maxVolts - minVolts)
	def roundedPct = Math.min(100, Math.round(pct * 100))
	def descText = "Battery level is ${roundedPct}% (${rawVolts} Volts)"
    // sendEvent(name: "batteryLevelLastReceived", value: new Date())    
	def result = [
		name: 'battery',
		value: roundedPct,
		unit: "%",
		//isStateChange: true,
		descriptionText: descText
	return result

// lifecycle methods -------------

// installed() runs just after a sensor is paired
def installed() {
//	sendEvent(name: "numberOfButtons", value: 1, descriptionText: "Device installed")
    return refresh()

// configure() runs after installed() when a sensor is paired or reconnected
def configure() {
    return configureReporting()

def refresh() {

    return zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) // battery voltage

// updated() runs every time user saves preferences
def updated() {
	logInfo("Updating preference settings")
    return configureReporting()

// helpers -------------

private def configureReporting() {
    def seconds = Math.round((batteryReportingHours ?: 12)*3600)
    logInfo("Battery reporting frequency: ${seconds/3600}h")    
    return zigbee.configureReporting(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020, DataType.UINT8, seconds, seconds, 0x01)
        + zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x20)

private def logDebug(message) {
	if (debugLogging) log.debug "${device.displayName}: ${message}"

private def logInfo(message) {
	if (infoLogging) "${device.displayName}: ${message}"

The awesome Markus Liljergren ( wrote the other drivers mentioned.
As per this post:
[Release] Xiaomi / Aqara / Opple Drivers with Presence!


Also if you are considering buying the RH3040 model, have a read of the limitations in the reviews before you buy. Once it detects movement, there is a 2-3 minute cooldown period during which it won't send another activation. Fine if you are just switching on a garage light, not so great if you are switching on lights as you walk down a corridor and then need to walk back again!

See the reviews here:

I have luck with this Smart ZigBee Scene Switch 4 Gang Remote as well:

(use 23A battery)

Yeah this one I bought too. I don't have a LR 23A 12V battery to test it yet though as it's kind of an unusual and expensive battery but it looks pretty sleek to have on the wall. It would be great if you can post which driver you used to make it work in Hubitat?

I use the standard 'Tuya Zigbee Scene Switch' driver for the remote. Yup, the battery is unusual.

Just wanted to provide an update.

I ordered this 4 gang switch and it DOES NOT work with the Tuya Zigbee scene switch driver. The model I received is id'd in the pairing as TS004F.

It works with this custom driver. The old TS0044 switches seems to be not produced anymore.

Change the driver and pair it again close to the hub.

1 Like

Wow thanks for the quick response. It really wasn't an issue as I also use zigbee2mqtt so I was just informing others.

To your knowledge are these switches tuya zigbee or are they aqara zigbee (which has issues with certain repeaters)

1 Like

They are Tuya Zigbee, inheriting all Tuya oddities .. :slight_smile: But no problems with Zigbee repeaters.

1 Like

I am still new to Hubitat and trying to link this to the hub:

You mentioned we should use "Tuya Zigbee Scene Switch" driver! but I couldn't find it!

Do you mind more details? I would appreciate that.

Thanks alot!

Its a custom driver written by @kkossev that you install

Click on "Drivers Code" link on your hubitat, then in upper right corner click "New Driver". Open the link below in a new browser tab, select all and then switch back to your hubitat tab and paste the code in the driver code editor window. Then click "Save"

You can also click the "import" button and paste the url below.

Now pair your scene switch and it should automatically pick the new driver you just installed.

Here's the link to the driver code

Thanks alot, very simple instructions! my buttons will arrive in few days but I am wondering does this code support the TS0044 also? the ones I shared are not TS004F.
Thank you.

TS0044 works out if the box using HE inbuilt driver.

Sorry for the dumb question, what do you mean with inbuilt driver? do you mean I should use this?
New device > add by brand > Tuya switch > 4gang


No, you must select 'Tuya ZigBee Scene Switch' for TS0044.

Once the device is paired to the Hub, if the driver that was automatically selected is not the right one, go to device page and manually change the driver to the one above, select it from the list.

1 Like

The device type can be seen in the 'data' section of the device page. It could be either TS0044 (use the inbuilt Tuya zigbee scene switch driver) or it could be TS004F (use the custom driver). Usually, you don't know what you will receive from the seller, until you pair it to the Hub.

1 Like

Thank you! one last question if you don't mind, how you set up the tiles to the right button (1 click, long, double)?

Sorry, I am not sure whether I understand the question.. To use the scene switch to control some lights or something else, you can try the Button Controller inbuilt app.


Download the Hubitat app