bspranger / Xiaomi

my Xiaomi Device Handlers for Smartthings
Apache License 2.0
520 stars 1.36k forks source link

Just got a new Xiaomi Aqara Button with mode id: lumi.sensor_switch.aq3 #106

Closed xtianpaiva closed 6 years ago

xtianpaiva commented 6 years ago

This is what I get, the current DH do not work properly, just let me know if you need some testing.

8:42:07: debug Thing: Parse returned [name:Model, value:lumi.sensor_switch.aq3, unit:%, isStateChange:true, descriptionText:device model, displayed:true, linkText:Thing]

8:42:07: debug Thing: Parse returned [name:battery, value:100, unit:%, isStateChange:true, descriptionText:Thing Battery at 100% (3.055 Volts), displayed:true, linkText:Thing]

8:42:07: debug Thing: [name:battery, value:100, unit:%, isStateChange:true, descriptionText:Thing Battery at 100% (3.055 Volts)]

8:42:07: debug cluster: 0000, attrId: 0005, value: 6C756D692E73656E736F725F7377697463682E61713301FF42260121EF0B0328230421A8130521620006240100030000082102010A2100009821080099210000, model:6C756D692E73656E736F725F7377697463682E617133, data:42260121EF0B0328230421A8130521620006240100030000082102010A2100009821080099210000

8:42:07: debug Thing: Parsing 'read attr - raw: B73F01000088050042166C756D692E73656E736F725F7377697463682E61713301FF42260121EF0B0328230421A8130521620006240100030000082102010A2100009821080099210000, dni: B73F, endpoint: 01, cluster: 0000, size: 88, attrId: 0005, encoding: 42, value: 6C756D692E73656E736F725F7377697463682E61713301FF42260121EF0B0328230421A8130521620006240100030000082102010A2100009821080099210000'

Thanks for the great work.

bspranger commented 6 years ago

We also need to know the rest of the finger print to add it to the DH.

Can you get the in and out clusters and other info from the hub event list. I believe the catchall has this info.

xtianpaiva commented 6 years ago

Hi @bspranger, there you go, just let me know if you need something else.

9:40:13: debug SmartShield(clusterId: 0x0000, command: 0x0a, data: [0x01, 0xff, 0x42, 0x26, 0x01, 0x21, 0xc7, 0x0b, 0x03, 0x28, 0x23, 0x04, 0x21, 0xa8, 0x13, 0x05, 0x21, 0x62, 0x00, 0x06, 0x24, 0x03, 0x00, 0x03, 0x00, 0x00, 0x08, 0x21, 0x02, 0x01, 0x0a, 0x21, 0x00, 0x00, 0x98, 0x21, 0x1e, 0x00, 0x99, 0x21, 0x00, 0x00], destinationEndpoint: 0x01, direction: 0x01, isClusterSpecific: false, isManufacturerSpecific: true, manufacturerId: 0x115f, messageType: 0x00, number: null, options: 0x0100, profileId: 0x0104, senderShortId: 0xb73f, sourceEndpoint: 0x01, text: null)

9:40:12: debug Thing: Parsing 'catchall: 0104 0000 01 01 0100 00 B73F 00 01 115F 0A 01 01FF42260121C70B0328230421A8130521620006240300030000082102010A21000098211E0099210000'
veeceeoh commented 6 years ago

@xtianpaiva - all of the log messages you copied here are normal, and not errors, so that's good news!

I have made an update to the DH for the Aqara button to add a fingerprint for the new lumi.sensor_switch.aq3 model, but before we release it, do you have time to try it and see if your button is recognized when using "Add a Thing" in the SmartThings mobile app?

Also, can you copy log message you see when you press the button? For example:

single-click (same speed as clicking a mouse) double-click triple-click quadruple-click hold the button for 3-5 seconds ...and also/// try shaking the button (I found a reference online that says the lumi.sensor_switch.aq3 can detect being shaken.)

The log messages will help us to know if the new Aqara button model has any new features to put into the DH.

Thanks!!!

veeceeoh commented 6 years ago

Also - what does your button look like?

xtianpaiva commented 6 years ago

Hi @veeceeoh just uploaded the new DH (v1.2) and re-added the Thing, no luck, it doesn't get recognized automatically, so I assigned it manually.

Maybe you can add some debugging to the code, I'm able to test it again.

When the button is pressed, there is an error:

0a685dc3-45f2-487c-be20-3f0d8c1b6e67  19:30:23: error java.lang.ArrayIndexOutOfBoundsException
0a685dc3-45f2-487c-be20-3f0d8c1b6e67  19:30:23: debug Thing: Parsing 'read attr - raw: 8A960100120A5500210100, dni: 8A96, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0001'
0a685dc3-45f2-487c-be20-3f0d8c1b6e67  19:30:17: debug Thing: Parse returned [name:Model, value:lumi.sensor_switch.aq3, unit:%, isStateChange:true, descriptionText:device model, displayed:true, linkText:Thing]
0a685dc3-45f2-487c-be20-3f0d8c1b6e67  19:30:17: debug Thing: Parse returned [name:battery, value:100, unit:%, isStateChange:true, descriptionText:Thing Battery at 100% (3.035 Volts), displayed:true, linkText:Thing]
0a685dc3-45f2-487c-be20-3f0d8c1b6e67  19:30:17: debug Thing: [name:battery, value:100, unit:%, isStateChange:true, descriptionText:Thing Battery at 100% (3.035 Volts)]
0a685dc3-45f2-487c-be20-3f0d8c1b6e67  19:30:17: debug Thing: Parsing 'read attr - raw: 8A9601000088050042166C756D692E73656E736F725F7377697463682E61713301FF42260121DB0B0328230421A8130521620006240200030000082102010A2100009821070099210000, dni: 8A96, endpoint: 01, cluster: 0000, size: 88, attrId: 0005, encoding: 42, value: 6C756D692E73656E736F725F7377697463682E61713301FF42260121DB0B0328230421A8130521620006240200030000082102010A2100009821070099210000'
xtianpaiva commented 6 years ago

It looks like this, no evident difference from previous model I think...

img_0166 img_0167

xtianpaiva commented 6 years ago

single-click Thing: Parsing 'read attr - raw: 8A960100120A5500210100, dni: 8A96, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0001' double-click Thing: Parsing 'read attr - raw: 8A960100120A5500210200, dni: 8A96, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0002' triple-click none quadruple-click none hold the button for 3-5 seconds hold Thing: Parsing 'read attr - raw: 8A960100120A5500211000, dni: 8A96, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0010' release Thing: Parsing 'read attr - raw: 8A960100120A5500211100, dni: 8A96, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0011' shake Thing: Parsing 'read attr - raw: 8A960100120A5500211200, dni: 8A96, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0012'

veeceeoh commented 6 years ago

Thanks... and Wow! That's totally different from the lumi.sensor_switch.aq2 model, and has much better capabilities.

All of those log messages tell me exactly what I need to change the DH to work with this model, and actually it may be a good idea to make a new DH just for this new Aqara model.

I really want to buy one of these - but how can we know if the seller will send lumi.sensor_switch.aq2 or lumi.sensor_switch.aq3??

What company did you buy it from?

kquinsland commented 6 years ago

@veeceeoh took the words right out of my mouth! I'd love a button that could support shaking as well as 1 or 2 presses as well as tap and hold.

single device, 4 different triggers!

For the record, i recently placed an order for several aqara buttons, they all have the ID of WXKG11LM. The ones that @xtianpaiva posted: WXKG12LM. The dif being 11 vs 12.

@xtianpaiva can you give us more details on when/where you got these buttons?

bspranger commented 6 years ago

My aqara button is a WXKG11LM

veeceeoh commented 6 years ago

I just realized that different printed model number also.

Looking at the reviews for the Aqara button on GearBest, I can't any photos that show WXKG12LM.

Based on the messages seen in the log output, the new Aqara button will be able to do the hold function more reliably than the round Xiaomi "original" Button!

bspranger commented 6 years ago

Yeah the new button looks way better!

kquinsland commented 6 years ago

After a closer look @ my aqara buttons (version 11LM) i have a line labeled CMIT ID: 2016DP6442 and @xtianpaiva's does not have this marking...

THe earliest mention i could find was Jan21: https://www.domoticz.com/wiki/index.php?title=Xiaomi_Gateway_(Aqara)&oldid=10095

Look here, you will see that there were two page edits on the 21st. the first edit does not contain the string aq3 and the second edit does. https://www.domoticz.com/wiki/index.php?title=Xiaomi_Gateway_(Aqara)&action=history

my button: https://ae01.alicdn.com/kf/HTB1iQYmi46I8KJjSszfq6yZVXXat/Original-Xiaomi-Aqara-Smart-Wireless-Switch-Key-Intelligent-Application-Remote-Control-Built-In-Gyro-ZigBee-Wifi.jpg

bspranger commented 6 years ago

It looks like this new button needs to be a new DH?

veeceeoh commented 6 years ago

@bspranger - yes. I could make a new one using the code I've been working on for the round "original" button. Just need to figure out the correct fingerprint, which is tricky, because it doesn't show up in the Hub events log for Xioami devices, only if they're paired and recognized. So a chicken and egg problem...

xtianpaiva commented 6 years ago

@bspranger @veeceeoh @kquinsland AliExpress is where I purchased the button, it is advertised as "2017 NEW" LINK

veeceeoh commented 6 years ago

Thanks, @xtianpaiva! Going to order a few!

xtianpaiva commented 6 years ago

@veeceeoh maybe you should order one, to be sure you finally get the lumi.sensor_switch.aq3 version, on these sites there can be some "variation". You know, just to be on safe side. :)

veeceeoh commented 6 years ago

I am reading about the WXKG12LM model maybe having a microphone sensor (?)

https://w3bsit3-dns.com/forum/index.php?showtopic=680062&view=findpost&p=69793769

xtianpaiva commented 6 years ago

I don`t think so @veeceeoh, my wife is laughing on me as I try to talk to the button :D, nothing in the logs at least.

veeceeoh commented 6 years ago

LOL!

veeceeoh commented 6 years ago

Features confirmed!

screen shot 2018-02-28 at 3 45 24 pm

From this site (Polish): http://allegro.pl/aqara-mini-przelacznik-bezprzewodowy-naklejka-mg-i7186033766.html

foz333 commented 6 years ago

Not been about much lately, tried to quit my job last week, but been reading with interest... be good to get finally get a fully function xiaomi button with all features working... this is one of the reasons ive been looking at the hubitat for local processing... but tricky to get in EU.

@veeceeoh been reading your efforts with the runin and other options for existing buttons i may have an idea to help but got to think the logic fully. This looks button looks good but still need to figure out optimal support for existing buttons. For DHs this is not going to help that the buttons look identical and have the same names... i can see a lot of people using the wrong thing.

bspranger commented 6 years ago

That is why there are finger prints. So they control which DH gets installed.

foz333 commented 6 years ago

only after they are imported

foz333 commented 6 years ago

as in end user needs to import 2 files to support one button (if not sure which they have).... not a big deal and somewhat unavaoidable unless im missng something, but opens up the path to more pairing related issues.

veeceeoh commented 6 years ago

@foz333 - Actually, I realized only one DTH is needed for the two Aqara models. I can do all of the code except for the fingerprint, which I can find out when the ones I order arrive (probably in 3 weeks). Please do share your idea for the button code though...

My "original" Xiaomi Button device driver for Hubitat is basically finished now (and available for anyone to try). I tested it a bunch last night with an app, and the runIn() function works great when the code is locally executed! I can't wait for the new Aqara buttons because with the separate hold and release messages I can make a dim/brighten App that will allow me to select a brightness for my Sengled bulbs by holding the button, much like the way an in-wall GE Z-Wave Dimmer switch works.

kquinsland commented 6 years ago

@veeceeoh i'll be more than happy to test your driver for hubitat as soon as i can successfully set mine up. Looking at it's network traffic, it called out to a lambda function once and has yet to show up in the portal; i'm unable to finish registration / setup. I'm putting together a more detailed set of notes for the support ticket i'll open w/ them later today.

veeceeoh commented 6 years ago

@kquinsland - You're not the only user who has had this problem - I noticed this thread on the Habitat Forum last night. The hub, which is running a special build of Ubuntu Server on Armbian is completely locked down, as I explained on the SmartThings forum here. So there's not much an end user can do in your scenario without their help, sadly. I don't see a "kquinsland" there - what's your Habitat username?

kquinsland commented 6 years ago

@veeceeoh Thanks for the details! I was doing some prying of my own; i'll check your links out, they might fill in some gaps in my knowledge.

Where / How do i determine what my username would be? I've only signed up for the portal. It looks like the support sub-domain is a ZenDesk CNAME with auth coming from the same AWS Cognito that portal uses. Try searching for hubitat as the username on the zendesk instance; that's apparently what shows up in the top right corner when i go to the support domain.

I've yet to post anything there; i'm still turning my notes into a cohesive draft that i'll post later today.

So there's not much an end user can do in your scenario without their help,

Challenge accepted ;P

I found a serial port, but i lack the necessary equipment (or time!) to probe it currently. Similarly, i have not been able to trace where the push button behind the AV 3.5mm socket goes on board, but i'm assuming it's a reset button.

gn0st1c commented 6 years ago

@kquinsland : i also had registration problem and the official solution was "reboot the hub. it may take a couple of times.". after the 2nd reboot, i was able to register :)

veeceeoh commented 6 years ago

@kquinsland - I already tried downloading the latest Armbian Ubuntu desktop image, put it on a SD card and attempt to boot from it, using the reset button. As far as I can tell, they have disabled the dual boot feature that was used to install Armbian server on the 96x's flash memory.

I haven't bothered with trying to gain access through the serial port because I assumed I'd still have to be able to produce the correct login credentials.

When I registered, my initial username was the same as my email minus "@_." and I was not happy with that at all. I contacted them via the support email and they got it fixed straight away.

bspranger commented 6 years ago

I have a hubitat being delivered today... not sure what I am getting myself into...

kquinsland commented 6 years ago

@gn0st1c good to know. the 3rd and 4th time were not the charm, so i'll keep trying, i guess...

@veeceeoh sorry, i mis-spoke. I was in a rush earlier! I meant JTAG, not serial. Assuming the test pages are labeled correctly / jtag is not turned off on the device, it should be possible to pop this box. Zero room in my tiny apartment for my usual electronics lab, though :(.

gn0st1c commented 6 years ago

@kquinsland : hub registration

@bspranger : it won't replace your smartthings out of the box. (currently, no hue support etc). but you'll love coding locally.

veeceeoh commented 6 years ago

@kquinsland - I have no knowledge of how to make use of a JTAG interface, but if you see that the board has one, perhaps that's a way to get a dump of the contents of the eMMC NAND flash. But what if that data is encrypted?

Is this the JTAG interface?

screen shot 2018-03-01 at 12 04 01 pm
kquinsland commented 6 years ago

@veeceeoh yessir. Those .05mm (?) pitch pads are going to be a PITA to attach to, though. As i said... none of my usual kit is available to me at the moment.

JTAG is an old protocol that's been extended a few times. the processor can (usually) be configured to hide certain things from JTAG access, but it remains to be seen if that's been done here. For development, it's usually not the default configuration.

Since i have yet to attach a JTAG harness to the board to confirm, take this w/ a grain of salt... Yes, it would be possible to boot up the processor and load our own instructions to dump the flash blocks. As for encryption, that'll depend on where if the keys are stored. It is certainly possible to have them burned into the chip such that they're in-accessible to JTAG.

https://en.wikipedia.org/wiki/JTAG#Debugging

kquinsland commented 6 years ago

@gn0st1c i dont have access to that thread :(. my username on that portal is hubitat5

veeceeoh commented 6 years ago

@kquinsland - I just looked and you're not shown as a Hubitat owner:

screen shot 2018-03-01 at 4 45 54 pm

Owners have a little smiley face in the lower-right corner of their profile pic / icon, like this:

screen shot 2018-03-01 at 4 48 41 pm

You should contact Hubitat support to makes sure your username /e-mail is recognized as having Owner status on the Community Forum / Support sites.

gn0st1c commented 6 years ago

@veeceeoh : my owner badge was given about a day after my hub registration.

foz333 commented 6 years ago

screenshot_2018-03-03-16-34-33 Maybe a new version of this too... anybody seen anything?

veeceeoh commented 6 years ago

So, I just checked the shipping info on the two new Aqara Button's (WXKG12LM) I ordered from Ali express over a week ago, and they've only just left the shipping warehouse.

So it's going to be another at least 2 weeks, and I think I should just try writing the new DTH based on the messages it sends that @xtianpaiva posted.

That way people with these new buttons can start using them, and just need to manually change to the new DTH after pairing. I should be able to figure out the correct fingerprint for automatic pairing when mine arrive.

veeceeoh commented 6 years ago

Well, my two Aqara Buttons have arrived in the US, at San Francisco's giant USPS facility. They are supposed to be delivered this Saturday.

I am currently beta testing what I hope will be the update to the round "Original" Xiaomi Button DTH, and if the people who are testing it with webCoRE come back with positive results, then I can just use that code as a starting point for the Aqara WXKG12LM Button DTH, and just add button number mappings for the double-click and shake capabilities.

xtianpaiva commented 6 years ago

@veeceeoh I can help to test the new DH, just let me know

gn0st1c commented 6 years ago

since we've talked about hubitat here, i thought i should also mention homey.

just received it last week and i love it so far. there is community developed xiaomi zigbee/lan devices support.

note that there is no smartthings device support, yet. (as most users are in europe and they don't know about smartthings).

GrahamDMoore commented 6 years ago

"Don't know about SmartThings" .You are clearly very poorly informed or just narrow minded. Whatever the reasons at least have the courtesy to reflect on what you write before posting, as it is dismissive and says far more about you than you realise.

Graham D. Moore

On 22 Mar 2018 08:11, "gn0st1c" notifications@github.com wrote:

since we've talked about hubitat here, i thought i should also mention homey https://www.athom.com.

just received it last week and i love it so far. there is community developed xiaomi zigbee/lan devices support https://apps.athom.com/search?query=xiaomi.

note that there is no smartthings device support, yet. (as most users are in europe and they don't know about smartthings).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bspranger/Xiaomi/issues/106#issuecomment-375212332, or mute the thread https://github.com/notifications/unsubscribe-auth/AXtANlqlRNBAX4dQ-FovWOs3ZhzpDageks5tg1yYgaJpZM4SWhT6 .

gn0st1c commented 6 years ago

@GrahamDMoore : i stand corrected, thank you.

kquinsland commented 6 years ago

Just got my order of WXKG12LM buttons. Can help test a new DTH over the next few days

veeceeoh commented 6 years ago

I received an email that my Aqara buttons were delivered today too! They better be model WXKG12LM!!

I am already almost finished with the new DTH code, will be able to try it out tonight and then I will make a Pull Request so everyone can test it out.

bspranger commented 6 years ago

Hope you got the WXKG12LM. Will be cool to have support for them.