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.

1 Like

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.

Download the Hubitat app