Xiaomi Gateway 3 - Aqara Magic Cube (9 Actions)

Aqara Magic Cube with Xiaomi Gateway 3

Basic blueprint for executing supported actions with the Aqara Magic Cube and Xiaomi Gateway 3 using original firmware.

Supports the following actions:

  • Wake
  • Double Tap
  • Move
  • Drop
  • Shake
  • Flip 90º
  • Flip 180º
  • Rotate Right
  • Rotate Left

Requirements:

Changelog:

  • 2022.01.25 - First Release
  • 2022.02.14 - Fix for v2.0.0 compatibility (some actions were renamed).

Soon - More Cube actions based on side

Blueprint Code

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

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

Or import this Blueprint by using the Gist URL:

https://gist.github.com/cvroque/0a7fcdd414ff366460353aef2a5e25db

Older version

If you’re on V1.6.5 or lower use the blueprint below:

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

Other blueprints for Xiaomi Gateway 3

(not by me)

[Xiaomi Gateway 3] Xiaomi Wireless Remote Switch (WXKG01LM) - Working DEC 2021

Sonoff Button SNZB-01 with Xiaomi Gateway 3

4 Likes

Thanks for the blueprint, works well. Xiaomi Gateway 3 Custom Integration it’s released to v2.0 with more action option for the cube.
Could you update the blueprint?

2 Likes

Hello! This one still functions normally, but I’m already working on the new actions and will update or release a new blueprint soon.

No , all movement don’t works. Move, now it’s Slide.
Good news :slight_smile:

Hey, I had some busy days, and you were right! A lot of stuff had stopped working. My most used (rotate and flip) were fine, but now I also fixed: wake up, slide, tapping, shaking and falling.

As for all the side validations, soon.

1 Like

thanks for update, but are missing actions. Each face has a number

ex:
Action flip90
From side 1
To side 0

It would not be possible to integrate the face number for more actions ?

Yes, I’m working on adding it, but it’s a lot of actions and complexity. I also want to be able to rotate based on side to change TV volume or lights brightness.

I know it’s hard to implement. But if you work on it that’s cool. Already 9 actions is good :slight_smile:

Hi,
I added slide and double tap on all sides, and now it’s been 19 actions. I’m going to add the flip90° and flip180° but it’s a lot of work. Wake Up, rotate, free fall and shake haven’t the infos for sides, impossible to exploit.

blueprint:
  name: Aqara Magic Cube with Xiaomi Gateway 3
  description: | 
  
    ## Aqara Magic Cube with Xiaomi Gateway 3
    Basic blueprint for executing supported actions with the Aqara Magic Cube and Xiaomi Gateway 3 using default firmware.
    
    Supports the following actions:
    - Wake
    - Double Tap
    - Move
    - Drop
    - Shake
    - Flip 90˚
    - Flip 180˚
    - Rotate Right
    - Rotate Left
    
    ### Requirements:
    - [Xiaomi Gateway 3 Integration][1] v2.0.0+
    - Official Firmware for the Gateway
    - Paired Aqara Magic Cube
    
    [1]: https://github.com/AlexxIT/XiaomiGateway3
  
  domain: automation
  input:
    trigger_entity:
      name: Aqara Magic Cube
      description: Choose Aqara Cube Action entity
      selector:
        entity:
          domain: sensor
          integration: xiaomi_gateway3
    alert:
      name: Wake
      description: Actions to run when cube wakes up (idle and you tap it)
      default: []
      selector:
        action: {}
    tap_twice_side0:
      name: Double Tap Side 0 Aqara Logo
      description: Actions to run when cube is tapped twice (hold it with your hands and tap it twice the table)
      default: []
      selector:
        action: {}
    tap_twice_side1:
      name: Double Tap Side 1
      description: Actions to run when cube is tapped twice (hold it with your hands and tap it twice the table)
      default: []
      selector:
        action: {}
    tap_twice_side2:
      name: Double Tap Side 2
      description: Actions to run when cube is tapped twice (hold it with your hands and tap it twice the table)
      default: []
      selector:
        action: {}
    tap_twice_side3:
      name: Double Tap Side 3
      description: Actions to run when cube is tapped twice (hold it with your hands and tap it twice the table)
      default: []
      selector:
        action: {}
    tap_twice_side4:
      name: Double Tap Side 4
      description: Actions to run when cube is tapped twice (hold it with your hands and tap it twice the table)
      default: []
      selector:
        action: {}
    tap_twice_side5:
      name: Double Tap Side 5
      description: Actions to run when cube is tapped twice (hold it with your hands and tap it twice the table)
      default: []
      selector:
        action: {}        
    move_side0:
      name: Move Side 0 Aqara Logo
      description: Actions to run when cube is moved (slide in any direction)
      default: []
      selector:
        action: {}
    move_side1:
      name: Move Side 1
      description: Actions to run when cube is moved (slide in any direction)
      default: []
      selector:
        action: {}
    move_side2:
      name: Move Side 2
      description: Actions to run when cube is moved (slide in any direction)
      default: []
      selector:
        action: {}
    move_side3:
      name: Move Side 3
      description: Actions to run when cube is moved (slide in any direction)
      default: []
      selector:
        action: {}
    move_side4:
      name: Move Side 4
      description: Actions to run when cube is moved (slide in any direction)
      default: []
      selector:
        action: {}
    move_side5:
      name: Move Side 5
      description: Actions to run when cube is moved (slide in any direction)
      default: []
      selector:
        action: {}
    free_fall:
      name: Drop
      description: Actions to run when cube is dropped (throw in the air and catch)
      default: []
      selector:
        action: {}
    shake_air:
      name: Shake
      description: Actions to run when cube is shaked (hold in your hands and shake)
      default: []
      selector:
        action: {}
    flip90:
      name: Flip 90º
      description: Actions to run when cube is flipped 90 degrees (flipped to any side)
      default: []
      selector:
        action: {}
    flip180:
      name: Flip 180º
      description: Actions to run when cube is flipped 180 degrees (flipped to the previous bottom side)
      default: []
      selector:
        action: {}
    rotate_right:
      name: Rotate Right
      description: Actions to run when cube is rotated right (turned clockwise)
      default: []
      selector:
        action: {}
    rotate_left:
      name: Rotate Left
      description: Actions to run when cube is rotated left (turned counter clockwise)
      default: []
      selector:
        action: {}
variables:
  action: '{{ trigger.to_state.state }}'
trigger:
  - platform: state
    entity_id: !input trigger_entity
condition: []
action:
  - choose:
      - conditions:
          - "{{ action == 'wakeup' }}"
        sequence: !input "alert"
      - conditions:
          - "{{ action == 'tap' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            below: '1'
        sequence: !input "tap_twice_side0"
      - conditions:
          - "{{ action == 'tap' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '0'            
            below: '2'
        sequence: !input "tap_twice_side1"
      - conditions:
          - "{{ action == 'tap' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '1'            
            below: '3'
        sequence: !input "tap_twice_side2"
      - conditions:
          - "{{ action == 'tap' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '2'            
            below: '4'
        sequence: !input "tap_twice_side3"
      - conditions:
          - "{{ action == 'tap' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '3'            
            below: '5'
        sequence: !input "tap_twice_side4"
      - conditions:
          - "{{ action == 'tap' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '4'            
            below: '6'
        sequence: !input "tap_twice_side5" 
      - conditions:
          - "{{ action == 'slide' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            below: '1'
        sequence: !input "move_side0"
      - conditions:
          - "{{ action == 'slide' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '0'            
            below: '2'
        sequence: !input "move_side1"
      - conditions:
          - "{{ action == 'slide' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '1'            
            below: '3'
        sequence: !input "move_side2"
      - conditions:
          - "{{ action == 'slide' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '2'            
            below: '4'
        sequence: !input "move_side3"
      - conditions:
          - "{{ action == 'slide' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '3'            
            below: '5'
        sequence: !input "move_side4"
      - conditions:
          - "{{ action == 'slide' }}"
          - condition: numeric_state
            entity_id: !input 'trigger_entity'
            attribute: side
            above: '4'            
            below: '6'
        sequence: !input "move_side5"
      - conditions:
          - "{{ action == 'fall' }}"
        sequence: !input "free_fall"
      - conditions:
          - "{{ action == 'shake' }}"
        sequence: !input "shake_air"
      - conditions:
          - "{{ action == 'flip90' }}"
        sequence: !input "flip90"
      - conditions:
          - "{{ action == 'flip180' }}"
        sequence: !input "flip180"
      - conditions:
          - "{{ action == 'rotate' }}"
          - condition: numeric_state
            entity_id: !input trigger_entity
            attribute: angle
            above: '0'
        sequence: !input "rotate_right"
      - conditions:
          - "{{ action == 'rotate' }}"
          - condition: numeric_state
            entity_id: !input trigger_entity
            attribute: angle
            below: '0'
        sequence: !input "rotate_left"
    default: []
mode: queued
max_exceeded: silent
2 Likes

Hello friend, nice work. My daughter arrived this week and I didn’t get a minute to sit at my computer, but we can keep track of sides using an helper outside the automation, such as a input number.

If you have a solution, I would wait for your work because I don’t see how to do it.

Hello, I would like to use this blueprints, but I have the first generation of Xiaomi Gateway with Mi Cube.
Do you think it’s possible to adapt this blueprint with this gateway ?

The integration used is “xiaomi_aqara”, the cube is a “binary_sensor” entity with attributes :
last_action: shake_air, rotate etc…
voltage: xxx
battery_level: xx
friendly_name: xxxx

Thanks in advance for your reply and tell me if it’s possible to adapt this blueprint by editig yaml :slight_smile: