That is simply an action sensor called by te zigbee stuff. It’s a Home Assistant script.
If ZHA has the angle as an attribute, that is the input and the rest should be close.
That is simply an action sensor called by te zigbee stuff. It’s a Home Assistant script.
If ZHA has the angle as an attribute, that is the input and the rest should be close.
I was about to try Z2M when I got this cube and couldn’t find so much material, but in the end I invested a bit more time to learn a bit more on how to work with events and discovered I can have very similar capabilities with ZHA, with an smoother user experience, so I decided to stay.
Maybe I can help you here… What you want is that Blueprint converted for ZHA?
On my Blueprint I don’t take in account the “from” side, I just use the side the needed showing up after each action.
Sometimes simplicity the best solultion, I can guarantee you that if I start talking about angles to control devices with my wife, she is going to through that cube out the window.
I think in my household, I will be using both your blueprints
thanks again for your awesome dev work here!!
From side that were not flip actions was fun. I happened to notice that if you were really careful you could get it into that mode. It is completely impractical, however. Not useful beyond a ‘secret’ way to activate a trigger for something…
I mostly added it so I could say there were over 100 ways to trigger it… (albeit some ridiculous…)
Anything anyone wants to take from my code into their code go right ahead. Attribution is nice but not required…
If someone can think of a tweak for mine suggest away.
Of course any copy of your Blueprint will require giving you the credits.
My point is more that “convert” a Blueprint originally designed to Z2MQTT in a way it can work with ZHA is not a big issue.
And I’m not sharing my Blueprint to compete with other Blueprint. I’m doing this in order to support someone who could have a similar use case that I had. It is a collaboration mindset, not a competitive mindset.
And if someone need help converting an existing Blueprint designed to Z2MQTT into a ZHA Blueprint I can help.
I’m not gonna offer to do the opposite by the simple fact that I don’t have a Z2MQTT environment to run my tests.
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?