[RELEASE] Xiaomi Drivers with Health Status and Zigbee2MQTT

Yeah I think I've already used every other driver available on the internet. I spent hours yesterday reading through multiple forums and trying each piece of code but this sensor is putting up a fight.
Here are the driver codes I've tried.
https://www.dropbox.com/sh/268neu5007du7pj/AADn3nH0cqp9BHGC0bAeoK_sa?dl=0

As far as Ive found I'm having the EXACT same issue as AlanB from the forum below. If you want to know what outcomes came from other drivers I got the same results as him.

Here's a question for you, @ShaunTheBaa... which Hubitat hub are you using?

I have the Xiaomi Mija Smart Light Sensor and I've been using the Oh La Labs driver since I first installed it a few years ago, works w/out issue.

Maybe my model is different?
image

Hubitat Elevation C7.
Just tried updating it too.

Currently running version: 2.3.5.102

New version available: 2.3.5.110

Then re-paired but no difference.

Huh, well there goes that theory.

On my C7 I get this:

And on my C8 I get this:

Same driver.

After the configuration "received by device" message is received, nothing else is heard from the device. On the other hub it works perfectly.

Long shot - what channel is your Zigbee radio on, @ShaunTheBaa?

Just tried again, manually installed all driver code on both hubs. Reset device, join C8, no messages received after the "got the config, thanks!" message. Reset device, join C7, "got the config, thanks!", works perfectly. :confused:

There is even one more driver that you can try but seems like the problem is somewhere else, all of the other drivers should work too. Remember, after switching drivers you need to pair the sensor again to HE every time because most of these Xiaomi/Mija/Aqara sensors need specific initialization which works effectively only during the pairing procedure time window.

Are you pairing the sensor close to the hub (at a maximum distance of 1-2 meters) ?

I remember reading somewhere that it's best to use it on 23 or 27?
Heading to work now so there will be some radio silence

There is a new C-8 beta version 2.3.5.112 - can you try it?

There is a beta release w/some fixes that are supposed to help w/Zigbee pairings. I was able to pair to Hue outdoor motion sensors that weren't pairing before. They have stayed connected/reporting for 2-3 hours. So things may be improving.

Okay, that's our first commonality. My working hub is on 25, the non-working hub is on 20. It doesn't feel like the right answer to me, though. Not easy for you to test either.

I've heard all sorts of recommendations, usually 11, 15, 20 or 25 are the ones recommended as they're supposedly in the diminished sidebands of the main Wi-Fi channels 1, 6 and 11. There's a decent write-up on Metageek. Nobody seems to recommend 26, which is the highest channel, as (again, supposedly) some devices don't support it.

Yeah, I don't think this is a driver thing either. Let's see if I can do a quick test.

1 Like

I have 2 such sensors ( * manufacturer: LUMI, * model: lumi.sen_ill.mgl01, * application: 15) connected to my C-8 directly (channel 20), for more than one week now. They stay connected and do not show any sign of problems... go figure!

Pulled out the clean test C7, installed HPM, installed driver, paired light sensor on channel 14. Works. Changed radio to channel 20. Re-paired. Still works.

I've got nothing here to help either of us, I'm afraid. This is essentially the same setup as yours, but it's working. I'll keep the test device on my C8 and try re-pairing with the next update, as I'm definitely seeing that same "no messages" thing there that you are, which points to a platform software issue of some kind.

1 Like

Okay so thanks for all of the replies guys. I fixed it, but I don't know how. Lets go on a journey.
I was originally noting down step by step everything I was trying in case it helped, taking on board the information above. This info is exact too as I was using text to speech saying everything as it happened.

  1. Removed the device using my pc. Hold device button until blue light came on and Re-Paired device within 30cm of hub using hubitat android app on phone. Blue light on device started blinking every 2 seconds.
  2. It paired, device light stays solid for 3 ish seconds then went out.
  3. Hubitat android says found "Xiaomi Mijia Smart Light Sensor GZCGQ01LM".
  4. Device page on pc Shows States: rawLux : 0, presenceUpdated : 1678958971116, illuminance : 0, presence : present.
  5. Clicked configure. States: configuration : complete. Nothing else changed.
  6. Removed the device again using pc and setup my pc to view live zigbee logging while redoing steps 1-3 the same way.
  7. The blue light on the device stayed on for longer this time. Like 8 seconds. I'm the same distance I was and paired it using the same android.
  8. This was the Zigbee Log on my pc. Might help someone.
Lux2023-03-16 19:39:39.371 profileId:0x104, clusterId:0x400, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-67
Lux2023-03-16 19:39:36.351 profileId:0x104, clusterId:0x400, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-67
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:24.276 profileId:0x104, clusterId:0x400, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-58
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:23.268 profileId:0x104, clusterId:0x400, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-69
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:20.551 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-61
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:20.349 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-67
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:18.538 profileId:0x104, clusterId:0x1, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-65
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:18.335 profileId:0x104, clusterId:0x1, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-64
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:17.328 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-66
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:17.025 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-71
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:16.923 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-66
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:16.822 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-68
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:16.720 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-71
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:16.618 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-70
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:16.516 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-69
Xiaomi Mijia Smart Light Sensor GZCGQ01LM2023-03-16 19:39:16.414 profileId:0x0, clusterId:0x8021, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-74
Xiaomi Mijia Smart Light Sensor2023-03-16 19:39:16.111 profileId:0x104, clusterId:0x0, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-71
883D2023-03-16 19:39:16.009 profileId:0x104, clusterId:0x0, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-68
883D2023-03-16 19:39:15.907 profileId:0x104, clusterId:0x0, sourceEndpoint:1, destinationEndpoint:1 , groupId:0, lastHopLqi:255, lastHopRssi:-71
883D2023-03-16 19:39:15.705 profileId:0x0, clusterId:0x8004, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-70
883D2023-03-16 19:39:15.402 profileId:0x0, clusterId:0x8005, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-71
883D2023-03-16 19:39:14.892 profileId:0x0, clusterId:0x13, sourceEndpoint:0, destinationEndpoint:0 , groupId:0, lastHopLqi:255, lastHopRssi:-70
  1. I open the device on my pc and look!

Current States

  • illuminance : 38
  • presence : present

State Variables

  • rawLux : 15911
  • illuminanceDirection : brightening
  • presenceUpdated : 1678959579287

I did nothing else different during the 2 seperate parings other then having the zigbee log open on my computer, and that makes no sense to me either. I didn't even need to click configure.
I would remove the device to provide a zigbee log when it doesn't work but i've been trying to get it to report for almost a week. So I can't help anyone with how it started working.
Thanks to everyone for the help and thanks to @birdslikewires for the device code. :blue_heart:

Edit: Maybe my smartthings hub had something to do with it? The 2 are within 1m of each other. Looking in the ST API my hub is running on channel 14 though.
I'm gonna buy another one, they are on special. Maybe we could get some answers then.

Edit2: something else I noticed is in the device list, everything else has a source of system but the lux sensor has a source of user. Normal?

All very strange, I guess I'll just try the same thing for my C8! :slight_smile:

That's normal, it's just saying that device is using a community driver, rather than one built-in to the system. If you use Hub Mesh to connected devices between hubs you'll get ones that say "Linked" too.

1 Like

Hello all,

I just got one of the Aqara Temperature and Humidity Sensor WSDCGQ11LM's. Paired right up using birdlikeswires' driver on my C7. Thanks for the driver !

All well and good, but the pressures are not particularly intuitive to me in KPa. I added a few lines of code to calculate the pressure in inches of mercury, and can see those in the event logs.

I can't seem to figure out how to add it to the "states" list though. Is that possible, and any hints where to look if so ?

Thanks,

Todd
Dallas, TX, USA.

And now it has shown up in the states list.

Looks like I copied the right lines.

1 Like

Embarrassed - so sharing! I've a Xiaomi Aqara humidity sensor. Worked great for a long time, then I had issues with it and never learned why. Moving the devices' location seems to have helped.
When I moved it - I set it on its side. On the bottom are little 'slats' which I assumed were for air flow.
Since I wasn't mounting it with tape, I laid it on its side at the top of the shower. This worked for a long while and things settled. Last night, my bathroom light went on and woke me. it happened repeatedly all night - I closed the bathroom door and said 'f*k it'.
This AM I determined it was firing due to Smarter Humidity Fan - and the value of humidity was 70% and barely fluctuating.
I'd only changed the battery 2 weeks ago, so that wasn't it. Then I considered - what if it has gotten moisture inside? I turned it and set it with the slats on the bottom, and scotch taped it to the wall. I never once reset, or played with battery - and within 30 mins humidity dropped 20% and is still dropping says Grafana. So, I learned to not turn humidity sensor on their side - seems they can get water in them!

3 Likes

So, after ordering another sensor which was lost in transit, then being offered a replacement, then having 3 new sensors arrive 1 month later, I now have a few spares lol.

The battery was flat out of the box but I replaced it and proceeded to go through the exact same headache pairing it that I had with the first one. I tried close, far, holding the button for different amounts of time, my 10 month old even tried throwing it on the ground like everything else.

Each time it would pair but showed 0 lux values. Eventually I narrowed it down.
My smartthings hub. It was auto adding the sensor (according to the zigbee logging) but not properly pairing to it. So the sensor was trying to send it's lux data to ST with no device entry but pairing to my Hubitat hub with no data.
It also might be that I waited until the blue light on the sensor flashed 3 times THEN let go of the button when pairing it.
It also could just be sheer coincidence. It paired perfectly on the second attempt after unplugging the ST hub and all I did was hold the sensor button longer.

Hopefully this helps someone. Funnily enough, this is still not the hardest zigbee device I've had to pair. 3 words, Xiaomi Water Sensor

1 Like

@birdslikewires first I like to say many thanks for the drivers, I have tried many different that no longer are supported and I always got my Xiaomi sensors to drop of after a few weeks to months so now Im testing yours and so far so good. At first I missed some settings like replaced battery date, custom battery level but I think you have chosen the best battery percentage levels I have seen so far and I like that you can see the battery voltage also so now I don't feel like I miss anything.

The driver Im using is the Temp and Humidity sensor for WSDCGQ11LM but Im using it for my older WSDCGQ01LM without any problem. I have just made another version of it with modded fingerprint part and some other places just to match WSDCGQ01LM.

One thing I noticed was that you use 2 decimals for temp and humidity and I personally like one decimal, I think it looks better in my dashboards at least and I don't need 2 decimal accuracy :slight_smile: .
So I went in to se if I could change this to one decimal in your driver and found the code below.
What I noticed is that the setScale and rounding does not do anything since it's done before variable temperature is divided by 100 so there are no decimals and also from my understanding the sensors only report temp/humidity with 2 decimals so no need to round if showing 2 decimals.
To get one decimal working I changed it as seen below.

Your original code
		BigDecimal temperature = hexStrToSignedInt(temperatureFlippedHex)
		temperature = temperature.setScale(2, BigDecimal.ROUND_HALF_UP) / 100

On my sensors this was enough for temp and humidity with 2 decimals
		BigDecimal temperature = hexStrToSignedInt(temperatureFlippedHex) / 100

My change to get one decimal working
		BigDecimal temperature = hexStrToSignedInt(temperatureFlippedHex) / 100
		temperature = temperature.setScale(1, BigDecimal.ROUND_HALF_UP) 
1 Like

So for anyone interested I added the option to choose how many decimals you want to have from 0 to 2. Since I only have temp and humidity I didn't do it for pressure but should work the same I presume :upside_down_face:.

Changes I did were these, Im not a developer so it probably can be done in a better way but works for me.

  1. Add two inputs under preferences
  2. Set the two preferences to default values when running configure so they are not null
  3. Use preferences values when rounding and trimming the decimals and added null check just to be safe
    (Update after feedback from BirdLikeWires: added a check to only set default values if they are not already set)
preferences {
	
	input name: "infoLogging", type: "bool", title: "Enable logging", defaultValue: true
	input name: "debugLogging", type: "bool", title: "Enable debug logging", defaultValue: false
	input name: "traceLogging", type: "bool", title: "Enable trace logging", defaultValue: false
	input name: "tempDecimals", type: "enum", title: "Temperature decimals", defaultValue: 2, required: true, options: [[0:"0"],[1:"1"],[2:"2 (Default)"]]
	input name: "humidityDecimals", type: "enum", title: "Humidity decimals", defaultValue: 2, required: true, options: [[0:"0"],[1:"1"],[2:"2 (Default)"]]
	
}

void configureSpecifics() {
	// Called by main configure() method in BirdsLikeWires.xiaomi

	updateDataValue("encoding", "Xiaomi")
	device.name = "Xiaomi Aqara Temperature and Humidity Sensor WSDCGQ01LM"
	sendEvent(name: "numberOfButtons", value: 1, isStateChange: false)
	if (tempDecimals == null) device.updateSetting("tempDecimals", [value: "2", type: "enum"])
	if (humidityDecimals == null) device.updateSetting("humidityDecimals", [value: "2", type: "enum"])
    
}

		BigDecimal temperature = hexStrToSignedInt(temperatureFlippedHex) / 100
    	temperature = temperature.setScale((tempDecimals != null ? tempDecimals : 2).toInteger(), BigDecimal.ROUND_HALF_UP)

		BigDecimal humidity = hexStrToSignedInt(humidityFlippedHex) /100
		humidity = humidity.setScale((humidityDecimals != null ? humidityDecimals : 2).toInteger(), BigDecimal.ROUND_HALF_UP)




This is how it looks in preferences.

Example of zero to two decimals i Dashboard

3 Likes