Aqara Magic Cube ZHA (51 actions)

I don’t have the time to do it, but if anyone has please do.

Thanks for the reply!

I’m pretty new to Home Assistant, but I’ll see if I can make sense of your blueprint and go from there.

Has anyone managed to get 2 cube to show up as options, as I have 2 at home one upstairs and one downstairs, but the blueprint only sees the first one that I have added?

I managed to do what I wanted thanks to your clean code. I hope my solution isn’t unnecessarily complicated.

I’m not sure what to do with it now. @Mikkelmoeller Do you want to (and have the time to) look at it (it’s on github for now) and maybe integrate it here, or should I post it as a new integration crediting you and linking here?

1 Like

I don’t quite understand: Are you trying to use both cubes in the same automation, or does the second one not show up as an option at all?

Nice, this is the most wholesome blueprint that I was able to find with the cube. Works fine for me.

1 Like

Hi, no the second cube doesn’t show up on the options to use

Oh OK, that’s weird. Mine shows both. Do they both show up as devices on the devices screen? Have you tried removing the second one and pairing again?

Hi @memorandomz ,

I imported your config but couldn’t find any differences. Maybe I am missing something. In which area is your code different from the one provided by Mikkelmoeller?

I am really happy with this blueprint, it made my Cube’s automation really easy.

If we can make the “rotate right” and “rotate left” actions to be side specific it will be really awesome.

For example with side 1 up you can dim and brighten the lights, side 2 up can control the TV volume, side 3 up can control your amplifier volume, etc.

I’ll give it a try too!

Hi @HawkMan,

I introduced this section into the blueprint:


I didn’t change any of the existing code, just added to it (well, basically copy-pasted from it).

Ooh, that sounds interesting. I don’t know if it’s possible, but it might be. Maybe I’ll play around with it a little tomorrow.

I don’t know if it is just my Cube but for the rotate right and left movements there is no zha_event about which side it is on. It just registers the rotate_right or rotate_left command and the relative degrees.

So it think it is pointless to try and assign different rotate actions according to the face the cube is on as I posted in my previous.

Can anyone else confirm the same?

My zha_event data
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:05:cf:9a:3d",
        "unique_id": "00:15:8d:00:05:cf:9a:3d:3:0x000c",
        "device_id": "ef000d94d7b85f1c1f873315860e16af",
        "endpoint_id": 3,
        "cluster_id": 12,
        "command": "rotate_right",
        "args": {
            "relative_degrees": 11.560001373291016
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-06T21:30:36.181945+00:00",
    "context": {
        "id": "9dfc7cc994cae4410d2984393553bda2",
        "parent_id": null,
        "user_id": null
    }
}

Yes, same here. :frowning_face:

If you really want that functionality, you could probably define an input_number that keeps track of which side is turned up and then react to the rotate left and right events accordingly.

This sounds like a good idea but I wouldn’t know where to start and how complex this can be. I am not an expert in HA or Yaml so I think I am going to revisit this after I gain more experience.

In the meantime maybe someone else with such knowledge creates it and shares it.

I really believe that the “rotate left and right actions per side” functionality for this cube is going to be really awesome.

Just installed this blueprint and it worked for a while. Now, all I’m getting is:

INFO (MainThread) [homeassistant.components.automation.aqara_magic_cube] Initialized trigger Aqara Magic Cube
ERROR (stream_worker) [homeassistant.components.stream.worker] Error demuxing stream while finding first packet: 

Any suggestions, ideas?

I tried this, but I’m always getting an error message:

Blueprint Aqara Magic Cube generated invalid automation with inputs OrderedDict([('remote', 'e725213099fc2bd940c26dc4fc5654ae'), ('cube_shake', [OrderedDict([('service', 'input_number.set_value'), ('entity_id', 'input_number.cube'), ('data', OrderedDict([('value', '0')]))])]), ('one_to_one', [OrderedDict([('service', 'input_number.set_value'), ('entity_id', 'input_number.cube'), ('data', OrderedDict([('value', '1')]))])])
extra keys not allowed @ data['action'][1]['choose'][0]['sequence'][0]['choose'][0]['sequence'][0]['command']

So it seems like the choose action isn’t supported, but needed.
Any way to fix this?

Here’s my automation:

alias: Aqara Magic Cube
description: ''
use_blueprint:
  path: Mikkelmoeller/aqara-magic-cube-zha-51-actions.yaml
  input:
    remote: e725213099fc2bd940c26dc4fc5654ae
    one_to_two:
      - choose:
          - conditions:
              - condition: state
                entity_id: input_number.cube
                state: '1'
            sequence:
              - service: script.prime_video
                data: {}
        default: []
    two_to_one:
      - choose:
          - conditions:
              - condition: state
                entity_id: input_number.cube
                state: '1'
            sequence:
              - service: script.prime_video
                data: {}
        default: []
    cube_shake:
      - service: input_number.set_value
        data:
          value: '0'
        entity_id: input_number.cube
    slide_on_one:
      - service: input_number.set_value
        data:
          value: '1'
        entity_id: input_number.cube

What I wanted to do is to execute different actions weither I turned it from 1 to 2 and from 2 to 1 OR from 2 to 1 and 1 to 2.

I am using Zigbee2mqtt and getting “no matching devices found” when i try to use the blueprint with my aqara cube… Is there a solution for that? Thanks!

1 Like

Hey,

This integration isn’t compatible with z2m, try this one instead:

Hope this helps!

none of the specific side action works for me. but if I check any side it will work.

I’m fairly new to ZHA and home assistant and I am just trying to understand your blueprint from reverse engineering.

I suspect the issue might be the conditions when you are specifying value == slide but it should be command == ‘slide’ ?

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:05:7b:00:4c",
        "unique_id": "00:15:8d:00:05:7b:00:4c:2:0x0012",
        "device_id": "dff5a27387297af7023e41b959706dd3",
        "endpoint_id": 2,
        "cluster_id": 18,
        "command": "slide",
        "args": {
            "value": 257,
            "description": "aqara logo facing user rotated 90 degrees right",
            "activated_face": 2
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-19T05:06:36.246734+00:00",
    "context": {
        "id": "0592ed21f8a6307c7add7d56c4e33c65",
        "parent_id": null,
        "user_id": null
    }
}

I’m sorry, but it has to be a different issue as specific site automations works for me without any problems using this blueprint.

Somebody know why with z2m and deconz its possible to know which face is up when rotating but not with ZHA?
This is the only thing missing for me to make my cube working.

1 Like