Aqara Cube

Hi @SFHasan,
I am running on 0.91.4, but that shouldn’t make any difference.

BTW, for testing purposes the event listener is very valuable. Just head to the Events tool (middle of the dev tools) and subscribe to “zha_event”.
I have now automations for all actions, and clearly fell in love with the cube.

1 Like

Thanks again. Can you please guide a bit more in detail steps, I tried listening to ZHA_event and the cube, however nothing happened. Where/how to see the events.

Secondly I guess the cube now lies dead all the time, although I successfully paired it up 2 weeks ago, but never used it, so does it needs to be paired again or somehow “woken” up again .

Thanks.

Never mind, stumbled here and there myself and found the way forward. So sharing here just for someone in a fix like myself.

In short I was unable to make much headway without the Mijia Gateway, so ordered one I was getting for cheap. I got the Mijia Gateway (the old version v1 as HASS tell that new Aqara V2 has troubles enabling the local LAN access protocol).

Onwards I installed the Mijia Home android app, and added the gateway, which promptly asked for a firmware update, to which I permitted. After the update I added the newer Aqara Cube “MFKZQ01LM” in the Mijia Home app, and tried making some if cube action “x” , then do “y” on Mijia gateway (like changing a light or playing a tune).

When I enabled local LAN communication on Mijia Gateway, it was auto detected on Home Assistant and the gateway ring light and the aqara cube were available as entities in HASS (0.91.0).

From the main screen cube “badge”, I was able to see that any cube positional events were sent to HASS and were updated. The events available on Aqara Cube are

flip90
flip180
move
tap_twice
shake_air
swing
alert
free_fall
rotate

So i tried to build some basic automation to toggle lights on/off with the rotate action. Based on the excellent information provided on this page

Cube actions

I tried building the automation via automation editior UI. I did write the automation correctly by only changing and replacing my own entity IDs and action type in the code syntax from the above page. However the automation were not getting triggered by rotating the cube.

I tried firing the event manually via Events UI in HASS, by putting in the event type cube_action, it worked, and toggled the connected smart light in on/off sequence.

I guessed probably events are not sent to HASS, but it was contradictory, since the cube badge on the main page was showing the different events coming from cube (it was live as they happened like move, rotate, tap twice).

So by hit and trial I stumbled over this post , which was true help.

Listen to Events

image

Observing the events log this way I found that newer aqara cube fire events with the event type

event_type: xiaomi_aqara.cube_action (and not older cube_action only)

So i replaced the event type in automation with this correct parameter and voila…it came alive.

The possibilities are numerous now , will continue experiments about how to make more useful automation from cube.

Thanks.

2 Likes

Thank you for randomly making it click in my about how the event subscriber function works!!

i have the Aqara cube… so far while pairing (without the gateway, only zigbee usb stick in the PI) I only ever get the Power sensor… but when i monitor the events in Developer Tools i see all the rotates, turns etc - not sure why pairing won’t discover all the other sensors. Any ideas?

1 Like

What you describe could have different reasons.
Depending on your chosen ZigBee integration (ZigBee2MQTT, ZHA, Deconz), the integration may support, recognize or just track the information. Then HA must map that knowledge too.
So you wrote that you are able to monitor the events in Developer Tools. That’s great, from hear on you can track the cube. Sure, it’s a little bit more manual work, but not difficult.

What sensors are you expecting?

there were examples above where the cube has lots of sensors… but for now - i have been using node-red which is monitoring the zha event and i know what cube face/movement is operative - and trigger scenes or events.

Ah shoot I have the same problem where I only see the power entity added. I’m using ZHA. Could you explain how you got it working?

@tbelaire My solution was just to use NodeRed, and monitor for ZHA_event, and then detect which way the cube had been turned or rotated… or which face as ‘active’ or up… then i execute the script/commands to change lights etc.

zigbee2mqtt works perfectly with these cubes. I paired one this afternoon and within two minutes had them adjusting my volume up and down on rotate right/left.

1 Like