This is just another Blueprint for controlling the Aqara Cube, and I’ve build this inspired by many other Blueprints available:
- ZHA - Aqara Magic Cube (57 actions)
- Aqara Magic Cube ZHA (51 actions)
- ZHA - Aqara Magic Cube (24 actions)
Zigbee integration: ZHA
I developed this when looking for a remote to control all the devices in my home-office room (and some nearby devices that might bother me during a call), but as this cube have lots of possibilities, the majority of integrations available was too complex to my brain, focusing a lot on which side was moved from… I just wanna one device per face (I will have an stick with the respective icon on each face), and the capabilities to do basic control on those devices.
This is my example (you can set the devices and actions as you want):
Face up | Device | Knock | Counter-clockwise | Clockwise |
---|---|---|---|---|
1 | Workstation light | Toggle light | Decrease brightness | Increase brightness |
2 | Workstation power | Toggle power | N/A | N/A |
3 | Roomba | Start/stop cleaning | Go home (when stopped) | N/A |
4 | Ceiling lights | Toggle light | Decrease brightness | Increase brightness |
5 | Curtain | Toggle curtain | Close 1 step | Open 1 step |
6 | TV Living room | Toggle TV | Volume down | Volume up |
So, in order to use this Blueprint you need an Aqara Cube and to create a helper to temporary store the last face up (as the cube don’t report the face up when rotating).
You can create this helper (it’s super easy) going to Configuration > Automation & Scenes, then select the tab “Helpers” (in the top), click on “+ Add Helper” and select “Number”:
You don’t have to spend too much time on this as only the name is required now, but if you want customize something else, make sure to allow numbers from 0 to 6 at least.
When you have the Cube and the helper set, just create a new automation from the Blueprint and have fun.
Change log:
- 2022-02-05 10:59 UTC:
- First time published
- 2022-05-17 06:50 UTC:
- Added relative_degrees to track the rotating angle.
This is the Blueprint:
blueprint:
name: Aqara Cube face-based
description: Control devices based on the cube's face.
domain: automation
input:
last_face_input:
name: Last face up numeric helper
description: Please select a Numeric Helper to be used to record the last face up.
selector:
entity:
domain: input_number
cube:
name: Aqara Cube
description: Select the Aqara Cube device
selector:
device:
integration: zha
manufacturer: LUMI
face_1_flip:
name: Flip to face 1
description: Actions to execute when the cube is flipped to face 1 in the top.
default: []
selector:
action: {}
face_1_knock:
name: Knock face 1
description: Actions to execute when the cube is knocked with face 1 in the top.
default: []
selector:
action: {}
face_1_rotate_counter_clockwise:
name: Rotate counter-clockwise face 1
description: Actions to execute when the cube rotates counter-clockwise with face 1 in the top.
default: []
selector:
action: {}
face_1_rotate_clockwise:
name: Rotate clockwise face 1
description: Actions to execute when the cube rotates clockwise with face 1 in the top.
default: []
selector:
action: {}
face_1_slide:
name: Slide face 1
description: Actions to execute when the cube slides with face 1 in the top.
default: []
selector:
action: {}
face_2_flip:
name: Flip to face 2
description: Actions to execute when the cube is flipped to face 2 in the top.
default: []
selector:
action: {}
face_2_knock:
name: Knock face 2
description: Actions to execute when the cube is knocked with face 2 in the top.
default: []
selector:
action: {}
face_2_rotate_counter_clockwise:
name: Rotate counter-clockwise face 2
description: Actions to execute when the cube rotates counter-clockwise with face 2 in the top.
default: []
selector:
action: {}
face_2_rotate_clockwise:
name: Rotate clockwise face 2
description: Actions to execute when the cube rotates clockwise with face 2 in the top.
default: []
selector:
action: {}
face_2_slide:
name: Slide face 2
description: Actions to execute when the cube slides with face 2 in the top.
default: []
selector:
action: {}
face_3_flip:
name: Flip to face 3
description: Actions to execute when the cube is flipped to face 3 in the top.
default: []
selector:
action: {}
face_3_knock:
name: Knock face 3
description: Actions to execute when the cube is knocked with face 3 in the top.
default: []
selector:
action: {}
face_3_rotate_counter_clockwise:
name: Rotate counter-clockwise face 3
description: Actions to execute when the cube rotates counter-clockwise with face 3 in the top.
default: []
selector:
action: {}
face_3_rotate_clockwise:
name: Rotate clockwise face 3
description: Actions to execute when the cube rotates clockwise with face 3 in the top.
default: []
selector:
action: {}
face_3_slide:
name: Slide face 3
description: Actions to execute when the cube slides with face 3 in the top.
default: []
selector:
action: {}
face_4_flip:
name: Flip to face 4
description: Actions to execute when the cube is flipped to face 4 in the top.
default: []
selector:
action: {}
face_4_knock:
name: Knock face 4
description: Actions to execute when the cube is knocked with face 4 in the top.
default: []
selector:
action: {}
face_4_rotate_counter_clockwise:
name: Rotate counter-clockwise face 4
description: Actions to execute when the cube rotates counter-clockwise with face 4 in the top.
default: []
selector:
action: {}
face_4_rotate_clockwise:
name: Rotate clockwise face 4
description: Actions to execute when the cube rotates clockwise with face 4 in the top.
default: []
selector:
action: {}
face_4_slide:
name: Slide face 4
description: Actions to execute when the cube slides with face 4 in the top.
default: []
selector:
action: {}
face_5_flip:
name: Flip to face 5
description: Actions to execute when the cube is flipped to face 5 in the top.
default: []
selector:
action: {}
face_5_knock:
name: Knock face 5
description: Actions to execute when the cube is knocked with face 5 in the top.
default: []
selector:
action: {}
face_5_rotate_counter_clockwise:
name: Rotate counter-clockwise face 5
description: Actions to execute when the cube rotates counter-clockwise with face 5 in the top.
default: []
selector:
action: {}
face_5_rotate_clockwise:
name: Rotate clockwise face 5
description: Actions to execute when the cube rotates clockwise with face 5 in the top.
default: []
selector:
action: {}
face_5_slide:
name: Slide face 5
description: Actions to execute when the cube slides with face 5 in the top.
default: []
selector:
action: {}
face_6_flip:
name: Flip to face 6
description: Actions to execute when the cube is flipped to face 6 in the top.
default: []
selector:
action: {}
face_6_knock:
name: Knock face 6
description: Actions to execute when the cube is knocked with face 6 in the top.
default: []
selector:
action: {}
face_6_rotate_counter_clockwise:
name: Rotate counter-clockwise face 6
description: Actions to execute when the cube rotates counter-clockwise with face 6 in the top.
default: []
selector:
action: {}
face_6_rotate_clockwise:
name: Rotate clockwise face 6
description: Actions to execute when the cube rotates clockwise with face 6 in the top.
default: []
selector:
action: {}
face_6_slide:
name: Slide face 6
description: Actions to execute when the cube slides with face 6 in the top.
default: []
selector:
action: {}
source_url: https://community.home-assistant.io/t/aqara-cube-zha-simplified-face-based-device-control/388850
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input cube
action:
- variables:
command: '{{ trigger.event.data.command }}'
value: '{{ trigger.event.data.args.value | default(0) }}'
flip_degrees: '{{ trigger.event.data.args.flip_degrees | default(0) }}'
relative_degrees: '{{ trigger.event.data.args.relative_degrees | default(0) }}'
temp_last_face_input: !input last_face_input
activated_face: '{{ iif((command == ''slide'' or command == ''knock'' or command == ''flip''), trigger.event.data.args.activated_face, states(temp_last_face_input)) | int(0) }}'
#activated_face: |-
#{% if command == 'slide' or command == 'knock' or command == 'flip' %}
#{{ trigger.event.data.args.activated_face | int(0) }}
#{% else %}
#{{ states(temp_last_face_input) | int(0) }}
#{% endif %}
- service: input_number.set_value
target:
entity_id: !input last_face_input
data:
value: '{{ activated_face }}'
- choose:
- conditions:
- '{{ activated_face == 1 }}'
sequence:
- choose:
- conditions:
- '{{ command == ''flip'' }}'
sequence: !input face_1_flip
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_1_knock
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_1_rotate_counter_clockwise
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input face_1_rotate_clockwise
- conditions:
- '{{ command == ''slide'' }}'
sequence: !input face_1_slide
default: []
- conditions:
- '{{ activated_face == 2 }}'
sequence:
- choose:
- conditions:
- '{{ command == ''flip'' }}'
sequence: !input face_2_flip
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_2_knock
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_2_rotate_counter_clockwise
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input face_2_rotate_clockwise
- conditions:
- '{{ command == ''slide'' }}'
sequence: !input face_2_slide
default: []
- conditions:
- '{{ activated_face == 3 }}'
sequence:
- choose:
- conditions:
- '{{ command == ''flip'' }}'
sequence: !input face_3_flip
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_3_knock
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_3_rotate_counter_clockwise
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input face_3_rotate_clockwise
- conditions:
- '{{ command == ''slide'' }}'
sequence: !input face_3_slide
default: []
- conditions:
- '{{ activated_face == 4 }}'
sequence:
- choose:
- conditions:
- '{{ command == ''flip'' }}'
sequence: !input face_4_flip
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_4_knock
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_4_rotate_counter_clockwise
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input face_4_rotate_clockwise
- conditions:
- '{{ command == ''slide'' }}'
sequence: !input face_4_slide
default: []
- conditions:
- '{{ activated_face == 5 }}'
sequence:
- choose:
- conditions:
- '{{ command == ''flip'' }}'
sequence: !input face_5_flip
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_5_knock
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_5_rotate_counter_clockwise
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input face_5_rotate_clockwise
- conditions:
- '{{ command == ''slide'' }}'
sequence: !input face_5_slide
default: []
- conditions:
- '{{ activated_face == 6 }}'
sequence:
- choose:
- conditions:
- '{{ command == ''flip'' }}'
sequence: !input face_6_flip
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_6_knock
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_6_rotate_counter_clockwise
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input face_6_rotate_clockwise
- conditions:
- '{{ command == ''slide'' }}'
sequence: !input face_6_slide
default: []
default: []