Go for it. Glad to share.
I have an old sonoff Zigbee V1 brick that someday I’m going it install ZHA for testing and porting stuff, but It hasn’t happened yet. Maybe late fall. So go right ahead.
Flip degrees is 90, 180 and not the rotation degrees
That’s right, @mouth4war, the rotation will be on relative_degrees, which I think is not included in this Blueprint. Thanks for catching that.
"command": "rotate_right",
"args": {
"relative_degrees": 76.14999389648438
I will take a look if I can add this info to the blueprint.
Ok, the value is available on trigger.event.data.args.relative_degrees. I’ve added this to the blueprint.
Noticed a bug. When I double tap on face 2 it changes the helper to 5.
Hi @mouth4wa, are you sure about this? I couldn’t reproduce what you are saying and basically the blueprint will use the face info it is receiving from the event.
The face numbering is a but tricky and I believe the best representation I found was this on from this other Blueprint: ZHA - Aqara Magic Cube (57 actions), which is also just using the info received by the event (from the Zigbee integration).
Ive reported an issue for the face reporting on knock events.
Hi @EdwardTFN
I can confirm the bug in the Aqara Cube ZHA integration and just now submitted diagnostic info to the code author on the issue reported by @mouth4war.
For the meantime, I’ve updated your blueprint to use only flip
event which reports the correct side to store the input_helper.
activated_face: '{{ iif((command == ''flip''), trigger.event.data.args.activated_face, states(temp_last_face_input)) | int(0) }}'
This seems to temporarily resolve the issue as it can still use the active face number from the last flip
event.
An advanced code may be written to invert the code for knock
/slide
reported values to increase the update frequency of the input_helper.
Even before I try using this blueprint, I have to appreciate the effort you made in writing a great description! It has links to similar blueprints that inspired yours (and that might be better suited for some use-cases), it has a clear example on how you use your device (and thus what to expect from the blueprint), and it has clear instructions with screenshots on how to setup the helper entity, it even has a changelog! It’s only missing a screenshot of the blueprint itself, but I’m not complaining, because you did beyond what most people do. And I recognize this effort, as you made it easier for new users to understand the required steps. Congratulations!
I did one modification to your blueprint: I’ve added a “neutral” rotation action. This can be very powerful together with {{ relative_degrees }}
. In my case, I set one face to change the brightness, and the other to change the color temperature. Like this:
- id: '1234567890123'
alias: Remote - Aqara Cube - Living room
description: ''
use_blueprint:
path: EdwardTFN/aqara-cube-zha-simplified-face-based-device-control-remix.yaml
input:
last_face_input: input_number.aqara_cube_1_last_face
cube: 6ce360c004dda1bf7f25e54e543aa1c5
face_1_rotate:
- service: light.turn_on
data:
brightness: '{{ (state_attr(''light.living_room'', ''brightness'') or 0)
+ (relative_degrees * 255 / 360 / 2) }}'
target:
entity_id: light.living_room
face_2_rotate:
- service: light.turn_on
data:
color_temp: "{{ min(\n max(\n (\n (state_attr('light.living_room',
'color_temp') or 0)\n + (relative_degrees * 200 / 360)\n ),\n
\ state_attr('light.living_room', 'min_mireds') or 0\n ),\n state_attr('light.living_room',
'max_mireds') or 1000\n )\n}}"
target:
entity_id: light.living_room
This means subtle rotations will change less than longer rotations. And since {{ relative_degrees }}
can be positive or negative, I don’t need separate actions for left/right rotations.
As my next step, I should move all that logic (to increase/decrease brightness or color_temp) into a script, to make it easier to call. Maybe even a blueprint of a script.
Here are my changes, feel free to incorporate into your blueprint.
EDIT! These changes are incorrect! By applying these changes, the “neutral” rotation is called but the specific direction actions are never called. That’s my mistake because I didn’t realize the whole block was inside a choose
. Oops.
--- aqara-cube-zha-simplified-face-based-device-control.yaml
+++ aqara-cube-zha-simplified-face-based-device-control-remix.yaml
@@ -1,6 +1,13 @@
blueprint:
- name: Aqara Cube face-based
- description: Control devices based on the cube's face.
+ name: Aqara Cube face-based (remix)
+ description: |-
+ Control devices based on the cube's face.
+
+ The following variables are available in the templates:
+ * `{{ relative_degrees }}`: Negative number for `rotate_left` and positive number for `rotate_right`.
+ * `{{ flip_degrees }}`: Either `90` or `180` for `flip` commands, or `0` for other commands.
+ * `{{ command }}`: The action being performed with the cube. You probably don't need this in your template.
+ * `{{ activated_face }}`: The current cube face, or the last known face. You probably don't need this in your
template.
domain: automation
input:
last_face_input:
@@ -32,6 +39,13 @@
default: []
selector:
action: {}
+ face_1_rotate:
+ name: Rotate (any direction) face 1
+ description: Actions to execute when the cube rotates in any direction 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
@@ -65,6 +79,13 @@
default: []
selector:
action: {}
+ face_2_rotate:
+ name: Rotate (any direction) face 2
+ description: Actions to execute when the cube rotates in any direction 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
@@ -98,6 +119,13 @@
default: []
selector:
action: {}
+ face_3_rotate:
+ name: Rotate (any direction) face 3
+ description: Actions to execute when the cube rotates in any direction 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
@@ -131,6 +159,13 @@
default: []
selector:
action: {}
+ face_4_rotate:
+ name: Rotate (any direction) face 4
+ description: Actions to execute when the cube rotates in any direction 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
@@ -164,6 +199,13 @@
default: []
selector:
action: {}
+ face_5_rotate:
+ name: Rotate (any direction) face 5
+ description: Actions to execute when the cube rotates in any direction 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
@@ -197,6 +239,13 @@
default: []
selector:
action: {}
+ face_6_rotate:
+ name: Rotate (any direction) face 6
+ description: Actions to execute when the cube rotates in any direction 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
@@ -252,6 +301,9 @@
- '{{ command == ''knock'' }}'
sequence: !input face_1_knock
- conditions:
+ - '{{ command == ''rotate_left'' or command == ''rotate_right'' }}'
+ sequence: !input face_1_rotate
+ - conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_1_rotate_counter_clockwise
- conditions:
@@ -272,6 +324,9 @@
- '{{ command == ''knock'' }}'
sequence: !input face_2_knock
- conditions:
+ - '{{ command == ''rotate_left'' or command == ''rotate_right'' }}'
+ sequence: !input face_2_rotate
+ - conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_2_rotate_counter_clockwise
- conditions:
@@ -292,6 +347,9 @@
- '{{ command == ''knock'' }}'
sequence: !input face_3_knock
- conditions:
+ - '{{ command == ''rotate_left'' or command == ''rotate_right'' }}'
+ sequence: !input face_3_rotate
+ - conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_3_rotate_counter_clockwise
- conditions:
@@ -312,6 +370,9 @@
- '{{ command == ''knock'' }}'
sequence: !input face_4_knock
- conditions:
+ - '{{ command == ''rotate_left'' or command == ''rotate_right'' }}'
+ sequence: !input face_4_rotate
+ - conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_4_rotate_counter_clockwise
- conditions:
@@ -332,6 +393,9 @@
- '{{ command == ''knock'' }}'
sequence: !input face_5_knock
- conditions:
+ - '{{ command == ''rotate_left'' or command == ''rotate_right'' }}'
+ sequence: !input face_5_rotate
+ - conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_5_rotate_counter_clockwise
- conditions:
@@ -351,6 +415,9 @@
- conditions:
- '{{ command == ''knock'' }}'
sequence: !input face_6_knock
+ - conditions:
+ - '{{ command == ''rotate_left'' or command == ''rotate_right'' }}'
+ sequence: !input face_6_rotate
- conditions:
- '{{ command == ''rotate_left'' }}'
sequence: !input face_6_rotate_counter_clockwise
Or you could adapt this Dimmer to ZHA…
or this color change…
And use those scripts.
Just have to get the triggered angle out to the script.
Thank you very much for this awesome blue-print. So far Ive managed to connect 3 lightgroups to 3 different sides and controlling scenes on them by sliding. Managing saturation by turning clockwise/counterclockwise and toggling on and off.
Unfortunately Ive been unable to add my favorite radio station towards one side.
What I would like is on side X tapping it would toggle play/stop my favorite radio channel. While turning would adjust volume and perhaps if its even possible let slide swap between a set of like 3 music channels.
Anyone know how to realise this? Thank you in advance!
What kind of element you use to control your radio? Which integration?
Im a big rookie to HA. Im not sure what exactly you are asking. Ive used 3 scenes to toggle between radio channels within HA itself. And I use " radio browser" and a lovelace card to control.
If there is an easier way to get it connected to the cube im all ears. I havent figured it out yet.
You have answered my question… Your integration is Radio Browser.
I will take a look and come back to you…
Radio Browser will be playing in a Media Player entity, so you can use services media_player.toggle
, media_player.volume_up
and media_player.volume_down
in other to control it.
Something like this:
thnx for your assistance. I managed to turn on/off power by tapping the cube.
volume regulation by rotating clock/counter
swapping between channels by toggling between scripts of each radio channel with the swipe action.
Yet im not able to toggle the power AND resume the last channel it was playing.
EDIT I have managed to let it start with a radio channel allready playing. Yet the toggling between the different channels isnt going as smoothly. it either just randomly selects another channel or even the same one. I tried to create a helper/scene where it should run the 3 different scripts for the channels but it fails to start the script on activating the scene.
Don’t you wanna share some of your code so we can take a look and try to get ideas?
Can anyone confirm whether or not this blueprint will also fully work with the new Aqara Cube T1 Pro?