-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xiaomi Mi Smart Cube #138
Comments
I think I figured out the Multistate Input cluster (0x0012). The cube has six sides (duh), numbered as follows:
Side 5 is with the MI logo; side 3 contains the battery door. Depending on the action, the following values for 0x0012/0x0055 are reported:
Push works in any direction. For Double Tap you really need to lift the cube and tap it on the table twice. In the Cluster Info plane in the deCONZ GUI, the 0x0012/0x0055 attribute is updated in real-time, but the 0x000c/0x0055 attribute isn't. In the Report Attribute command, this attributes is reported seconds, after the 0xff05 attribute. Could this be a bug in the deCONZ GUI, that it discards the whole message, when it finds an unknown attribute? |
Awesome! Mine hasn't delivered yet, from your findings it looks to be perfect to trigger some rules.
I'll check that, normally every command should be forwarded at least in the apsdeDataIndication(), but the NodeEvent might miss it then the cluster is not defined in the ZCLDB xml file. |
Sure looks like a fun gadget here.. guessing I will order one to and tag along for testing if that is ok with you all. |
Yes, please, the more the merrier!
The cluster is defined, as is the 0x0055 attribute, but the 0xff05 attribute isn't. Haven't tried adding it to the file yet.
Loads of rules! It has 43 (if I count correctly) different values for 0x0012/0x0055. Would we want to expose the raw value as Mapping the rotation is going to be even more challenging. I think we would need to translate the angle into a series of button events (cf. holding a button), where the number of x001 events corresponds to the size of the rotation. E.g. 30º would be 2000, 2002; 90º would be 2000, 2001, 2001, 2003; and -90º would be 3000, 3001, 3001, 3003. This would allow for rules similar to those for the DimUp and DimDown buttons of the Hue dimmer or Trådfri remote. |
Spontaniously, I would not go for the 43 options/rules. Practically this would never work I think. Just think how you would want a simple guy like me to memorize 43 options to reach my goal ;-) |
Implemented provisional support in PR #139, using the raw values for |
If I'm lucky the cube and various other Xiaomi sensors will arrive today :)
The deCONZ core will be extended so that yet unknown clusters and attributes will be attached on arrival of ZCL attribute reports. This is possible since the reports contain all the information including datatype (beside the complexity the ZCL generic stuff is really nice).
I'm for an abstract simple approach like the six sides mapped to
The |
I hope you get yours soon! This waiting on Chinese shipments is not my thing...
Agreed. I do want to be able to support different use cases:
In other words, we need to cater for both simple and complex rule schemes.
So e.g. push while side 1 is on top would be 1001, for side 2: 2001, for side 3: 3001, etc. For the second use case, I really don't mind, but for the first, you'd need a rule condition for push. In this scheme, that condition would be If we were to flip the coding: use the action for the 1000s and use the side for the 1s, we'd have e.g. push for side 1: 1001, for side 2: 1002, for side 3: 1003, etc. Now the condition becomes
No, it doesn't. And yet, it sort of does. Note that the cube is stateless: it only reports gestures. If I gently flip the cube, it doesn't send any Report attributes, so there's no way of knowing which side currently is on top, or what the actual rotation orientation is.
I suppose the IKEA dimmer? Again thinking use cases: I'd want to dim my lights by rotating the cube. Of course, when I rotate a small angle, I'd want to change the brightness a little bit, and when I rotate a big angle, I want a big change in brightness. Ideally, I would be able to pass the angle reported by the cube as parameter to the action to set Again, I could workaround this by creating a whole bunch of rules, which different conditions: BTW: I don't think there's a hard limit on the number of rules that deCONZ supports? I'm currently on 231 rules with 693 conditions and 377 actions on my RaspBerry Pi 3. This is more than I'd need once I no longer need to workaround issue #98 (dare I give another hint ;-). Even then, this is obviously way too much to manage manually. I really think we need to care not to explode the number of rules needed for using the cube. |
The package has delivered, I can confirm the above observations — oh the possibilities :) This is a very children friendly device. |
Makes you never want to grow up ;-)
Love to hear you view how to tame these (see my earlier post). Below the changes I made to the ZCLDB xml file, to monitor the values from the deCONZ GUI Cluster Info panel. Alternatively, use my PR in combination with a web sockets monitor to see which events reach deCONZ. Unlike my initial observation 0x000c/0xff05 does occasionally change value while rotating the cube. I haven't been able to detect any pattern, nor what this attribute stands for. <cluster id="0x000c" name="Analog Input (Basic)">
<description>An interface for reading the value of an analog measurement and accessing various characteristics of that measurement.</description>
<server>
<attribute-set id="0x000" description="Analog Input Information">
<attribute id="0x0051" type="bool" name="Out of service" required="m" access="rw" default="0"></attribute>
<attribute id="0x0055" type="float" name="Present value" required="m" access="rw" default="0"></attribute>
<attribute id="0x006f" type="bmp8" name="Status flags" required="m" access="r" default="0">
<value name="In Alarm" value="0x01"></value>
<value name="Fault" value="0x02"></value>
<value name="Overidden" value="0x04"></value>
<value name="Out_of_Service" value="0x08"></value>
</attribute>
<attribute id="0xff05" type="u16" name="Unknown" required="o" access="r" default="0" showas="hex"></attribute>
</attribute-set>
</server>
<client>
</client>
<!-- TODO -->
</cluster>
<cluster id="0x0012" name="Multistate Input (Basic)">
<description>Provides an interface for reading the value of a multistate measurement and accessing various characteristics of that measurement. The cluster is typically used to implement a sensor that measures a physical quantity that can take on one of a number of discrete states.</description>
<server>
<attribute-set id="0x000" description="Multistate Input Information">
<attribute id="0x004a" type="u16" name="Number of states" required="m" access="rw" default="0"></attribute>
<attribute id="0x0051" type="bool" name="Out of service" required="m" access="rw" default="0"></attribute>
<attribute id="0x0055" type="u16" name="Present value" required="m" access="rw" default="0" showas="hex"></attribute>
<attribute id="0x006f" type="bmp8" name="Status flags" required="m" access="r" default="0">
<value name="In Alarm" value="0x01"></value>
<value name="Fault" value="0x02"></value>
<value name="Overidden" value="0x04"></value>
<value name="Out_of_Service" value="0x08"></value>
</attribute>
</attribute-set>
</server>
<client>
</client>
<!-- TODO -->
</cluster> |
As a guy with a soft spot for gadgets, this is indeed a long wait! Won't grow up anymore I think :-) I know what you're saying there @ebaauw .... But at least I can prepare playing with it in my head for now....
I am looking a bit of a different standpoint. as I am not looking for rules on the gateway level really, my users like to be able to control many types of devices within their system that can be Zigbee of course, X10, Zwave, klikaanklikuit or other protocol types of devices. And this is done with events and action controled outside the gateway, in the homeseer environment. The side of the cube could be an important parameter pointing to the light I am controlling (or a thermostat, blinds, whatever...). So it is a bit of a bummer that this status is not always updated. Maybe I could guide this a bit to my users by expecting a push for instance before enabling triggering a shake or accepting a second push shortly after that?
Lots of possibilities here, am seeing lots of use cases in my house, for laying, but also serious (how about shaking to put the TV on... a double push for changing channels.....).
Just thinking out loud here... |
I documented the raw values above. Whatever mapping we'll make, we won't be able to create more info. Currently, I'm exposing these raw values 1:1 as
The cube doesn't keep a status - it just sends notifications for gestures: Shake, Push, 90º Flip, 180º Flip, Double Tap, Rotate. Sometimes the cube doesn't register a gesture, so it doesn't send a notification, e.g. if I gently flip the cube. When the next gesture is 90º Flip, 180º Flip, Push, or Double Tap, it sends the actual (new) top side during that gesture. When the next gesture is Shake or Rotate it doesn't send the top side. Any status tracking of which side would be on top in between 90º Flip, 180º Flip, Push, or Double Tap notifications is your own guess. |
I guess I will need to play with it when it arrives.. Will set it in toy mode surely before getting too serious.. If with a 90° flip the old side is delivered, then that is promising, as we can calclulate the old side for 180° Flip as well right? With push old side should show the correct side for the plugin, as does Double tap. As for shake or rotate I could use the saved value for last know side, or demand a push before excuting shake or rotate. I am glad you are sharing the experiences, trying to get the picture in my mind how to get it all and make this usefull for the users. |
Yes, see the "map" I drew of the sides. |
Ok, I was really thinking on the thumb of "7". If you want to know what is on the other side of a dice, the sum of top and bottom is 7. I am expecting it would not be much different for this cube. The other side of 3 is 4, the other side of 1 is 6 etc. For the 90° flip it is more difficult, as you could go 90° left, right, forward of backward... |
I was as well. Let's renumber the sides, so opposite sides add up to 7 (and the opposite side can be computed by
where side 2 holds the MI logo and side 6 has the battery door.
The cube doesn't know its orientation. It only knows that you flip to side 1 from side 3, which could be front, right, back, left, depending on the orientation.
Let's try that for now. We need to add 7000 for gestures where there's no side (shake, rotate). As for the action, I would use the previous side here, with 0 for push, the same side for double tap, the opposite side for 180° flip, and the other four sides for 90° flip. This leads to:
Note: the cube reports these gestures from the Multistate Input cluster on endpoint 2, so these are the |
Sure, it actually shows as two sensors. The light sensor seems to report too low light levels compared with other light sensors.
|
Translate raw multistage input values into meaningful buttonevent values, see #138.
Thanks @manup! I assume it uses Report Attribute commands for the 0x0400 and 0x0406 clusters, like the other Xiaomi devices?
That could be compensated by adjusting Out of interest, does the 0x0406 cluster support PIR Occupied to Unoccupied Delay? I'd expect not, as all other Xiaomi devices only support attribute reporting. Does it also report when motion is no longer detected (like the Hue motion sensor), or only when motion is detected (like the TRADFRI motion sensor)? |
It does, there is also a manufacturer specific report to basic cluster, haven't figured out what it does yet (maybe battery report).
Yes these should be adjusted.
The ZCL values and based on lux value is defined by the ZCL spec, maybe Xiaomi is creative here again and they just forward the raw lux value, so we just could skip the transform. Needs more observation but by looking on the values it kinda makes sense.
It seems that the sensor only reports 0x01 as presence when motion is detected, same is true for light value. When no motion is detected it keeps total radio silence, very likely to safe battery. |
The other Xiaomi sensors seem to send a report for 0x0000 when the setup button is pressed, but I don't think I saw the Manufacturer Specific flag set in any of these. I did capture several of these (this is from the weather sensor):
Wireshark actually truncates the string, because it contains \0 (0x00) characters, but there's a full 37 bytes of data. I figured it might be a logo, picture, or some Chinese text for the Mi app, but in my very small sample, I see different values for one byte. |
For the motion sensor it happens after I tried to read the occupancy attribute. Same attribute is reported, 34 bytes, attribute id 0xff01 with manufacturer code 0x115f. |
I received my cube today. I have the cube connected to deCONZ, but no reports yet in the REST api. Do I miss a step or is it not available? |
Which cube model are you talking about? deCONZ issues buttonevent 7007 when I shake my old model (non Aqara) cube. |
I stand corrected. |
Just did some juggling with my cube, and, indeed, it reports a Present value of 3. Hadn't seen that before. I'll map it to buttonevent 7008. PR #632. |
Sorry for whipping this closed thread (tell me if you want me to open a new issue), but I just want to come with an observation.
I have a rule triggering every time lastupdated changes:
Note the Thread:sleep(600) I had to put in. Could it be that the state lastupdated is updated before the buttonevent? Apologies if the problem I'm seeing is not deCONZ related. |
I don't know how OpenHAB works, but in deCONZ
That might be stretching it (depending on what hardware deCONZ runs on). I find that the Hue bridge cannot handle polling more frequently than once every two seconds (2000ms). I never tested this extensively with deCONZ, because, in my HomeKit plugin, I use the web socket events for instant notifications, instead of polling deCONZ. I think OpenHAB should do this as well. |
Fine, just wanted to check the source first. I also found that reducing the Thread:sleep to just 10ms also did the trick. My deCONZ is running on the same host as openHAB on a Intel Celeron 2957U / 1.4 GHz so polling the two sensors makes top show deCONZ with 2-3% CPU every now and then. Thank you so much for your help so far. Maybe tomorrow we will see how the Aqara cubes fare? :-) |
@ebaauw I'm currently running deconz 2.05.35, but i seems, that analog input events are not broadcasted over websocket. |
They are:
Note that the cube has two
|
thanks for the info!
It shows a doubletap-rotation-doubletap chain and I don't see any "Update ZCL value"/"Websocket send message" for the 00C, which supposed to be the rotation iirc. |
Could you double-check that you have two sensor resources? If not, better reset the cube, delete the resources through the API, delete the node from the GUI, and re-pair the cube. Another cause could be that the 0x000C cluster is missing from the ZCL definitions in general.xml. What system do you run deCONZ on? Could you double-check that the cluster is visible in the deCONZ GUI, and the the Current Value attribute (0x0055) gets updated. |
@ebaauw thanks for the info, remove/add just worked fine. It turned out, that the trick is - which I obviously missed in the docs - during Add process I need to do make an action for both sensors ( shaking/rotating the cube and rotating on a flat surface). Thanks! |
How to you add the Cube to deconz? I am having issues with pairing... |
How do I have to add the cube? I have issues too with pairing. Other sensors from aqara are no problem. |
@Oliviakrkk, @siggi85 try to get cube very close to ConBee stick (for pairing) and check battery (low battery is casing problems). |
Thanks for help! I did it this way long time ago und it worked. 😊 |
just received my aqara smart cube today and succesfully connected it with deconz all gestures are recognized except for the rotate version; anyone who could help me to get this enabled? would like to dim my lights with this option which should be possible of course but ain't seeing any events coming through is there another way to test this out? |
Put it in front of you, start sensor search in Phoscon, do not lift it, but spin clock-/counterclock wise a few times. |
@SwoopX its already connected with deconz... all other gestures are coming through it's only that the motion "rotate" is not being detected. So no issues with connecting it to deconz that's working perfectly fine :-) |
If you wanna ignore the solution, feel free 🤷♂️ |
well not ignoring the solution otherwise I wouldn't have asked right? but if that's not helping? 😉 |
@jaimyborgman as it is described here: in Cube there are 2 seperate sensors, and both of them need to be activated.
|
@pawelbura many thanks for taking the time to reply! I’d already managed to get it working shortly after my first question. I’d removed indeed the cube first and then paired it first as a sensor by rotating it on its own axes. After that I’d again paired it as a switch which eventually resulted in both sensors being registered under the switch tab. At first pair I’d connected it as a switch which resulted in issues in deconz for me also while trying to add it as a sensor after it turned green but wasn’t showing up. So the order of the steps taken are important; first the sensor after the switch worked out perfectly fine for me! |
Erm, deleting the sensor shouldn't have been necessary but great that it works now.
That's what I said, right? Badly expressed? Btw, you can create both sensors while searching for sensors. When the first one is found, you get the green success indication but the network is only closed after do click on the button. So by not clicking it, it should allow you enough time to perform gestures required for both sensors. |
New gadget!
It sends unicast Report Attribute commands to the RaspBee, endpoint 1:
The text was updated successfully, but these errors were encountered: