Aqara Magic Cube ZHA (51 actions)

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

i testes out all of the triggers with service toggle light while watching zha_event.

knock, slide only works on side 1 even when “slide any side” and “knock on any side” are set to false.

when performing the action, zha_event are register and logbook shows automation triggered by zha event, however the service is not called.

im not sure if this is related to my config or only tie to this blueprint.

Where do I have to remove the lumi.sensor_cube statement? Can’t find it in the blueprint…

1 Like

Is there side specific rotate options or am I missing something? Was thinking rotate could be used for light brightness with the light chosen by side facing up?

1 Like

looking for the same feature. if ever you found it

It looks like the deconz blueprint has a double tap automation. Does ZHA not support that?

This blueprint supports double tap, its a double knock or what is listed as simply “knock” in the bullets.

I am Looking for a way to limit rotate left/right based on the activated face.
So that with face 1 rotate left/right will increase/decrease light brightness, and face 2 will change color or volume etc…

Right now the rotate trigger is global, regardless of active face.
I thought to add conditions but only battery is available as a condition.

Any hints?

2 Likes

@Necromancer I’ve added an input_select helper and when I put the cube down on a face, it changes the input_select to some text value (eg. Lights, Music). Then in rotate left/right triggers I’ve used a choose action. Depending on what the active face is (in the input_select), it switches between different actions.
Some sample code:

Face select
four_to_one:
      - service: input_select.select_option
        data:
          option: Music
        entity_id: input_select.active_cube_side

You’ve got to set it up for all x_to_y parts. Here’s the rotation part:

Rotate
rotate_right:
      - choose:
        - conditions:
          - condition: state
            entity_id: input_select.active_cube_side
            state: Music
          sequence:
          - service: media_player.volume_up
            data: {}
            entity_id: media_player.player_name
        - conditions:
          - condition: state
            entity_id: input_select.active_cube_side
            state: Lights
          sequence:
          - service: light.turn_on
            data:
              brightness_step_pct: 15
            entity_id: light.light_name

Hope this helps

2 Likes

@makistane
How do you check which face the cube is on to update the input_select helper to keep track of the active face?
In automation the only available triggers is “device slid/knocked/flipped with face 1 activated”

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: