🧯 Zigbee2MQTT Aqara Magic Cube T1-Pro CTP-R01 Xiaomi Lumi cagl02

hI,
i’ve been watching the MQTT and noticed my cube seems to update the last side and then clear it


it logs the last side then clears it

I notice the automation runs twice one completes the action i created and the other stops on a condition.

looking the trace when it first runs I notice it skips the last side part of the automation

That last side entity is only updated for some of the moves. It is the one that the cube provides. If you are automating against last side I suggest you use the one I create and mentioned above. I provide it on every move.

Z2m has at minimum 3 triggers everytime you do something, a wake-up, the actual trigger, and another null trigger after that. Sometimes there’s even more…
That’s why my blueprint does some of the stuff it does.

Sorry I thought this was linked to why it’s not capturing the last side

as you can see it’s skipping the last side

edit here is the helper which is away blank

If you think there is an issue with the blueprint, and I can’t really tell here, please put your thoughts and data together and do an issue for me. We can sort it out over there.
This is the first report but that doesn’t mean something hasn’t changed.

1 Like

Posted,

thank you for your support I really appericate it

Hi James,

So I was trying to use to the " Z2M_Cube_Dimmer_Control_Stub_Actions_and_Script_SAMPLE.yaml"" - I am fairly new to homeasistant so got a little confused - so if I understood it correctly the script has two parts, the top part I added under actions (CW 3 side Up) Template condition -

/rotate_cw_face_3:

  • service: script.cube_dimmer_control_5
    data:
    angle: ‘{{ trigger.payload_json.action_angle | float(0.0)}}’
    light: light.tv_light
    rotate_ccw_face_3:
  • service: script.cube_dimmer_control_5
    data:
    angle: ‘{{ trigger.payload_json.action_angle | float(0.0)}}’
    light: light.tv_light/

the bottom part of the script (heavy lifter) I added to my script.yaml file
/script:
cube_dimmer_control_5:
description: Template Dimmer Control
variables:
angle:
light:
sequence:
- service: light.turn_on
data_template:
entity_id: “{{ light.tv_light }}”
brightness_pct: >
{% set step_size = angle * 0.4 %}
{# Use the 0.4 above to change the sensitivity of the action. #}
{# Get brightness as a percent. #}
{% set cb = (state_attr( light, ‘brightness’) | float(10) / 255.0) * 100.0 %}
{% set new_brightness = cb | int(10) + step_size %}
{% if new_brightness < 5 %}
{# If it gets really low set to 0. Adjust if needed for your lights. #}
0
{% elif new_brightness <= 10 %}
{# If it’s not quite 0, set to a minimum working brightness. #}
10
{% elif 91 <= new_brightness < (90 + step_size) %}
{# If it’s almost full brightness, set to 100%. #}
100
{% else %}
{# Send actual calculated value. #}
{{ new_brightness }}
{% endif %}/
the enitity I am trying to control is light.tv_light also in the script section I created a script called “cube_dimmer_control_5” , now when I rotate the cube I can see in the automation screen that the automation tempelate gets triggered - but the under scripts the script never gets triggered , and so the dimmer does not work either - if you could please guide me with this setup - it will help me immesnsley in future automations using scripts.

Thank You

I can’t quite tell what you are doing, but in general you download/install the blueprint, then select it in the automation ui editor one of a couple of ways.

Once there you find the line item you want to add stuff to, in this case action CW side 3 and action ccw side three.

select call service, change to edit in yaml, then paste the provided code in.

The script part is a script, added via the script ui editor. Script ui editor, edit in yaml, paste in the whole script section except the word script:

If you want to see it in use, look at my personal configuration…

1 Like

Hi James , so as a first step when I try to add action in blueprint by choosing call service and pasting the code I am getting the following error when I try to save -


what am I dont wrong please ?

there is no service called “”. Clear that sample stuff before you add real stuff.

And if you are messing around with the script name make sure it’s the same in scripts as well. You very likely only need one of those scripts and can call it from multiple BP instances, so changing the name and getting yourself confused is not advised.

Also you don’t call CW and CCW with the same cube action.

You have to think about what is happening here. The sample text is showing you what you need. service: '"". The part of the sample code I provide you need is the part that looks like that. So for the CW one copy the service and data sections into the CW in the BP.
The call is identical for both the CW and CCW sections because the angle goes nefative when turned CCW. Both of these make separate calls to the same script.

So you have about 4 or 5 things wrong.

Hi James , I removed the auto populated stuff and pasted the real stuff , but still got the error as in the picture .

I also pasted the script part in script.yaml, this time as per you advise have not changed script name.

Hi James ,

Please ignore - got it to work finally - thnak you so very much for your help.

1 Like

I have added 3 new script blueprints to replace the yaml scripts I had offered as samples before. I have also cleaned the coding up on these and simplified them.
They may now be suitable for use in other people Blueprints and/or your bare automation to help with light dimming with the cube, color change with the cube, and simulating long / short button press with the cube.
I am now working on one to do volume control.

Cube Light Dimming: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Cube Color Change: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Cube Long/Short Press Simulation: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

hi James,

added the cube to zigbee2mqtt, and can see status change when I put action to the cube,
but when i try to run the automation i have this error

Error: UndefinedError: ‘dict object’ has no attribute ‘payload_json’

the action for ‘🫳 ACTION MODE ONLY 🫳 Group 1 :apple: Double tap with face 2 up’
is set to

service: light.turn_on
data: {}
target:
entity_id: light.living_room

i know this action works cos i can run test and light got turn on, but no luck when i run the automation.

code of the automation is below

alias: cube double tap 2
description: “”
use_blueprint:
path: SirGoodenough/Zigbee2MQTT-Aqara-Magic-Cube-T1-Pro-CTP-R01-Xiaomi-Lumi.yaml
input:
topic: zigbee2mqtt/cube
action_doubletap_face_2:
- service: light.turn_on
data: {}
target:
entity_id: light.living_room

can you shed some light over please, thanks in advance.

Are you hitting ‘run’ in the automation, which won’t work because there is no data in the trigger, or are you actuating the cube itself?
Also, since you are selecting an action double-tap, make sure the cube is in action mode not scene mode.

im actioning the cube, still no luck in the outcome,
the cube is in action mode. im kinda stuck cos dont know what direction to go as troubleshoot

thanks,
SAm

shake works, i think, but tap doesnt, maybe i miss something on setup :frowning:

You may be typing wrong. Look in the instructions, I have a demo there showing you how to tap.

Updated instructions to clarify Template Error problem.

  • 2022-03-01-A: Beef-up the note not to use spaces and non alpha in MQTT topics.

Hello, just wanted to say thanks for the amazing blueprint, but im facing an issue.

With my Pro cube the Aqara logo is on side 1, and the automation works as intended when coupled to “side 1”. That being said there are no “side 6” fields to work with and the ones labeled “side 0” do not work with my “side 6”.

On the dashboard it shows the current side as being 6, so I assumed that there is no entity for “side 0”. I tried changing the yaml file from “doubletap_face_0” to “doubletap_face_6” but no luck it getting it to work.

Any help is appreciated.

Z2M numbers the cube sides 1 to 6. ZHA numbers the cube sides 0 thru 5. This is a Z2M automation, so there is no 0.

Also if you set up the sensor and it reports to you that you are on side 6, that is detected from the cube so that is what side it’s on.

Is you make changes, that’s cool, but make the change in the !inputs, and in the actions. It won’t work if you change in one spot. Lots of stuff going on there and I can explain only so much in the helper file.

If you are using ZHA, use this BP:

For both the old cube and the new cube. The ZHA team has not to my knowledge updated a correct interface for the new cube, so the only functions that are available are less than the old cube. The cube itself will do them, but ZHA has no idea it is doing it.

There is an open issue with the zigpy team but no one has stepped up to fix it yes. Perhaps if people created a bit of a buzz around it it might get some attention.

1 Like

I am actually on Z2M, and I believe I have the right blueprint uploaded as seen in the screenshot below:

Or have I somehow mixed up the links?