Aqara Cube ZHA - Simplified face-based device control

Thanks for sharing, @althan.

I’ve managed to get it working now with this fix.

1 Like

Hi, I’m using your blueprint and it is fantastic! I’m trying to trigger an automation with a condition tapping the cube, but it doesn’t work. I’m quite sure it is my fault, but I can’t find a solution. Thanks in advance for any help

alias: Cinema ON
description: Predispone la stanza per guardare il proiettore
trigger: []
condition:
  - condition: device
    device_id: ccacf2caf9f620ad7d9a3188184ae33d
    domain: media_player
    entity_id: media_player.denon_avr_x3100w
    type: is_off
action:
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.telecomando_jvc
  - service: media_player.turn_on
    data: {}
    target:
      device_id: aeb8570f8bd33d8d211583bfcb230583
  - service: light.turn_on
    data:
      transition: 0
      rgb_color:
        - 0
        - 255
        - 255
      brightness_pct: 25
    target:
      device_id: 8dc8effc7091a9739d018cc870eb4845
  - service: media_player.turn_on
    data: {}
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - service: switch.turn_off
    data: {}
    target:
      device_id: 4cadbb0719870b5e4915cf64fbad075f
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: media_player.select_source
    data:
      source: Media Player
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data:
      transition: 0
    target:
      area_id: soggiorno
mode: single

Hi @falcof, my apologies for my late reply here.

It isn’t clear to me what you are asking for? Do you wanna help to create a trigger for this automation you shared or are you trying to fit those conditions and actions in one of the faces on the Blueprint?

If you want to use the Blueprint, you can use an “if..then” statement like this:

if:
  - condition: state
    entity_id: media_player.denon_avr_x3100w
    state: "off"
then:
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.telecomando_jvc
  - service: media_player.turn_on
    data: {}
    target:
      device_id: aeb8570f8bd33d8d211583bfcb230583
  - service: light.turn_on
    data:
      transition: 0
      rgb_color:
        - 0
        - 255
        - 255
      brightness_pct: 25
    target:
      device_id: 8dc8effc7091a9739d018cc870eb4845
  - service: media_player.turn_on
    data: {}
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - service: switch.turn_off
    data: {}
    target:
      device_id: 4cadbb0719870b5e4915cf64fbad075f
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: media_player.select_source
    data:
      source: Media Player
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data:
      transition: 0
    target:
      area_id: soggiorno

Hi, that is not what I was expecting as an answer, but I think it should solve my problem.
I created 2 different automations (cinema on and cinema off) and I would like to trigger both knocking on the same face of the cube, depending on the state of Denon.
I will try to use your suggestion using if… then…
Thanks in advance, I’ll let you know

1 Like

This Blueprint may or may not work with the new cube version, but the new cube version has several functional differences from the old one.
The new cube version has an ACTION mode and a SCENE mode and you might have have to switch it to get it to work properly.
I have tested my blueprint and it works properly with the new cube if the cube is in the correct mode. The exception being that the DROP function is apparently no longer available.

Here is a link on how to switch the mode of the cube should you need to do so and everything I know about the new cube hardware:

1 Like

I’m sorry, but I have to say that the cube doesn’t trigger anything

Could you please share your yaml? Please remove any sensitive information.

By the way, do you have anything in your logs?
Which Cube model are you using? The old one or the Cube pro?

Hi, first of all thanks for been so kind. Here’s my config.yaml


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
camera: !include configurations/camera.yaml

I have the old cube, all my other automations, trigger by the cube are working.
There’s an error in my log.
Logger: miio.miioprotocol
Source: /usr/local/lib/python3.10/site-packages/miio/miioprotocol.py:255
First occurred: 17 gennaio 2023 07:17:38 (17081 occurrences)
Last logged: 21:03:53

Got error when receiving: {‘code’: -9999, ‘message’: ‘user ack timeout’}

Thank you in advance

Hi @falcof,

When I asked for your yaml I mean the auto.atiin itself, not the configuration.yaml.
Just open your Automation (the one using the Blueprint) and click on the menu and select to view as yaml.

I don’t think this is related to the Blueprint or the Cube.

if:
  - condition: state
    entity_id: media_player.denon_avr_x3100w
    state: "off"
then:
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.telecomando_jvc
  - service: media_player.turn_on
    data: {}
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - service: scene.turn_on
    data: {}
    target:
      entity_id: scene.relax
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: media_player.select_source
    data:
      source: MPlay
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - service: media_player.turn_on
    data: {}
    target:
      device_id: aeb8570f8bd33d8d211583bfcb230583
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.piantana

Again, thank you!

Just to isolate the parts, in order to help us finding the issue, could you please try to run it without the if clause and confirm if it does what you are expecting?

Something like this:

  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.telecomando_jvc
  - service: media_player.turn_on
    data: {}
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - service: scene.turn_on
    data: {}
    target:
      entity_id: scene.relax
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: media_player.select_source
    data:
      source: MPlay
    target:
      device_id: ccacf2caf9f620ad7d9a3188184ae33d
  - service: media_player.turn_on
    data: {}
    target:
      device_id: aeb8570f8bd33d8d211583bfcb230583
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.piantana

Also, could you please go to Developer Tools, then click on State tab and search for media_player.denon_avr_x3100w, then take not for the different states when that device is on, off or in standby (if supported)?

That’s exactly what I’ve been looking for! Using it to control kitchen/diner lights but I wanted to only dim the lights related to the face showing. Spent ages trying different things but this saved me hours/days of working out. Top marks Ed!

1 Like

To anyone using the PRO T1 version of the cube…

The cube has a scene mode, a throw action, a hold action, and other features that are NOT being exported thru zigpy into ZHA.
I suggest that you go to

And ask for the new features to be installed.

1 Like

Hi guys, I’ve got the original cube and with this automation and helper (thanks @EdwardTFN) it works fine but is reporting the 2-5, 3-6 issue. Does not affect rotation, (2 is 2, 3 is 3 etc) but does affect knock and slide. I see there are definite issues on GitHub, this forum and Reddit about this but no obvious resolution that I can see. Have I missed something? I’m using the cube directly with HA on a ConBee stick so no Aqara Hub.

Could you please detail a bit more? I’m not sure if I understood which problem you are having.

If you want to switch between the modes of the cube, press the link button five times. Before, it wouldn’t register the active side for me.

1 Like

There are a few posts (various forums, some referring to ZHA) that say that the cube has an issue with mixing up sides 2 & 5, and 3 & 6.

I’ve set up the helper which recognises when i have flipped the cube and registers the correct face, for example:

Flipping from side 1 to side 2, the allocated lights come on correctly. When I rotate the cube with side 2 facing up, the lights allocated to side 2 increase/decrease brightness. When I knock the cube with side 2 facing up, it operates the blind which is allocated to side 5.

I can see this action in the logs or a page somewhere (it escapes me where it is for now) and i see last face as 2 and when i rotate the cube it switches to side 5

Mmmm
Thanks for the details. I will investigate this and come back to you.

In Z2M you can do that, or just go to the device in Home Assistant, change the mode, do a ‘throw’ action with the cube, and it changes…
The throw action that you don’t have here…
You also are missing the hold command, the drop command is listed but no longer available. then there is the 52 other scene based actions that ZHA has no access to. If I knew how to write a quirk I could do something about it, but I looked into it and honestly have no clue…

We need someone with a new cube and the knowledge on how to write a quirk…