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:
EDIT: Have looked into the actual “events” from the cube send. There is no trigger events when “turned arround in hand”, hence no way the blueprint can detect it. Sorry for not checking first.
This blueprint is perfect, however I have a issue with “people using the cube”
Im intending to use the “faceup” as a input for a number of other automations, like “daytime setting”, “Night time setting” and other “states the house can be in”. A small icon on each side and it will be easy for everybody to set the setting of the house. Even non-normal guests.
However, the cube does not always show the “flip to side”. It works if you flip to a side, however if people have the cube in the hand, turns it around to find the right side and then sets it on the table it does not work consistently.
The problem is that the cube sends a drop or turn command instead, and the “flip to side x” is not triggered.
Have anybody figured out how to remove all the other options, and only have a
“face side up” trigger. The flip to is perfect for this, if consistent.
EDIT: Have looked into the actual “events” from the cube send. There is no trigger events when “turned arround in hand”, hence no way the blueprint can detect it. Sorry for not checking first.
Great idea, and thank you! I’ve put it in the main post.
What am I missing?
You’re missing absolutely nothing. I didn’t use that feature from the blueprint I extended, so I didn’t test it. Turns out that part was a bit buggy. I’ve fixed it and tested.
Hi, I have a question related to this blueprint. I want to fire an event when the cube is rotated, and in event_data for this event pass relative_degress to use it somewhere else. Is it possible and how to achieve it?
I just updated the blueprint to populate the relative_degrees variable from the event_data. You can use it in any service template. It’s a float, so it will have the full decimal precision from the zha event.
I have extended this blueprint to allow for per-side rotation actions using an input number helper to track the active side from the last flip action (so it does suffer from the shortcomings that brent mentioned).
This also includes an example for how to use relative_degrees in an automation.
Hi, by using rvaidya blueprint I have developed another one, but in a much more simpler approach (only 24 actions, 6 sides * [rotate, flip, knock and slide])
Hi there,
I’ve an issue with creating an automation with this blueprint. I use MQTT. I paired the cube and it appears in my device list. I also see the events if I manipulate the cube.
But when I try to make an automation with the BP, I cannot select the cube for some reason. So far I never made an automation via a BP, so no idea what to do now.
ZHA performs checkin events for devices (see the ‘Logbook’), and when it does that for the Magic Cube, the automation using this blueprint is triggered. The cube itself is not generating events, and checkins for other devices exit fine.
When ZHA is checking for the cube however, there is an error in the core log at the exact same time:
Error in ‘choose[0]’ evaluation: In ‘template’ condition: TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
I am trying to use the rotation as a volume control, is there any way to increase the impact of each rotation? Increase or decrease the volume more for each rotation?
Thanks, awesome blueprint!!!
I get follow error : : Error: UndefinedError: ‘dict object’ has no attribute ‘event’
The cube is available in HA with Sonoff Zigbee 3.0 USB Dongle Plus - Sonoff Zigbee 3.0 ZBdongle-P
any idea ?
I know it’s an awfully long time since this was developed, however, I still use it because it’s simple, works and doesn’t need an extra input_boolean to keep track of the faces.
I thought I’d make sure other people know of a few little extras I’ve had to put in over time to keep it working.
Since things have changed in the Zigbee/HA world, I’ve had to do the following:
All instances of “from_face” need to be replaced with “deactivated_face”.
The blueprint is (inexplicably) missing code for the 90 degree flip from face one to four and from four to one.
I’ve spelled it out this way in case Brent decides to edit the available blueprint to the new version and people can see where the changes are.
Total New Code is:
blueprint:
name: Aqara Magic Cube
description: Control anything using Aqara Magic Cube.
domain: automation
input:
remote:
name: Magic Cube
description: Select the Aqara Magic Cube device
selector:
device:
integration: zha
manufacturer: LUMI
multiple: false
flip_90:
name: Flip 90 degrees
description: 'Actions to run when cube flips 90 degrees.
This cancels all specific 90 degrees functions.
e.g From side 1 to side 2 will be the same as from side 6 to side 2'
default: false
selector:
boolean: {}
cube_flip_90:
name: Flip cube 90 degrees
description: Action to run when cube flips 90 degrees. This only works if 'Flip
90 degrees' is toggled
default: []
selector:
action: {}
flip_180:
name: Flip 180 degrees
description: 'Actions to run when cube flips 180 degrees.
This cancels all specific 180 degrees functions
e.g From side 1 to side 4 will be the same as from side 5 to side 2'
default: false
selector:
boolean: {}
cube_flip_180:
name: Flip cube 180 degrees
description: Action to run when cube flips 180 degrees. This only works if 'Flip
180 degrees' is toggled
default: []
selector:
action: {}
flip_any:
name: Flip to any side
description: 'Actions to run when cube flips to any side.
This cares about the end side, but cancels all specific flip functions.
e.g From side 1 to side 2 will be the same as from side 6 to side 2
but different than side 1 to side 5'
default: false
selector:
boolean: {}
cube_flip_1:
name: Flip cube to side 1
description: Action to run when cube flips to side 1. This only works if 'Flip
any' is toggled
default: []
selector:
action: {}
cube_flip_2:
name: Flip cube to side 2
description: Action to run when cube flips to side 2. This only works if 'Flip
any' is toggled
default: []
selector:
action: {}
cube_flip_3:
name: Flip cube to side 3
description: Action to run when cube flips to side 3. This only works if 'Flip
any' is toggled
default: []
selector:
action: {}
cube_flip_4:
name: Flip cube to side 4
description: Action to run when cube flips to side 4. This only works if 'Flip
any' is toggled
default: []
selector:
action: {}
cube_flip_5:
name: Flip cube to side 5
description: Action to run when cube flips to side 5. This only works if 'Flip
any' is toggled
default: []
selector:
action: {}
cube_flip_6:
name: Flip cube to side 6
description: Action to run when cube flips to side 6. This only works if 'Flip
any' is toggled
default: []
selector:
action: {}
slide_any_side:
name: Slide any side
description: 'Actions to run when cube slides on any side.
This cancels all specific ''slide'' functions
e.g Slide on side 1 will be the same as slide on side 2'
default: false
selector:
boolean: {}
cube_slide_any:
name: Slide cube on any side
description: Action to run when cube slides on any slide. This only works if
'Slide any side' is toggled
default: []
selector:
action: {}
knock_any_side:
name: Knock on any side
description: 'Actions to run when knocking cube regardless of the side.
This cancels all specific ''knock'' functions
e.g Knock on side 1 will be the same as knocking side 2'
default: false
selector:
boolean: {}
cube_knock_any:
name: Knock cube on any side
description: Action to run when knocking cube on any side. This only works if
'Knock on any side' is toggled
default: []
selector:
action: {}
one_to_two:
name: From side 1 to side 2
description: Action to run when cube goes from side 1 to side 2
default: []
selector:
action: {}
one_to_three:
name: From side 1 to side 3
description: Action to run when cube goes from side 1 to side 3
default: []
selector:
action: {}
one_to_four:
name: From side 1 to side 4
description: Action to run when cube goes from side 1 to side 4
default: []
selector:
action: {}
one_to_five:
name: From side 1 to side 5
description: Action to run when cube goes from side 1 to side 5
default: []
selector:
action: {}
one_to_six:
name: From side 1 to side 6
description: Action to run when cube goes from side 1 to side 6
default: []
selector:
action: {}
two_to_one:
name: From side 2 to side 1
description: Action to run when cube goes from side 2 to side 1
default: []
selector:
action: {}
two_to_three:
name: From side 2 to side 3
description: Action to run when cube goes from side 2 to side 3
default: []
selector:
action: {}
two_to_four:
name: From side 2 to side 4
description: Action to run when cube goes from side 2 to side 4
default: []
selector:
action: {}
two_to_five:
name: From side 2 to side 5
description: Action to run when cube goes from side 2 to side 5
default: []
selector:
action: {}
two_to_six:
name: From side 2 to side 6
description: Action to run when cube goes from side 2 to side 6
default: []
selector:
action: {}
three_to_one:
name: From side 3 to side 1
description: Action to run when cube goes from side 3 to side 1
default: []
selector:
action: {}
three_to_two:
name: From side 3 to side 2
description: Action to run when cube goes from side 3 to side 2
default: []
selector:
action: {}
three_to_four:
name: From side 3 to side 4
description: Action to run when cube goes from side 3 to side 4
default: []
selector:
action: {}
three_to_five:
name: From side 3 to side 5
description: Action to run when cube goes from side 3 to side 5
default: []
selector:
action: {}
three_to_six:
name: From side 3 to side 6
description: Action to run when cube goes from side 3 to side 6
default: []
selector:
action: {}
four_to_one:
name: From side 4 to side 1
description: Action to run when cube goes from side 4 to side 1
default: []
selector:
action: {}
four_to_two:
name: From side 4 to side 2
description: Action to run when cube goes from side 4 to side 2
default: []
selector:
action: {}
four_to_three:
name: From side 4 to side 3
description: Action to run when cube goes from side 4 to side 3
default: []
selector:
action: {}
four_to_five:
name: From side 4 to side 5
description: Action to run when cube goes from side 4 to side 5
default: []
selector:
action: {}
four_to_six:
name: From side 4 to side 6
description: Action to run when cube goes from side 4 to side 6
default: []
selector:
action: {}
five_to_one:
name: From side 5 to side 1
description: Action to run when cube goes from side 5 to side 1
default: []
selector:
action: {}
five_to_two:
name: From side 5 to side 2
description: Action to run when cube goes from side 5 to side 2
default: []
selector:
action: {}
five_to_three:
name: From side 5 to side 3
description: Action to run when cube goes from side 5 to side 3
default: []
selector:
action: {}
five_to_four:
name: From side 5 to side 4
description: Action to run when cube goes from side 5 to side 4
default: []
selector:
action: {}
five_to_six:
name: From side 5 to side 6
description: Action to run when cube goes from side 5 to side 6
default: []
selector:
action: {}
six_to_one:
name: From side 6 to side 1
description: Action to run when cube goes from side 6 to side 1
default: []
selector:
action: {}
six_to_two:
name: From side 6 to side 2
description: Action to run when cube goes from side 6 to side 2
default: []
selector:
action: {}
six_to_three:
name: From side 6 to side 3
description: Action to run when cube goes from side 6 to side 3
default: []
selector:
action: {}
six_to_four:
name: From side 6 to side 4
description: Action to run when cube goes from side 6 to side 4
default: []
selector:
action: {}
six_to_five:
name: From side 6 to side 5
description: Action to run when cube goes from side 6 to side 5
default: []
selector:
action: {}
one_to_one:
name: Knock - Side 1
description: Action to run when knocking on side 1
default: []
selector:
action: {}
two_to_two:
name: Knock - Side 2
description: Action to run when knocking on side 2
default: []
selector:
action: {}
three_to_three:
name: Knock - Side 3
description: Action to run when knocking on side 3
default: []
selector:
action: {}
four_to_four:
name: Knock - Side 4
description: Action to run when knocking on side 4
default: []
selector:
action: {}
five_to_five:
name: Knock - Side 5
description: Action to run when knocking on side 5
default: []
selector:
action: {}
six_to_six:
name: Knock - Side 6
description: Action to run when knocking on side 6
default: []
selector:
action: {}
slide_on_one:
name: Slide - Side 1 up
description: Action to run when slides with Side 1 up
default: []
selector:
action: {}
slide_on_two:
name: Slide - Side 2 up
description: Action to run when slides with Side 2 up
default: []
selector:
action: {}
slide_on_three:
name: Slide - Side 3 up
description: Action to run when slides with Side 3 up
default: []
selector:
action: {}
slide_on_four:
name: Slide - Side 4 up
description: Action to run when slides with Side 4 up
default: []
selector:
action: {}
slide_on_five:
name: Slide - Side 5 up
description: Action to run when slides with Side 5 up
default: []
selector:
action: {}
slide_on_six:
name: Slide - Side 6 up
description: Action to run when slides with Side 6 up
default: []
selector:
action: {}
cube_wake:
name: Wake up the cube
description: Action to run when cube wakes up
default: []
selector:
action: {}
cube_drop:
name: Cube drops
description: Action to run when cube drops
default: []
selector:
action: {}
cube_shake:
name: Shake cube
description: Action to run when you shake the cube
default: []
selector:
action: {}
rotate_right:
name: Rotate right
description: Action to run when cube rotates right
default: []
selector:
action: {}
rotate_left:
name: Rotate left
description: Action to run when cube rotates left
default: []
selector:
action: {}
source_url: https://community.home-assistant.io/t/zha-aqara-magic-cube-57-actions/297012
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
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) }}'
flip_any: !input flip_any
flip_90: !input flip_90
flip_180: !input flip_180
slide_any_side: !input slide_any_side
knock_any_side: !input knock_any_side
flip90: 64
flip180: 128
slide: 256
knock: 512
shake: 0
drop: 3
activated_face: "\n{% if command == \"slide\" or command == \"knock\" %}\n\n {%
if trigger.event.data.args.activated_face == 1 %} 1\n\n {% elif trigger.event.data.args.activated_face
== 2 %} 5\n\n {% elif trigger.event.data.args.activated_face == 3 %} 6\n\n
\ {% elif trigger.event.data.args.activated_face == 4 %} 4\n\n {% elif trigger.event.data.args.activated_face
== 5 %} 2\n\n {% elif trigger.event.data.args.activated_face == 6 %} 3\n\n
\ {% endif %}\n\n{% elif command == 'flip' %}\n\n {{ trigger.event.data.args.activated_face
| int }}\n\n{% endif %}\n"
deactivated_face: "\n{% if command == \"flip\" and flip_degrees == 90 %}\n\n {{ ((value
- flip90 - (trigger.event.data.args.activated_face - 1)) / 8) + 1 | int }}\n\n{%
endif %}\n"
relative_degrees: "\n{% if command == \"rotate_right\" or command == \"rotate_left\"
%}\n\n {{ trigger.event.data.args.relative_degrees | float }}\n\n{% endif %}\n"
- choose:
- conditions:
- '{{ command == ''rotate_right'' }}'
sequence: !input rotate_right
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input rotate_left
- conditions:
- '{{ command == ''checkin'' }}'
sequence: !input cube_wake
- conditions:
- '{{ value == shake }}'
sequence: !input cube_shake
- conditions:
- '{{ value == drop }}'
sequence: !input cube_drop
- conditions:
- '{{ command == ''knock'' and knock_any_side }}'
sequence: !input cube_knock_any
- conditions:
- '{{ command == ''slide'' and slide_any_side }}'
sequence: !input cube_slide_any
- conditions:
- '{{ command == ''flip'' and flip_any }}'
sequence:
- choose:
- conditions: '{{ activated_face == 1 }}'
sequence: !input cube_flip_1
- conditions: '{{ activated_face == 2 }}'
sequence: !input cube_flip_2
- conditions: '{{ activated_face == 3 }}'
sequence: !input cube_flip_3
- conditions: '{{ activated_face == 4 }}'
sequence: !input cube_flip_4
- conditions: '{{ activated_face == 5 }}'
sequence: !input cube_flip_5
- conditions: '{{ activated_face == 6 }}'
sequence: !input cube_flip_6
- conditions:
- '{{ flip_degrees == 90 and flip_90 }}'
sequence: !input cube_flip_90
- conditions:
- '{{ flip_degrees == 180 and flip_180 }}'
sequence: !input cube_flip_180
- conditions:
- '{{ flip_degrees == 90 and activated_face == 1 }}'
sequence:
- choose:
- conditions: '{{ deactivated_face == 2 }}'
sequence: !input two_to_one
- conditions: '{{ deactivated_face == 3 }}'
sequence: !input three_to_one
- conditions: '{{ deactivated_face == 4 }}'
sequence: !input four_to_one
- conditions: '{{ deactivated_face == 5 }}'
sequence: !input five_to_one
- conditions: '{{ deactivated_face == 6 }}'
sequence: !input six_to_one
- conditions:
- '{{ flip_degrees == 90 and activated_face == 2 }}'
sequence:
- choose:
- conditions: '{{ deactivated_face == 1 }}'
sequence: !input one_to_two
- conditions: '{{ deactivated_face == 3 }}'
sequence: !input three_to_two
- conditions: '{{ deactivated_face == 4 }}'
sequence: !input four_to_two
- conditions: '{{ deactivated_face == 6 }}'
sequence: !input six_to_two
- conditions:
- '{{ flip_degrees == 90 and activated_face == 3 }}'
sequence:
- choose:
- conditions: '{{ deactivated_face == 1 }}'
sequence: !input one_to_three
- conditions: '{{ deactivated_face == 2 }}'
sequence: !input two_to_three
- conditions: '{{ deactivated_face == 4 }}'
sequence: !input four_to_three
- conditions: '{{ deactivated_face == 5 }}'
sequence: !input five_to_three
- conditions:
- '{{ flip_degrees == 90 and activated_face == 4 }}'
sequence:
- choose:
- conditions: '{{ deactivated_face == 1 }}'
sequence: !input one_to_four
- conditions: '{{ deactivated_face == 2 }}'
sequence: !input two_to_four
- conditions: '{{ deactivated_face == 3 }}'
sequence: !input three_to_four
- conditions: '{{ deactivated_face == 5 }}'
sequence: !input five_to_four
- conditions: '{{ deactivated_face == 6 }}'
sequence: !input six_to_four
- conditions:
- '{{ flip_degrees == 90 and activated_face == 5 }}'
sequence:
- choose:
- conditions: '{{ deactivated_face == 1 }}'
sequence: !input one_to_five
- conditions: '{{ deactivated_face == 3 }}'
sequence: !input three_to_five
- conditions: '{{ deactivated_face == 4 }}'
sequence: !input four_to_five
- conditions: '{{ deactivated_face == 6 }}'
sequence: !input six_to_five
- conditions:
- '{{ flip_degrees == 90 and activated_face == 6 }}'
sequence:
- choose:
- conditions: '{{ deactivated_face == 1 }}'
sequence: !input one_to_six
- conditions: '{{ deactivated_face == 2 }}'
sequence: !input two_to_six
- conditions: '{{ deactivated_face == 4 }}'
sequence: !input four_to_six
- conditions: '{{ deactivated_face == 5 }}'
sequence: !input five_to_six
- conditions:
- '{{ value == flip180 + activated_face - 1 }}'
sequence:
- choose:
- conditions: '{{ activated_face == 1 }}'
sequence: !input four_to_one
- conditions: '{{ activated_face == 2 }}'
sequence: !input five_to_two
- conditions: '{{ activated_face == 3 }}'
sequence: !input six_to_three
- conditions: '{{ activated_face == 4 }}'
sequence: !input one_to_four
- conditions: '{{ activated_face == 5 }}'
sequence: !input two_to_five
- conditions: '{{ activated_face == 6 }}'
sequence: !input three_to_six
- conditions:
- '{{ command == ''knock'' and not knock_any_side }}'
sequence:
- choose:
- conditions: '{{ activated_face == 1 }}'
sequence: !input one_to_one
- conditions: '{{ activated_face == 2 }}'
sequence: !input two_to_two
- conditions: '{{ activated_face == 3 }}'
sequence: !input three_to_three
- conditions: '{{ activated_face == 4 }}'
sequence: !input four_to_four
- conditions: '{{ activated_face == 5 }}'
sequence: !input five_to_five
- conditions: '{{ activated_face == 6 }}'
sequence: !input six_to_six
- conditions:
- '{{ value == slide + activated_face - 1 }}'
sequence:
- choose:
- conditions: '{{ activated_face == 1 }}'
sequence: !input slide_on_one
- conditions: '{{ activated_face == 2 }}'
sequence: !input slide_on_two
- conditions: '{{ activated_face == 3 }}'
sequence: !input slide_on_three
- conditions: '{{ activated_face == 4 }}'
sequence: !input slide_on_four
- conditions: '{{ activated_face == 5 }}'
sequence: !input slide_on_five
- conditions: '{{ activated_face == 6 }}'
sequence: !input slide_on_six
Or you can use mine. I keep mine maintained. There will be a release next week for all 20 of mine or sooner with some of the updates from the latest HA release 2024.6.
The input section of blueprints are going to be labeled and collapsed to make things less confusing for users and simpler to use.