[RELEASE] Aqara (B1) Smart Curtain Motor (ZNCLDJ11LM & ZNCLDJ12LM) Driver

NOTE: Although many users have had great success using them, Xiaomi / Aqara ZigBee devices are NOT officially supported or guaranteed to work on the Hubitat Elevation platform.

@veeceeoh has released most of the Xiaomi drivers used on the HE platform, see this thread for more information.

This is a driver for the Aqara Smart Curtain Motor (ZNCLDJ11LM) and Aqara B1 Smart Curtain Motor (ZNCLDJ12LM). They are both feature complete. This driver MAY also work with Aqara Smart Rolling Shutter Motor (ZNGZDJ11LM), but that has not been tested, if you do have one and want to test it, contact me in this thread and we can make sure it is added properly.

Supported features in both curtains:

  • Open/Close/Stop/SetPosition
  • Set curtain to Original direction (requires track discovery to be done again on ZNCLDJ11LM)
  • Set curtain to Reverse direction (requires track discovery to be done again on ZNCLDJ11LM)
  • Activate Track Discovery with a command from the driver, no need to reset the device physically.
  • Enable/Disable command in the driver for manually opening the curtain (tugging on the curtain to make it open/close)
  • The curtain is also exposed as a dimming light (on/off/set level) to be used with integrations like Alexa.
  • Refresh fetches the current position (not needed normally, but provided just in case)

For Aqara B1 Smart Curtain Motor (ZNCLDJ12LM) these additional features are active:

  • Battery percentage is read
  • Power source type (battery/dc/unknown) is read
  • A scheduled check once every 12 hours for battery level runs on top of the automatic battery level events sent by the curtain when the percentage changes.
  • Refresh also fetches the battery level and power source type (not needed normally, but provided just in case)

Install and reset like any other Aqara/Xiaomi device.

The driver can be found here.

FAQ

  1. "Your idea is stupid and slow and I don't like it" - Don't use the code
  2. "Your app/driver is crashing my Hub. I submitted a support ticket" - Don't do that, the fine folks at Hubitat Inc. do NOT maintain this code. This software is given free of charge with no support, implied or otherwise. I may still help...
  3. "The latest update broke it, FIX IT" - I do this for fun, please don't make it un-fun.
  4. "I have a great idea for a feature" - Go ahead and post it, I might get around to it...
  5. "You ignored my great idea" - See #2
  6. "I hate you for getting my hopes up, your app/driver is awful/buggy/stupid" - Ok, please write a better one so I can use it
  7. "Please fix your code, it's broken" - I write this because I enjoy coding. I will continue to support and provide updates as long as that remains the case.
  8. "I stole your code and made it soooo much better" - Thanks. Please post it so I can start using it.
  9. "You are awfully sarcastic, I don't like you" - That's ok, I don't need you to
    (thank you @thomas.c.howard for the original FAQ this one was based on)
3 Likes

Hi again

I have deleted the old driver and paired the device again with the new driver.

Initial good observations :

  1. Device is detecting the driver automatically while pairing this time
  2. I am able to set position of the curtain to open and close

I will do further testing and will post again,

1 Like

There's two battery attributes being set, please check if both are the same, if they are, I will merge them into one.

  • All driver commands are not working for me except for **"Set Position"

  • I reset the device but it does not seem to reset the fully open position while i set the position to open at 99% it will not fully open

  • I cant see the battery percentage so am not sure if both values for the battery are same or not

I will keep testing bellow are the logs

Logs

Ok, I will investigate and see what we can try next, there must be a major difference between your model and mine. With mine all is working

@altajer at the bottom of the driver page in the Data section, which model has been detected?
I see events not sent by my curtain motors.

@altajer Added a new version of the driver to test. Just to confirm, does Stop not work either?
Enable "Use only Set Position" to use SetPosition for Open and Close. With my curtain Open and Close work with other commands. Do try Open and Close with either "Curtain Direction" or "Use only Set Position" set.
The command "Clear Position" might be able to reset the fully open position to a new location. It does not work for my curtain, but I found Wireshark logs showing that this could work with yours.
Do run the refresh command as well, please. There's something I want to see from the log.

With the feedback from this we will get further... If you could sniff the Zigbee traffic using Wireshark when using the original app and issuing stop and close commands, that would be helpful, but let us try this first.

EDIT: There's also "Alt Open", "Alt Close" and "Alt Stop", please try them.

Hi Markus ,

The following are the information in the Data Section :

Data

  • endpointId: 01
  • application: 0C
  • model: lumi.curtain.hagl04
  • manufacturer: LUMI

Thanks, looking forward to hearing about how the testing of the latest driver goes.
@altajer any progress in testing this?

Hi
i was using the aqara curtains with the driver "generic zigbee switch" . After a couple of weeks it messed up my zigbee mesh and my battery devices started dropping ( excluded the curtain from the mash solved the issue)
i would like to know is there any chance that this driver will solve this problems?

(i have the wired version with no battery)

Unfortunately there is nothing the driver can do about that. With that said, there's many people, me included, that have been able to build a rock solid mesh with Xiaomi/Aqara devices. I have 60+ sensors from Xiaomi/Aqara in my mesh, plus Aqara outlets and Cubes. With this I have Xbees and CC2531/CC2530. There is a whole thread about just this topic.
I have been playing with the idea of maybe using a CC2531 with a custom firmware to actively make sure the devices stay online by actively sending packets in a way not really within the standard, but this is currently far from releasable and I'm not even sure I do half of it right yet, nor if this is going to turn out being any better than just putting the right Zigbee routers in.

EDIT: To be clear, a Zigbee mesh my size with Xiaomi/Aqara devices is NOT easy, not something I recommend anyone who doesn't have the time and patience as well as appropriate technical background. Anyone who really wants to can probably get it working with the information in this forum and elsewhere, but it is NOT easy for most. There are alternative ways, here is one.

Hey guys I just got the ZNCLDJ12LM listed above as being compatible with this code. I'm excited about automating my curtains and I'm in the midst of setting up my second smart home (first version was basic lighting and locks 8 years ago on Z-wave). I'm planning to buy a hub for many things in my house and I need a single hub that will support much more than the Xiaomi hub. So I'm on here trying to determine if the Hubitat will work. Can you guys please update your findings with this code? Does the ZNCLDJ12LM work as expected??? I'm a technical guy and can add drivers but I don't currently have the time to constantly tinker. From reading on other threads it sounds like the SmartThings hub will control the Aqara properly. But I'm kinda leaning in the Hubitat direction if the curtains will work well. Thoughts? Here's what I currently have in my home and I'm planning to add more:

-Aqara B1 curtain motors ZNCLDJ12LM
-Hue lights
-Ikea Tradfri lights
-Lutron Radio RA2 lights and hub
-Logitech Harmony hub/remote
-Abode security system

Please provide an update and any advice. Thanks!

First of all, welcome to the community!

If you are willing to test I can provide a working driver for these curtains, I don't have that model, I have the other one without a battery. That one works as it should, but the commands are different for the battery version. I believe one of the versions of commands that is in the driver now will work, but since the guy I wrote that addition for never responded, I couldn't finish this.

As for the others I've seen many threads about Hue lights, best is probably to create a new thread asking if these devices will work, the community is very friendly and you will probably get replies very quickly from people that actually have them.
Logitech harmony I've seen a community driver for, I know Lutron works, but I don't know if it is the RA2 or something else since I don't have it. Same with Abode, I've seen it mentioned, but can't say more than that.

If it's just the curtains that keep you from Hubitat, then don't worry, we'll sort it out. Exactly which driver on Smartthings is supposed to work? I can have a look at that one as well in case there is some extra functionality I've not implemented that exists in that one. The driver is mostly ready, it needs testing and then I'll clean it up once we know exactly which commands work with your curtain.

Thanks for the welcome Markus! And thanks so much for offering to help! I'm super excited about getting my curtains automated. I'm hoping it gets the wife in a good mood to automate the whole house :wink:

So I went ahead and got the Hubitat. After doing a bit of reading it sounds like most of my other devices will be compatible and I decided we'd just have to get the curtains working :wink: (as I'm not a dev I was counting on you or someone hopefully making it happen :))

With all that said I'll be happy to test and provide feedback to you! I promise I won't disappear like the last guy but I am fairly busy so I may take awhile to get things done and respond. But please hang with me and I'll see this through till it's working flawlessly if you are willing.

So I'm raring and ready to go but I haven't even taken my HE out of the box yet. My curtain motors and tracks just arrived and I need to get them installed at some point. I plan on getting the HE running this weekend and we can test the Aqara B1 curtain motors ZNCLDJ12LM without them being installed. Once I get the HE going I'll reply back here. Since I'm completely new to HE I may need some quick instructions on how to install the driver but I'm sure I can get it done. I have an engineering degree and I'm a certified wifi network admin so I can handle somewhat technical tasks if provided instruction.

Stay tuned and I'll update you when I'm ready to test!

And here's where I was reading and it sounded like they had the curtains working on SmartThings. If you read through to the end it seems like the initial code may not have supported partial opening but it sounds like they even got that working. Not sure though:

That's great, then let us get this working, first step is to test the driver as is with the steps I outlined in a post above. I'll paste them into this post later.

To test you will need the rail as well, but you can just put it on the floor to begin with, that is how I tested before I stalling mine. Without the rail there is no resistance the motor can use to determine the rail length so nothing really works.

I'm also very busy, so it can take time at times before I respond. As long as you don't disappear that's fine :slight_smile: this time I'd like to finish this.

I'll add some links to the getting started info you need once I'm in front of the computer.

EDIT: Steps to try:
Just to confirm, does Stop work?
Enable "Use only Set Position" to use SetPosition for Open and Close. With my curtain Open and Close work with other commands. Do try Open and Close with either "Curtain Direction" or "Use only Set Position" set and tell me which one works, if any.
The command "Clear Position" might be able to reset the fully open position to a new location. Please try it.
There's also "Alt Open", "Alt Close" and "Alt Stop", please try them.

For installing custom drivers, there's the official docs:
https://docs.hubitat.com/index.php?title=Drivers_Code

I have the track and it is assembled. I installed the motor on it and it appears to have set it’s stop points at both ends after the first run down the track and back. It now stops where it should at the beginning and end. It also stops when I hit the button on the motor. So the hardware seems to be functioning properly. I’ll get the HE up and running this weekend then try to add the motor and driver and report back. Do I need to add the driver before attempting to add the motor in HE?

That's great, yes, you need to install the driver first. It should then be automatically selected when you pair the curtain, if the fingerprint is correct. Looking forward to hearing how it goes.

OK Markus - I'm ready! Got my curtain tracks, motors and curtains installed. Turned the motors on and let them run back and forth to set the track end points. Both motors seem to be functioning properly. Curtains work perfectly with the physical motor button.

And got the HE installed and setup. Successfully loaded your driver linked at the very top of this thread. Then paired both curtain motors successfully. See screenshots. I went into each motor and hit Open and Close but nothing happened. Then I chose Set Point and set it to 0,

Let me know what else I need to do please:



Did you try all of this? Also try setting position to 100.
The first goal is to have working open and close commands together with stop. After that we'll work on getting Set Position to work as expected.

EDIT: @claytonelliott Update to the latest driver from the repo, there is a minor value check fix.

Test the following Commands with "Use only Set Position" UNSET:

  • Close
  • Open
  • Close
  • Alt Close
  • Alt Open
  • Alt Stop
  • SetPosition (try with value 0, 50 and 100)

Then test the following Commands with "Use only Set Position" SET:

  • Close
  • Open
  • SetPosition (try with value 0, 50 and 100)

Note: The Stop command needs to be tested when the curtain is in motion.

When we know which one of these work, it is time to test "Reverse Curtain" (should make open and close to behave in the opposite to how they did to begin with). "Clear Position" should make the curtain reset the track position and size data and do a new track discovery.

I loaded the new driver code you linked. Then completed the list with these results:

Test the following Commands with "Use only Set Position" UNSET:

  • Close : does nothing
  • Open : does nothing
  • Close : does nothing
  • Alt Close : does nothing
  • Alt Open : does nothing
  • Alt Stop : does nothing
  • SetPosition (try with value 0, 50 and 100) : numbers 1-99 work but numbers 0 & 100 do nothing, Also 1=curtain all the way closed and 99=curtain all the way open which is the opposite of what I would expect but maybe that's just me
  • Stop : works!

Then test the following Commands with "Use only Set Position" SET:

  • Close : works!
  • Open : works!, however my curtain now has an issue where when in opens all the way it doesn't quite stop when it should. It keeps going too far and "squeals" like it is doing the track discovery each and every time it opens. This only happens when opening. Closing stops as it should and doesn't squeel
  • SetPosition (try with value 0, 50 and 100) : ALL values work including 0 & 100!

So this thing is pretty much working as expected as long as "Use only Set Position" is SET. Except for these minor issues that I guess I can live with but would love to be fixed (in order of importance):

1 - when I got my curtains set up yesterday I had them do the track discovery and they successfully learned the correct stop points. But something happened when I paired them with Hubitat and started using this driver that has apparently altered the set point on only one of my two curtains. Now one of my curtains has an issue where when in opens all the way it doesn't quite stop when it should. It keeps going too far and "squeals" like it is doing the track discovery each and every time it opens. This only happens when opening. Closing stops as it should and doesn't squeel. And it's only the one curtain. I'm thinking I may just need to redo the track discovery but I can't figure out how to make it do it. When I try your "Clear Position" command it doesn't seem to do anything. Track positions still seem to be set the same. And I can't figure out how to restore the motor to factory defaults either. It came with no manual and I can't find anything online. There is no reset button on the B1 like there is on older models. I have emailed Aqara support...

2 - This is just a nice to have thing: In the videos for the curtain motors they always show and state that the motor can be started by simply tugging on the curtain. Mine has never done this and still hasn't during testing with your code. I thought it may be a setting once it is paired to the Aqara hub but I don't have one of those. Not a big deal but this would probably be handy

3 - In my mind 100 should = curtain all the way closed and 0 should = curtain all the way open (i.e. the absence of a curtain). Not sure if these positions are determined by the manufacturer or your code but I'm sure I can live with it if it can't be changed easily. In reality I probably won't be telling Alexa "set curtains to 75% closed" very often anyways (probably never). And 50% is 50% either way...