Aqara Magic Cube ZHA - 2024-06-04 by SirGoodenough
This Blueprint uses a Z2M Event Sensor to sort out the 38(+54) unique actions available from the Xiaomi Magic Cube Remote. (Some unique actions are available thru templating only. See the related document.)
The split out of functions gives you the ability to assign local scripts or functions to do the things you want the remote to do.
Functions that are left empty will simply do nothing.
🍎 There is a set of 36 event functions that will trigger on specific actions on specific sides that are listed as Group 1 actions 🍎.
🍒 There is a set of 6 event functions that will trigger on specific actions on ANY side that are listed as Group 2 sctions 🍒.
🍐 There is a set of 30 event functions that will trigger on cube flips to & froma specific sides that are listed as Group 3 sctions 🍐.
🍕 There are 2 actions (shake and drop) that only occur once and are OK to be combined with any other group. Listed as Group 4 sections 🍕.
Please be aware that ALL actions except the 2 listed above,
🍕 will trigger an action in ALL 3 groups at the same time every time. Therefore I suggest if you just have a couple of things you want this remote to do that you choose the ANY / Group 2 / 🍒 events.
If you want more than a few events, you should select actions in Group 1 / 🍎 OR Group 3 / 🍐.
With careful selection you can use mixed groups, but you run the risk of a single cube action triggering more than 1 Home Assistant action and making a mess of things 🍱.
NOTICE: This cube can be triggered 124 ways, but only 38(+54) of them are unique (with templating).
There is sample code to make the template sensor in the help file on GitHib named Zigbee2MQTT - Xiaomi Cube Controller.md & in the community page related to this.
Within this blueprint there is an event handler that will latch the last action that the blueprint finds and sends that to the event buss. From there a simple Template sensor can grab it and show you the last action sent. Thie will help when setting up new functions and to troubleshoot strange behaviours. _________________________
This was "forked" from >> Aqara Cube ZHA - Simplified face-based device control > Project authored by EdwardTFN (Edward Firmo) and he based on on several other giants that came up with most of the base code. >> >> ZHA - Aqara Magic Cube (57 actions) >> >> Aqara Magic Cube ZHA (51 actions) >> >> ZHA - Aqara Magic Cube (24 actions) > >I sincerely thank Them for their work. I wanted to support a version that was virtually the same as my Z2M version, and leverage all the documentation and code samples there but still port it to ZHA. I also had a better idea for troubleshooting info. _________________________
Community link for this blueprint
🗿Notice👮🏿♂️:
-
Copies of the original Blueprint that were converted via the 'Take Control' feature or other means are officially not supported by me.
-
I may or may not be able to support you when you have a problem after you make changes to my code, as some of the code is no longer mine.
-
I & my license also require attribution as a link back to the original should you use this code in your own creation.
-
Here is a link to my license & the original github post expected to be followed & referenced as attribution should you use this code elsewhere.
Import to Home Assistant
Click to import this blueprint directly into your Home Assistant instance.
Configuration
Requires 16 inputs to configure
Source Code
View on GitHubDetails
Explore More
Related Blueprints
More button actions automations you might like