Aqara Magic Cube ZHA (51 actions)

Quite happy that there is a blueprint for this device. So kuddos for making this!

I have owned this device since my Hubitat days and never really could find a good use-case scenario for this. Can folks share how they are using the cube in their home automations? Suggestions is appreciated!

I use the blueprint’s “From side x to side y” input to call the input_select.select_option service and change the input_select value. It sounds like you tried to make a new automation to handle this, but there is no need, everything can be done in the blueprint.

oh right, need to use automation through the blueprint.
did it a few days ago and already forgot i about it :smiley:

@makistane
Do you run all of cube functions from one automation? or do you split each function to its own different automation?

1 Like

I extended this to add actions for flipping to a specific side regardless of the side it was on before: ZHA - Aqara Magic Cube (57 actions)

Please help i really want to use this blueprint template but i have cc2531.

I have succesfully added aqara cube to Ha and i see the integration and maked some manual automation and it is workimg fine.

What do i replace thinks on this template to work all actions also with cc2531 ???

1 Like

(thank you for this blueprint)

I’m reporting that my logs fill up with warning messages like the one below every time a rotate event happens:

WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'flip_degrees' when rendering '{{ trigger.event.data.args.flip_degrees }}'

Correspondigly, the same log-warning is issued but for the relative_degrees key, when the cube is flipped.

The culprit is the blanket access of those trigger.event.data.args keys when setting up the initial variables.

A fix would be to check first that the key exists, like this:

action:

  - variables:
      ...
      flip_degrees:   ' {{ trigger.event.data.args.flip_degrees | default }}'
      relative_degrees: '{{ trigger.event.data.args.relative_degrees | default }}'

[edit: for a period of time i had suggested a conditional code, above, but reverted back to default filter after testing it]

Is there any possiblity that this fix can be applied?
(and if yes, do i need then to refresh my blueprints, somehow?)

1 Like

I am getting following error on trace
Error: UndefinedError: ‘dict object’ has no attribute ‘event’
I am using zha integration , device name LUMI lumi.sensor_cube
what I am missing ?

I believe this blueprint has a way to control what rotate does with respect to the side it’s on, but I could be wrong?

I have extended this blueprint and brent’s 57 action blueprint to allow for per-side rotation actions.

4 Likes

Nice job, Rahul!

Awesome … works well!

Hi, just wanted to ask, recently been getting these errors in my log files for my (HAOS). Not sure if its related to the blueprint or the device itself. Cube seems to be working normally, though.

I’d be happy to share more information is required.

Logger: homeassistant.helpers.template
Source: helpers/template.py:1822
First occurred: March 16, 2022, 6:13:19 PM (82 occurrences)
Last logged: 8:53:58 AM

Template variable warning: 'dict object' has no attribute 'flip_degrees' when rendering '{{ trigger.event.data.args.flip_degrees }}'
Template variable warning: 'dict object' has no attribute 'relative_degrees' when rendering '{{ trigger.event.data.args.relative_degrees }}'
Template variable warning: 'dict object' has no attribute 'value' when rendering '{{ trigger.event.data.args.value }}'
1 Like

Just putting this out there for people trying to keep track of sides, getting log errors, and other weird behavior, zigbee2mqtt has this nailed. One sensor to monitor for all operations, There are blueprints for it. I would never look back to another controller integration.

This is great - been playing with it to control my lights.

One question - I have it so rotating the cube anticlockwise dims the lights and clockwise brightens it. This works, but it only works once - so it only dims a bit, then if I rotate more it doesn’t get any brighter or dimmer. Is there a way that I can make it function as a proper dimmer? Or each turn reduces/increases brightness by X?

Sure I’m missing something here!

I am still finding these in my logfiles, any easy fixes?

2022-05-25 11:10:40 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'value' when rendering '{{ trigger.event.data.args.value }}'
2022-05-25 11:10:40 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'flip_degrees' when rendering '{{ trigger.event.data.args.flip_degrees }}'

These cubes toss out a lot of NULL triggers, so if the trigger action doesn’t filter them out you will get a lot of junk in the logs like that.
I don’t have ZHA, but the blueprint I wrote for Z2M takes that into account and only allows triggers into the automation that are valid. This Blueprint may have to be modified if you want to get rid of that.

A variation on the template trigger that you see in mine should solve that. If a trigger doesn’t have a valid keyword, it is not used and it does not throw an error.

(Note, I am assuming that this might help, I only looked at this blueprint for a moment but that’s the errors that would be with null triggers.)

I’m assuming the error is related to how the blueprint will create variables even for values that don’t exist in the event payload. Thus, the solution is to change from:

    value: '{{ trigger.event.data.args.value }}'
    flip_degrees: '{{ trigger.event.data.args.flip_degrees }}'
    relative_degrees: '{{ trigger.event.data.args.relative_degrees }}'

to:

    value: '{{ trigger.event.data.args.value | default(None) }}'
    flip_degrees: '{{ trigger.event.data.args.flip_degrees | default(None) }}'
    relative_degrees: '{{ trigger.event.data.args.relative_degrees | default(None) }}'

under the variables section.

That may change it, but the reason is it’s allow to trigger without condition on the null triggers and wake-up triggers which should not be sent to the the rest of the blueprint for parsing at all…

The errors will them be that none is not valid in the rest of the blueprint.

Hoping someone can help. I have the cube setup on ZHA with the Sonoff Zigbee Stick. It shows up in my devices in an automation as what I named it, Living Room Cube. However, when I import the blueprint it does not show it in devices but shows other Aqara devices. I renamed the manufacturer in the code to unk_manufacturer because that’s what it says in device info and then when I go to the blueprint it shows me two devices one of them Living Room Cube and the other unk_manufacturer. So tested both out and neither work. Then I went to events to listen and nothing is happening when I do any cube actions. Any suggestions?