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
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 }}'