ZHA - Aqara Magic Cube (57 actions)

That’s the correct behaviour.
You can start using this blueprint. Just select the right device.

Yep, you’re totally right.
I should have just tried it and I may have realised that.
I really appreciate the help.
Also, this works awesome!

Thanks @brent, that looks really powerful and this blueprint convinced me to buy one cube.
One question (or two) : it does not seem that sides of the cube are identified by numbers. How to you know which one is which ?
Second one : Aqara only advertises 6 moves and they don’t take into account the side. Shall I understand that through the Zigbee messages sent by the cube we can know the side nb facing up, etc … If so, this opens up to even more actions.
tks

Thank you for this good job!

This made the cube a really useful device. I’m a newbie.

Can you please tell me if there is some way to add a separate rotation for each side to this blueprint?

Or if this is too much for you, maybe someone else from respected users can give me an answer?

This would be the pinnacle of excellence in using this device.

1 Like

great work!
just got an aqara cube can’t wait to try this out.
does anyone know is it possible to have a double tap action with this blueprint, and if so how to implement?

EDIT: nevermind - my understanding now is that ‘knock’ is a double tap action, and there is no single tap?

1 Like

I’m glad this has been useful to so many people!

The side with “Aqara” is 1.
The side opposite that is 4.
If you position the cube so that Aqara is on the top, and facing you so you can read it, the remaining sides are:
Up: 3
Left: 5
Right: 2
Down: 6

If you want to check for yourself, go to Developer Tools → Events. Start listening to zha_event, and the event data will have an activated_face variable. That’s the side that’s up.

Some of the gestures do send the activated face (flip, slide, knock). Others don’t (drop, shake, rotate).

The information sent by the cube doesn’t include the side that’s up during a rotation. It would be possible to track that in an input_number helper, but I’m not sure how to generalize that for a blueprint without hardcoding a name of a helper (maybe possible, but if so I don’t know how yet). Also, there are many things that can happen that would get that out of sync, like tossing the cube in the air. Very easy for the side that’s actually up to be different than the last reported activated side.

It seems that a single tap doesn’t send an event at all. Any number of multiple taps in quick succession (I tested 2-6) send a single knock event.

2 Likes

:pray: really useful

Love it! Could you extend this with rotation on each side (same as slide)?. This would allow me to change brightness of multiple lights and adjust volume for instance.

Nope, unfortunately not. For a more thorough explanation, see my comment a couple replies up.

Am i the only one to report that my logs fill up with messages like the one below every time an event kicks in?

WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'flip_degrees' when rendering '{{ trigger.event.data.args.flip_degrees }}'

and the same for relative_degrees if flip is used.

The culprit is the blanket access of those trigger.event.data.args keys when setting up the initial variables.

A fix would be to check do the existence of the key first, like this:

action:

  - variables:
      ...
      flip_degrees:   ' {{ trigger.event.data.args.flip_degrees | default }}'
      relative_degrees: '{{ trigger.event.data.args.relative_degrees | default }}'

[edit: had suggested another code above for some period, but reverted back to default filter]

Is there any possiblity that this fix can be applied?
(and if yes, do i need then to refresh my blueprints, somehow?)

PS: thank you for your efforts.

Thanks for finding that and for the code revisions! Currently, relative_degrees isn’t used, so I commented it out. I also provided default values for both value and flip_degrees. In my testing, there are no longer errors, and everything still works as intended. Additional feedback welcome!

Edit: I’m not sure of the correct way to update yours. Documentation says “When a user imports a blueprint, Home Assistant stores the URL from which it was imported. This will allow Home Assistant in the future to update blueprints by looking at updated blueprint code in the forum topic.” So I can’t tell if that means it will automatically update or not.

I’m not able to import this blueprint, it says that it’s not formatted correctly.

No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

Fixed. The parser apparently didn’t like having anything after the blueprint code block. Moved the changelog to before. Thanks!

1 Like

Would it be possible to make ‘side 1 up’ and rotate left / right ??
And that for all sides possible??

So based on what side is up, and rotate left / right to trigger an action??

Thnx

Nope, unfortunately not. That information isn’t sent with the rotation event. See here.

I know, but isn’t it possible to set the state (side up) to a memory , and then add the rotation to the side up ?? I’m also trying to figure this out in node red …
So I can use like ‘side one’ to set volume of Sonos
Side 2 to to dim lights etc

2 Likes

I made some comments on that in a previous reply as well. In short: yes, it’s possible, no, it probably isn’t reliable. It’s at least not something that I think would be appropriate for the blueprint.

Setting different actions to rotate the cube on each side would be a really useful feature. Therefore, we bother you so much :sweat_smile:
I have no experience in programming, otherwise I would try to do everything myself. :slightly_smiling_face:
I noticed that many people manage to implement this function for example in deCONZ. It would be cool to implement it in zha too.
Since ZHA is easy to understand for novice users.

Here is an example of code in deCONZ.
The site was translated from RU to EN using google.

Here is the original RU page.

Maybe this will help someone to implement it also in ZHA.

Thank you for your patience and your efforts and sorry for the intrusiveness.

1 Like

I couldn’t find this mapping originally (didn’t search hard enough :stuck_out_tongue:) – maybe it’s worthwhile to put in the main post?

Aqara cube layout (sides):
         _______
        |       |
        |  #3   |
 _______|_______|_______
|       | AQARA |       |
|  #5   |  #1   |  #2   |
|_______|_______|_______|
        |       |
        |  #6   |
        |_______|
        |       |
        |  #4   |
        |_______|
3 Likes

I can’t get the face-specific knocks to work. It adds the correct YAML in automations.yaml, the zha_event is also correctly registered, but when knocking on the respective side - nothing happens.
The log output only has:

2021-08-01 10:24:55 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Restarting
2021-08-01 10:24:55 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Running automation actions
2021-08-01 10:24:55 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Executing step setting variables

Compared with e.g. flip to a specific side:

2021-08-01 10:24:25 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Restarting
2021-08-01 10:24:25 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Running automation actions
2021-08-01 10:24:25 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Executing step setting variables
2021-08-01 10:24:25 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Choose at step 2: choice 8: Running automation actions
2021-08-01 10:24:25 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Choose at step 2: choice 8: Choose at step 1: choice 1: Running automation actions
2021-08-01 10:24:25 INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube_57_actions] Aqara Magic Cube (57 actions): Choose at step 2: choice 8: Choose at step 1: choice 1: Executing step call service

What am I missing? :thinking: