[DEPRECATED] Xiaomi Mijia Smart Light Sensor (moved to ST's Edge driver)

EDIT (06/09/2022):

While the DTH will still work until ST completely kills off Groovy DTH’s, I’ve switched both of my sensors over to ST’s Edge driver called “zigbee-illuminance-sensor”. They work perfectly, and fast. The only thing that’s not there is the battery reporting, but I can deal with that (and hope that the driver eventually updates to use that capability).

I thought I’d share my DTH for this device since nothing exists yet from SmartThings. I bought this for $13.69 (that includes shipping from China) and got this working in ST for both the Classic and the new app. It’s a nice and tiny little device that reports on every change in LUX. It also mounts using magnets or double sided tape.


There’s still a little work to do with regards to commenting/documenting certain parts of the code, but the code will work. The new app is also a challenge with having it show up right (motion sensor shows up for me as a capability), but that’s not a DTH issue. We just have to wait for ST to recognize ocfDeviceType: “oic.r.sensor.illuminance” (got that from ST’s own documentation BTW).

The correct fingerprint is included in the DTH, so it will join correctly, but just in case it joins as a “Thing” (I joined it using the Classic app), go to the IDE and change the DTH to be the one you created from this code.


Anyway, hopefully this will help anyone else who bought one of these. Also, feel free to tweak, fix, update this code as you see fit.

Tagging @veeceeoh and @MinerJason


I ordered a few to try and play with this.

1 Like

Are these accurate? 13,000 lux seems like a lot for my 100w bulb to be putting out…

That’s the value being returned by the sensor, and I didn’t change or convert it, but if that needs to change it would be a simple thing to do.

See my updates in a post further down with updates from May 6, 2020.

Great, thanks for you work, I am going to order some light sensor to try.

1 Like

Mine has been working great, and I ordered 2 more a couple weeks ago.

How is the battery life on this? I see it uses a CR2450.

I’ve had it for just over a month, and it reports lux changes immediately. So far it still says 100%. I’m keeping an eye on that pretty close to get a feel for battery life. So far so good.

1 Like

I just got my Xiaomi light sensor and work very well with the DH, can receive lux and battery level.
But the value of lux is rather on high side (over 20,000 for internal lighting, normally should be a few hundred to few thousand). Also, the sensor is very sensitive, the lux keep changing and reporting to hub even there is no observable light change. Is there any way to reduce the reporting frequency, I don’t want the battery drain away too fast.

This is the raw data value the device sends to the ST hub when the value changes, but I believe I may have found something from another ST DTH that I need to use (a conversion process). I just found that tonight, so give me a day to look that over and test. There is also a way to configure the device to not reports as often, so I’ll test that as well.

I’ll post an update here when it’s ready.

FYI @mvevitsis

Thank you so much and very appreciate your effort :+1: :+1:, waiting your good news.

1 Like

FYI @mvevitsis

Here are the updates:

  • Cleaned up code and resolved large lux values by using zigbee.lux() to convert raw value to lux.
  • Added a preference to adjust minimum illuminance reporting time, and a preference for the amount of change in raw lux data.

Please update to the latest release here:


Once you save and publish, go to the device (in either Classic or the new app) and set your preference/settings for the minimum amount of time in seconds the sensor should send data (0 is default), and then set the amount of change in the raw data to be detected (21 is default). When you save and/or exit from settings/preferences, a config will be initiated to update the sensor. This may take a few minutes for the sensor to change, and sometimes it takes a couple attempts because it’s a sleepy device (battery powered).

I’ll be testing values for each over the next day or two, so let me know how things go for you? You can see debug events in Live Logging in the IDE.

EDIT: Even though I’ve set these 2 values (60 seconds and 100 raw data change), the sensor doesn’t seem to honor them.

I updated the DH and the lux value now become normal, good.
But you’re right, for the 2 setting values, the sensor seems just ignore them no matter what value I’ve entered.

1 Like

I also saw a discussion within the Hubitat community where they saw the same behavior with this device not honoring certain settings. I’m not too worried about that to be honest, but I will keep an eye on battery usage.

The levels now seem accurate

1 Like

Anyone having problems with the sensor? I can pair it succesfully, and after pairing it does give out a few readings (the values seem plausible). After that, it does not report back and hitting refresh does nothing. Over time it is listed as “Unavailable” in the app. If I press the button on the device, it does report a new value once, and after that, no new readings and goes back to unavailable.

Initially I just thought it was a battery issue and replaced it, but same problem persists after switching the battery. Any ideas? Faulty device?

Try rejoining the device. If you use the Classic app, go to adding a new device. With the new app, I can’t quite remember how, but it technically shouldn’t matter.

Press and hold the button until the blue LED starts to quickly blink, or three blinks at a time (can’t remember, sorry). The hub will see the rejoin and you should see those events in your hub’s event log. Rejoin close to the hub, or close to the nearest zigbee repeating device where the sensor will be placed.

Sadly not working the rejoining process. I can delete the device and pair it again okay, but after the few first minutes it does not report back the values and over time goes to unavailable status. The battery is always seen at 0% for some reason, and I already replaced the battery once thinking it might be the cause.

Hmm, ok. Can you bring up Live Logging in the IDE and then press the button on the sensor? Click on the sensor name in Live Logging so that you only see events from that sensor. Can you get a screenshot of the events the sensor generates?

At around 11:46-47 I removed the device using the old ST app and then started to repair it by holding the button, which resulted in blinking the the light. At around 11:47.02 I can see it has paired. The following “Refreshing values” entries are when I have pressed the value once and shortly after that, the device responds with the “Desc Map” entry.

The last value entry I can see on the ST Recently section is the 11.48.41 value. After the 11.42:23 NullPointerException there are no new values coming in to the Recently entry.

At 11.59.48 I press the button on the device once, which results on the three “Desc Map” entries. No new values appear on the app or Recently section. I can continue to press the button which results in three “Desc Map” entries showing up like before, but no new values appear on the ST app and no new “Refreshing values” entries appear.

Any ideas?