[Release] Xiaomi / Aqara device drivers

community_driver

#256

Just a wild guess, but battery voltage (decreasing over time) may change the behavior of the reed switch.


#257

I’ve similar behavior on my front door sensor, an Iris contact sensor and have had to tweak the location of the magnet in relation to the reed to limit the false triggering.
If a driver could sense the first state change and then stop reporting for 100ms, that might fix things.


#258

@veeceeoh any chance of a driver for the aqara vibration sensor please?

sharing the logged data here if that helps in anyway with your decision.

here is the debug messages from the device. the 1st and 3rd messages are on triggering vibration. the 2nd and 4th seem to be auto generated about 4 mins after each vibration:

2018-11-05 18:12:28.436:debug Vibration Sensor: Parsing description: read attr - raw: 75E70101010E05052300001100, dni: 75E7, endpoint: 01, cluster: 0101, size: 0E, attrId: 0505, encoding: 23, value: 00110000

2018-11-05 18:08:28.210:debug Vibration Sensor: Parsing description: read attr - raw: 75E70101010A5500210100, dni: 75E7, endpoint: 01, cluster: 0101, size: 0A, attrId: 0055, encoding: 21, value: 0001

2018-11-05 18:07:14.641:debug Vibration Sensor: Parsing description: read attr - raw: 75E70101010E05052300001800, dni: 75E7, endpoint: 01, cluster: 0101, size: 0E, attrId: 0505, encoding: 23, value: 00180000

2018-11-05 18:03:13.786:debug Vibration Sensor: Parsing description: read attr - raw: 75E70101010A5500210100, dni: 75E7, endpoint: 01, cluster: 0101, size: 0A, attrId: 0055, encoding: 21, value: 0001

here is the data from the device:

  • endpointId: 01
  • application:
  • model: lumi.vibration.aq1
  • manufacturer:

thank you.


#259

Thanks for the request and the debug log output.

Actually, I own two of the new Aqara Vibration Sensors and have been working on a SmartThings device handler for over a month now, and will be porting it to Hubitat quite soon. :smile:

These sensors are somewhat more complex that any other Xiaomi devices, and it's taken reverse-engineering by different people to pull together all the information necessary to create device drivers on different HA platforms. For a really "fun" and technical read on this new Xiaomi device, check out this GitHub comment thread:

Because Hubitat doesn't have a mobile app UI with tile "buttons" that can be assigned functions, I am looking at possibly making a companion App for the Xiaomi Vibration sensors, for the functions of setting open/close angle positions, and tracking of what I'm calling "activity report" values. For the time being, though, I will probably just make use of function call buttons in the device driver page for users to set open/close positions (if they choose to use that functionality of the sensor.)

EDIT: I have released a beta device driver, a few posts down, here.


#260

I was so thrilled that my leak sensors were connected for approx 14 days then they all dropped off at the same time. I re-paired them but it only lasted one day the next time around.


#261

There are some posts here on the subject if you do more searching, but the first post in this thread is probably the best resource: Xiaomi devices - are they pairing / staying connected for you?

In short, you'll want to have repeaters because they are sensitive to "falling off" the network, but you also want to make sure your repeaters are known to play well with Xiaomi devices (they are not standard and many repeaters don't handle them reliably--the Hubitat hub didn't either until an early firmware update). Unfortunately, there are few. An Xbee is quite reliable but requires some assembly; most/all of the others are select smart bulbs (despite these reports, I'd still be careful since many are known to behave poorly on ZHA networks) and a discontinued Sylvania plug whose newer, incompatible revision is likely the only one you'll find.


#262

Thanks! I took a quick look and the one repeater I have is not compatible lol. It's a peanut plug.

Edit: oh man, even the Iris plug I just got from Lowe's clearance is not compatible.


#263

Sylvania Smart + (not type A) is compatible. Ikea Trådfi light bulbs are said to be compatible, so perhaps their outlet shipping soon will be too. I asked some of the europeans on the ST forum that have already received the plugs, if they have Xiaomi devices and could map their network to see if their working for that, but I've had no response.


#264

I'm trying to digest the xbee info in other threads, it looks interesting except for the wait on the parts.


#265

Yep. Still waiting myself. Months now. If you're in the US you have a better chance getting parts than me though. Also if you go for a Zigbee 2 version instead of the Zigbee 3 version I'm waiting on, then it will be faster.

The Zigbee 2 versions will work just fine and do what you need. I'm just buying a future is all my wait is about.


#266

I'm excited to give it a try. I ordered an xbee s2 and a waveshare usb adapter from ebay so we'll see if this helps my xiaomi sensors.


#267

what is the status of the xiaomi 2018 aqara vibration sensor on hubitat? I have an application for 6 of them, but I don't want to buy them until I'm sure they're supported. Thx


#268

[BETA] v0.5b of NEW Aqara Vibration Sensor Device Driver

The beta device driver code can be found here.

This sensor has quite a variety of features, which can be used in a number of ways / applications. Here is a chart to show how its functions are mapped to Hubitat events that can then be used with Apps for various automations:

Sensor Function Hubitat event Notes
Vibration/Shock Detected motion = active motion inactive is timer-based
Tilt Detected acceleration = active acceleration inactive is timer-based
Tilt Angle tiltAngle = value Custom attribute (see notes below)
Drop Detected button 1 = pushed
XYZ accelerometer values contact = open/closed see notes below
Activity Report values Custom attribute see notes below
Change sensitivity level n/a not yet working

Notes:

  • Sensor Status: Purely for use in a Hubitat Dashboard, the custom attribute sensorStatus can be used for displaying the following states: Stationary, Vibration, Tilt, and Drop. The Open / Close states are not displayed because they can occur simultaneously during a vibration detected (motion = active) state.

  • Vibration/Shock detection: The sensor does not seem to work well for clothes washer / dryer cycle detection, and also no message is sent when the sensor is stationary. If "heavy" enough vibration continues, the sensor only sends subsequent vibration/shock detected messages every 60 seconds, so the device driver will is set up to reset motion to inactive after 65 seconds as a default, with a user-adjustable reset time in the preference section of the device details page (see screenshot below).

  • Tilt detection: The sensor sends a tilt detected message when it has been rotated in any direction, and both a Tilt Angle value message and XYZ accelerometer values message are sent when the sensor stops moving and has come to a resting position. Because Tilt detected is assigned to the acceleration capability, it also resets to acceleration inactive using a timer - in this case, 2 seconds, not user-adjustable. The reason for 2-seconds is purely to give a visual indicator in a Hubitat Dashboard if the custom attribute sensorStatus is used. However, since acceleration is state-based, it needs to be reset to inactive when no more tilts are detected after some length of time.

  • Tilt Angle: This value is sent after the sensor has been rotated and come to a resting position. It is a relative value, so in other words, the difference in angle from the sensor's previous resting position. There doesn't seem to be any built-in Hubitat capability that is well suited to assign to this data, so it is assigned to the custom attribute tiltAngle for events that can be used in WebCoRE, by a custom App, or displayed in a Hubitat Dashboard. It is not useful for determining an absolute open or closed position, however, which is why the XYZ Accelerometer value message data is used for that purpose.

  • Drop detection: The sensor sends this message whenever a free-fall drop is detected. It seemed best assigned to a trigger action, so button 1 pushed is used.

  • XYZ Accelerometer values: These values are sent after the sensor has been rotated and come to a resting position. Unlike the Tilt Angle report, they are absolute values, and in the device driver are converted to a 3-axis angle position. Although this calculated position is not extremely accurate, it is consistent enough to use for setting and storing absolute open and close positions. This is accomplished by putting the sensor in each position and then pressing the "Set Open" or "Set Closed" buttons in the device view page while logged into the Hubitat Hub (see screenshot below). The conversion to 3-axis positions includes a "margin of error" to allow for positions that don't exactly match the stored user-set position. I may make this margin value available for users to change in the device preferences.

  • Change Sensitivity Level: The sensor has 3 hardware sensitivity levels: low, medium, and high. Changing the level requires pushing the "Change Sensitivity Level" button in the device view page (see screenshot below). However, because no "level changed successfully" message from the sensor is passed on by the Hubitat hub (or in SmartThings, for that matter) and the current level cannot be queried by the Hubitat driver, I have not yet been able to confirm that the level change command works correctly. So I can't currently guarantee it will work on the Hubitat platform. I plan on opening a new forum thread to ask about the best method for sending the ZigBee write attribute command in this case. EDIT: This has been changed in the v0.7b beta driver, but is still not yet working.

An example screenshot from the device details page of my Aqara Vibration Sensor using the beta device driver:


#269

Keith, wow that was fast getting out the beta DH for the Aqara vibration sensor and it's working great. This very tiny device has quite a few neat capabilities, and the reasonable prices for all these xiaomi sensors really helps in putting a system together.

Thank You


#270

I have been playing with the QBKG03LM double button no neutral wall light switch. When the left button is pushed this turns on the relay in the device direct, you get the following in the log:

dev:6422018-11-17 10:01:11.738:debugparse description2: read attr - raw: 1C86040006100000100000001001, dni: 1C86, endpoint: 04, cluster: 0006, size: 10, attrId: 0000, encoding: 10, value: 0000001001

dev:6422018-11-17 10:01:11.453:debugparse description2: read attr - raw: 1C86020006160000100100F02300861C03, dni: 1C86, endpoint: 02, cluster: 0006, size: 16, attrId: 0000, encoding: 10, value: 0100F02300861C03

When you press again it turns the relay off and you get:

dev:6422018-11-17 10:03:17.461:debugparse description2: read attr - raw: 1C86040006100000100000001001, dni: 1C86, endpoint: 04, cluster: 0006, size: 10, attrId: 0000, encoding: 10, value: 0000001001

dev:6422018-11-17 10:03:17.133:debugparse description2: read attr - raw: 1C86020006160000100000F02300861C03, dni: 1C86, endpoint: 02, cluster: 0006, size: 16, attrId: 0000, encoding: 10, value: 0000F02300861C03

So I can see from the above that the endpoint for the button is 4 and the endpoint for the relay is 2, when you press the right button you get the same but the endpoint for the button is 5 and the endpoint for the second relay is 3. On the relay turning on and off value changes.

I have modifies a driver to use with this wallswitch and it is below

/**
 *
 *  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.
 *
 *  Modified from DTH and simic by a4refillpad and modded again by picturepete
 
 *  08/2018 first release
 */

metadata {
    definition (name: "Aqara 2 Button Wired Test", namespace: "picturepete", author: "picturepete") {
        capability "PushableButton"
        capability "Switch"
              
        command "on"
		command "off"
		command "on2"
        command "off2"
		
        attribute "numberofbuttons", "3"
        attribute "switch2","ENUM", ["on","off"]
        attribute "lastCheckin", "string"
	    attribute "buttonPressed", "String"
    } 

}

// Parse incoming device messages to generate events
def parse(String description) {
   log.debug "Parsing '${description}'"
   def value = zigbee.parse(description)?.text
   def endpoint = description.split(",").find {it.split(":")[0].trim() == "endpoint"}?.split(":")[1].trim()
   def cluster	= description.split(",").find {it.split(":")[0].trim() == "cluster"}?.split(":")[1].trim()
   def attrId = description.split(",").find {it.split(":")[0].trim() == "attrId"}?.split(":")[1].trim()
   def valueHex = description.split(",").find {it.split(":")[0].trim() == "value"}?.split(":")[1].trim()
   log.debug "Parse: $value"
   Map map = [:]
   
	if (cluster == "0006") {
		// Parse button press: endpoint 04 = left, 05 = right, 06 = both
		map = parseButtonPress(Integer.parseInt(endpoint))
	}
	else if (description?.startsWith('read attr -')) {
		map = parseReportAttributeMessage(description)
	}
    else if (description?.startsWith('on/off: ')){
    	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 parseButtonPress(value) {
	def pushType = ["", "Null", "Relay1", "Relay2", "Right", "Left", "Both"]
	def descText = "${pushType[value]} button${(value == 6) ? "s" : ""} pressed (Button $value pushed)"
	displayInfoLog(descText)
	displayDebugLog("Setting buttonPressed to current date/time for webCoRE")
	sendEvent(name: "buttonPressed", value: now(), descriptionText: "Updated buttonPressed (webCoRE)")
		return [
		name: 'pushed',
		value: value,
		isStateChange: true,
		descriptionText: descText
		
		]
	
}

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

  private def displayInfoLog(message) {
	if (infoLogging || state.prefsSetCount != 1)
		log.info "${device.displayName}: ${message}"
}

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

def on() {
   log.debug "on()"
	sendEvent(name: "switch", value: "on")
	"st cmd 0x${device.deviceNetworkId} 2 6 1 {}"
}

def off2() {
    log.debug "off2()"
	sendEvent(name: "switch2", value: "off")
	"st cmd 0x${device.deviceNetworkId} 3 6 0 {}"
}

def on2() {
   log.debug "on2()"
	sendEvent(name: "switch2", value: "on")
	"st cmd 0x${device.deviceNetworkId} 3 6 1 {}"
}

This works and in the device control you can turn the relays on and off and you can see the buttons being reported, however if you press the button it activates the relay but it isn't reported to the driver, I am unsure how to do this, if anyone can help that would be great. I also do not know how to make a child device so when you want to create a rule etc you cannot see the second relay, but you can create a virtual switch using virtual device sync, this creates two switches but you can delete the first switch which you can control from the main DH.

It also is reporting on both buttons being pressed and also on another cluster number 1 and I am unsure what it is reporting here.

Any ideas or pointers on how I can get the DH to report the relays on a button press would be greatly appreciated.

The logs for switching by pressing the button on are below:

2018-11-19 08:49:27.959 pm debugParse returned [name:pushed, value:4, isStateChange:true, descriptionText:Right button pressed (Button 4 pushed)]

dev:6422018-11-19 08:49:27.957 pm infoDouble No Neutral Switch: Right button pressed (Button 4 pushed)

dev:6422018-11-19 08:49:27.956 pm debugParse: null

dev:6422018-11-19 08:49:27.955 pm debugParsing 'read attr - raw: 1C86040006100000100000001001, dni: 1C86, endpoint: 04, cluster: 0006, size: 10, attrId: 0000, encoding: 10, value: 0000001001'

dev:6422018-11-19 08:49:27.592 pm debugParse returned [name:pushed, value:2, isStateChange:true, descriptionText:Relay1 button pressed (Button 2 pushed)]

dev:6422018-11-19 08:49:27.588 pm infoDouble No Neutral Switch: Relay1 button pressed (Button 2 pushed)

dev:6422018-11-19 08:49:27.584 pm debugParse: null

dev:6422018-11-19 08:49:27.583 pm debugParsing 'read attr - raw: 1C86020006160000100100F023B9861C03, dni: 1C86, endpoint: 02, cluster: 0006, size: 16, attrId: 0000, encoding: 10, value: 0100F023B9861C03'

And this is the log for switching off by pressing the button:

2018-11-19 08:50:37.916 pm debugParse returned [name:pushed, value:4, isStateChange:true, descriptionText:Right button pressed (Button 4 pushed)]

dev:6422018-11-19 08:50:37.914 pm infoDouble No Neutral Switch: Right button pressed (Button 4 pushed)

dev:6422018-11-19 08:50:37.910 pm debugParse: null

dev:6422018-11-19 08:50:37.909 pm debugParsing 'read attr - raw: 1C86040006100000100000001001, dni: 1C86, endpoint: 04, cluster: 0006, size: 10, attrId: 0000, encoding: 10, value: 0000001001'

dev:6422018-11-19 08:50:37.692 pm debugParse returned [name:pushed, value:2, isStateChange:true, descriptionText:Relay1 button pressed (Button 2 pushed)]

dev:6422018-11-19 08:50:37.689 pm infoDouble No Neutral Switch: Relay1 button pressed (Button 2 pushed)

dev:6422018-11-19 08:50:37.686 pm debugParse: null

dev:6422018-11-19 08:50:37.684 pm debugParsing 'read attr - raw: 1C86020006160000100000F023B9861C03, dni: 1C86, endpoint: 02, cluster: 0006, size: 16, attrId: 0000, encoding: 10, value: 0000F023B9861C03'


#271

Peter, I have a working driver for the neutral variant of your switch (QBKG11LM/QBKG12LM), it supports the button, switch, and energy monitoring capailities.

It may or may not work for you, but you can give them a try: Hubitat/Drivers at master · guyeeba/Hubitat · GitHub

It needs a generic child switch driver as well, because I try to avoid cutom commands as much as possible, but the code can be easily modified to suit your needs...


#272

Hi, thrown it at the switch and it creates the child devices and the second child device works, detecting the button press and the relay state, these are on endpoint 2 for the relay and 4 for the button, Cannot get first child to work, the endpoints for the second button is 5 and the relay 3 all of them are on cluster 6. Not too sure how you define the separate child devices and endpoints. The logs show:
(starting at the bottom and working up, left button pressed, and right button pressed.

2018-11-26 08:28:54.330 pm debugDouble No Neutral Switch: []

dev:6422018-11-26 08:28:54.328 pm warnOn/off cluster attribute 0 for non-switch endpoint 5

dev:6422018-11-26 08:28:54.324 pm debugDouble No Neutral Switch: read attr - raw: 1C86050006100000100000001001, dni: 1C86, endpoint: 05, cluster: 0006, size: 10, attrId: 0000, encoding: 10, value: 0000001001

dev:6422018-11-26 08:28:53.831 pm debugDouble No Neutral Switch: []

dev:6422018-11-26 08:28:53.828 pm warnOn/off cluster attribute 0 for non-switch endpoint 3

dev:6422018-11-26 08:28:53.825 pm debugDouble No Neutral Switch: read attr - raw: 1C86030006160000100000F0233F861C03, dni: 1C86, endpoint: 03, cluster: 0006, size: 16, attrId: 0000, encoding: 10, value: 0000F0233F861C03

dev:6422018-11-26 08:28:44.543 pm debugDouble No Neutral Switch: []

dev:6422018-11-26 08:28:44.542 pm warnOn/off cluster attribute 0 for non-switch endpoint 4

dev:6422018-11-26 08:28:44.539 pm debugDouble No Neutral Switch: read attr - raw: 1C86040006100000100000001001, dni: 1C86, endpoint: 04, cluster: 0006, size: 10, attrId: 0000, encoding: 10, value: 0000001001

dev:6422018-11-26 08:28:43.972 pm debugDouble No Neutral Switch: []

dev:6422018-11-26 08:28:43.960 pm debugDouble No Neutral Switch: read attr - raw: 1C86020006160000100100F023CF861C03, dni: 1C86, endpoint: 02, cluster: 0006, size: 16, attrId: 0000, encoding: 10, value: 0100F023CF861C03

Any pointers?

Cheers Pete


#273

maaaan, I hate these Aqara devices, they all work differently... but: I double-checked my drivers, and...
and I have something that seemingly does what you want, but it's just an early work-in-progress.

The strange part is having a DTH like this means that I have a double-button-no-neutral-switch, but I can't find it anywhere (only a single button variant).... whatever, I uploaded a new file to github (Aqara QBKG03LM-QBKG04LM BETA.groovy), please try it, and if it works, I'll revisit these no-neutral switches and hack an acceptable driver for them.


#274

They are very annoying, the no neutral version seems to use cluster 6 for the relay and the button, endpoints being 2 and 3 for the relays and 4 and 5 for the buttons, my driver works fine with these but as said earlier doesn't register the relays state if you manually press the buttons. These are really good switches as they can directly replace switches here in the UK and look good. There definitely seems to be an opening for someone to make a good looking wall light switch, all the ones I see available are either silly money or just weird looking. These cost £22.00 in the UK and the wireless equivalent £12.00. BTW you pair the switch by holding the left button until the light/relay switch off.


#275

The DH works perfectly with all 16 of my double Aqara Light switches (neutral version). Child devices are created after selecting 2 buttons in the options and pressing Save on the parent device.

I will move my single button Aqara neutral switches off of SmartThings tonight and test.

Thank you so much @guyeeba and @peter for your efforts.