deCONZ - Xiaomi Aqara MFKZQ01LM Cube Controller

Blueprint to support the Aqara MFKZQ01LM Cube Controller thanks to @Savjee for this example.

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

aqara-cube

Supported actions:

Wake
Slide
Double tap
Flip 180 degrees
Flip 90 degrees
Shake
Drop
Rotate Clockwise
Rotate Counter Clockwise
blueprint:
  name: deCONZ - Aqara Magic Cube MFKZQ01LM
  description: Control anything using Aqara Magic Cube
  domain: automation
  input:
    remote:
      name: Remote
      description: Magic Cube to use
      selector:
        device:
          integration: deconz
          manufacturer: LUMI
    wake:
      name: Cube wake up
      description: Action to run when cube wakes
      default: []
      selector:
        action: {}
    slide:
      name: Slide the cube
      description: Action to run on slide movement
      default: []
      selector:
        action: {}
    double_tap:
      name: Double tap the cube
      description: Action to run on a double tap
      default: []
      selector:
        action: {}
    flip_180:
      name: Flip the cube 180 degrees
      description: Action to run on a 180 flip
      default: []
      selector:
        action: {}
    flip_90:
      name: Flip the cube 90 degrees
      description: Action to run on a 90 flip
      default: []
      selector:
        action: {}
    shake:
      name: Shake the cube
      description: Action to run when the cube is shaked
      default: []
      selector:
        action: {}
    drop:
      name: Drop the cube
      description: Action to run when the cube is dropped
      default: []
      selector:
        action: {}
    rotate_cw:
      name: Rotate cube clockwise
      description: Action to run when the cube is rotated clockwise
      default: []
      selector:
        action: {}
    rotate_ccw:
      name: Rotate cube counter clockwise
      description: Action to run when the cube is rotated counter clockwise
      default: []
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/deconz-xiaomi-aqara-mfkzq01lm-cube-controller/255988
mode: restart
max_exceeded: silent
trigger:
- platform: event
  event_type: deconz_event
  event_data:
    device_id: !input 'remote'
action:
- variables:
    event: '{{ trigger.event.data.event }}'
- choose:
  - conditions:
    - '{{ event == 7000 }}'
    sequence: !input 'wake'
  - conditions:
    - '{{ event in [1000, 2000, 3000, 4000, 5000, 6000] }}'
    sequence: !input 'slide'
  - conditions:
    - '{{ event in [1001, 2002, 3003, 4004, 5005, 6006] }}'
    sequence: !input 'double_tap'
  - conditions:
    - '{{ event in [1006, 2005, 3004, 4003, 5002, 6001] }}'
    sequence: !input 'flip_180'
  - conditions:
    - '{{ event in [1002, 1003, 1004, 1005, 2001, 2003, 2004, 2006, 3001, 3002, 3005,
      3006, 4001, 4002, 4005, 4006, 5001, 5003, 5004, 5006, 6002, 6003, 6004, 6005] }}'
    sequence: !input 'flip_90'
  - conditions:
    - '{{ event == 7007 }}'
    sequence: !input 'shake'
  - conditions:
    - '{{ event == 7008 }}'
    sequence: !input 'drop'
  - conditions:
    - '{{ event | int > 0 }}'
    sequence: !input 'rotate_cw'
  - conditions:
    - '{{ event | int < 0 }}'
    sequence: !input 'rotate_ccw'

Please note: for both the rotations and movements to work the two sensors need to have the same name. This can be checked through the deCONZ rest api

12 Likes

Thanks for sharing, would love to use this blueprint!
I have a MFKZQ01LM Cube in the deCONZ Add-On. But if I try to use the blueprint, I get a “No matching devices found” message.
I looked up the devices in the deCONZ integration page and my cube has the model name “lumi.sensor_cube”, without the aqgl01. Is there a way to add both model types to the blueprint?

I have removed the model from the blueprint, so you can now choose from all devices you have from manufacturer LUMI. That should enable you to use it.

Great job Can you make one using zigbee2mqtt I will be very thank full

Thanks! It’s working great!

I dont get it, you mention 2 sensors.
I have only 1 sensor showing in HA mi_magic_cube.

And do i create a seperate blueprint.yaml or do i out this in automations?

By looking they can be completly diffrent deconz vs ZHA vs Zigbee2mqtt, might be wrong but lot of the time you need the platform setup with the device to actually get the data to make these, this would be a lot of work for them to do… definitly think buying a beer would be needed in these instants (might be wrong)

Just upgrade to the latest version of Home Assistant which supports blueprints 2020.12.1. Then import the blueprint by copying the url from this topic. Then in your blueprints overview you click on create automation and see if it works for both the rotation and the other gestures. If so you don’t have to do anything else. If either rotation or gestures are working you might have to rename one of the sensors through the deconz rest-api.

I have no idea what the values are that zigbee2mqtt uses and sends to HomeAssistant for this device. You need to have someone who knows these values so you can adjust the blueprint to make it work with zigbee2mqtt

@usaiphone I had exactly the same question and couldn’t find an existing blueprint. That is why I made a Z2M variant based on this blueprint.

@wmn79 Thanks for this blueprint, but I get a pretty bad error: Is it possible that your blueprint reacts to the event 7000 for wakeup? Everytime I barely touch my desk, with the cube on it, the automation is triggered. Looking at the yaml it could be the rotate_cw action? I’m monitoring the events in the home assistant event log and nothing besides 7000 is fired

Hi, I don’t have any issue with this myself. How does your yaml look for this automation. If you share it might shed some light in the direction we need to look into.

- id: '1613080417800'
  alias: Nanoleafs
  description: ''
  use_blueprint:
    path: wmn79/deconz-xiaomi-aqara-mfkzq01lm-cube-controller.yaml
    input:
      remote: af6980cfe91e40c1af3f6bcdc101a745
      slide:
      - type: toggle
        device_id: 026535bd3201ac3920466c25b8fcd4b3
        entity_id: light.nanoleafs
        domain: light
      flip_90: []
      shake:
      - service: light.turn_on
        data:
          effect: '{{ (["Pride", "Color Waves", "Sinelon", "Beat", "Juggle", "Fire"]
            | random) }}'
        entity_id: light.nanoleafs
      rotate_cw:
       - service: light.turn_on
        data:
          effect: "Snow"
        entity_id: light.nanoleafs
      rotate_ccw: []

“Snow” is activated everytime the cube is woken up, like touching my desk with the cube on it.

The problem is line 94 in the blueprint:

  - conditions:
    - '{{ event | int > 0 }}'
    sequence: !input 'rotate_cw'

This is matching for every event over 0, like 7000, what is the wake up event for the cube. I think it would be fine if you would ignore that specific number?

Let me check if I can reproduce it, otherwise it may be a solution to add an extra sequence (which you then don’t use) for the event 7000.

1 Like

That sounds like a good idea! Maybe there is also someone who wants to use this event for something, even if I can not think of a use case right now :sweat_smile:

I have updated the start post with the edited blueprint including a wake. I believe you need to delete the current downloaded one and then add it again. I quickly tested it and it looks fine, but you can better test it yourself. Good luck!

1 Like

Reimported the Blueprint last night and set actions to the turn event again, so far no more problems. Thanks a lot!

1 Like

How to add this blueprint to HA? There is no link here. Thanks for help

You could do this in the “old fashioned” way by copying the url of this topic and paste it in the blueprint import dialog. But I have now also added a my.homeassistant badge which you can use to do this in an even more convenient way.

1 Like

How can I check this? I have googled and tried everything to my knowledge… Can someone explain how to check this step by step?