ZHA - Aqara Magic Cube (69 actions)

Blueprint to automate the Aqara Magic Cube using ZHA.
Based on Mikkelmoller’s 51-action blueprint.
as well as brent’s 57-action blueprint.

This blueprint adds support for rotating the cube per specific side, by using an Input Number helper to track the side that was last activated by a side-specific action (flip, slide, knock).

Note that since this blueprint uses an input number helper to track which side is active, it will only register side changes from valid side actions (again, flip/knock/slide). If you lift the cube, rotate it freely, and then place it down on a different side, this is not registered as a valid action and the tracking variable won’t be updated.

The input number helper will need to be created independently in HomeAssistant, by going to Configuration → Helpers in the UI and adding a new Number helper.

Supported actions

  • Slide
  • Knock
  • Flip 90 degress
  • Flip 180 degress
  • Flip to specific side
  • Shake
  • Drop
  • Wake
  • Rotate clockwise
  • Rotate counter-clockwise
  • Rotate per side

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Here’s a sample automation that will call out the side using Alexa media player TTS when flipped, and will adjust brightness of office lights based on the relative degree of the rotation (thanks brent!) but only for face 1:

- id: '1634593050891'
  alias: 'Master: Aqara Magic Cube'
  description: ''
  use_blueprint:
    path: rvaidya/aqara_magic_cube.yaml
    input:
      remote: 3243d34
      active_face: input_number.aqara_magic_cube_active_face
      flip_any: true
      cube_flip_1:
      - service: notify.alexa_media
        data:
          message: One
          target: media_player.user_s_echo_dot
          data:
            type: tts
      cube_flip_2:
      - service: notify.alexa_media
        data:
          message: Two
          target: media_player.user_s_echo_dot
          data:
            type: tts
      cube_flip_3:
      - service: notify.alexa_media
        data:
          message: Three
          target: media_player.user_s_echo_dot
          data:
            type: tts
      cube_flip_4:
      - service: notify.alexa_media
        data:
          message: Four
          target: media_player.user_s_echo_dot
          data:
            type: tts
      cube_flip_5:
      - service: notify.alexa_media
        data:
          message: Five
          target: media_player.user_s_echo_dot
          data:
            type: tts
      cube_flip_6:
      - service: notify.alexa_media
        data:
          message: Six
          target: media_player.user_s_echo_dot
          data:
            type: tts
      rotate_left_side_1:
      - service: light.turn_on
        target:
          area_id: office
        data_template:
          brightness_step: '{{ relative_degrees | float }}'
      rotate_right_side_1:
      - service: light.turn_on
        target:
          area_id: office
        data_template:
          brightness_step: '{{ relative_degrees | float }}'
3 Likes

Hey this looks like it will do exactly what I am looking for. I am however very new to HA and was wondering if you could just give me an example how the number helper would work. What lines were required etc. I am a once I see it I can understand how to do the rest but the big thing is tracking the sides which is the big functionality.

Really Appreciate it and looks great!

Thanks very great work!
I have tested for rotate face and it works but if try to use knock face option seems to not work.
There is some special flag to use “knock” face feature?
Thanks so much

You can create an input number helper in HomeAssistant’s UI. Just go to Configuration → Helpers and create a “Number” helper. You can then reference this in the automation in the UI.

The knock detection on the cube is kind of flaky - I find that I have to pick up the cube and then hit it against the desk 3 times to trigger it somewhat consistently.

Excellent work! Thank you!

Yes you are right, now if pick up and then i hit it it works!! So thanks so much and sorry…!