Aqara Cube ZHA - Simplified face-based device control

Also, I cannot test right now, but most likely the Blueprint that I’ve created will work as it is if you select “call a service” as an action for one of the turning sides and then adding the variable as a template in YAML mode:

EDIT on 2022-05-07: Use relative_degrees or trigger.event.data.args.relative_degrees instead of flip_degrees.

I’ve tried both in automations before and prefer the one using degrees as a multiplier. If you set it right, you can get finer control over the adjustment. Low angle = low change in brightness/volume. High angle = high change. Versus a static X% no matter how much the turn angle.

hi thanks for your blueprint!

I have 3 of these cubes and they control various thongs like blids, fans, lights, etc. I’m currently using the 51 action blueprint one now, besides geting erros messages in the my log files when I rotate the cube:

Template variable warning: 'dict object' has no attribute 'flip_degrees' when rendering '{{ trigger.event.data.args.flip_degrees }}'

2:24:17 PM – (WARNING) helpers/template.py - message first occurred at 2:24:06 PM and shows up 28 times

just curious what your blueprint does that is better than the 51 action one? I’d be happy to change to this!

Have you tried using flip_degrees as in my last example?

Hi @Anto79-ops,
I don’t know which Blueprint you are talking about. Please share the link here and I can try to identify the difference between them.
By the way, this is not a competition between blueprints. :wink:

It’s the wrong zigbee flavor, but if you are able to get the angle into my template, this template logic I suggest for angle actions should work for you… (This is a link to the dimmer control section)

At that level, it’s just an action. You would need to pass the angle in. Z2M gives me pos angles for CW and negative angles for CCW, so the template doesn’t change and called script gets used for multiple sensors.

I also provide in there a scheme to set the R, G, & B Colors using rotation, and another section to use a short rotation for a short press and a larger rotation as a long press. These are all template things you can do regardless of the Zigbee flavor as long as you can get the angle out of the Integrations Data Attributes.

@EdwardTFN thanks!

Here’s what im using now, its in your OP

I tried your blue-print, and it acutally fixes that error in logs that I posted above! so that is great news.

With your blue-print, how does one:

  1. set a command to fire when, for example, something is flipped from side 1 to side 2

@Sir_Goodenough

its sounds like things are greener over at the Z2M side, in terms of features. I’m slowly building up momentum to make the switch. That’s an impressive blue-print for the cube!

That is simply an action sensor called by te zigbee stuff. It’s a Home Assistant script.

If ZHA has the angle as an attribute, that is the input and the rest should be close.

1 Like

I was about to try Z2M when I got this cube and couldn’t find so much material, but in the end I invested a bit more time to learn a bit more on how to work with events and discovered I can have very similar capabilities with ZHA, with an smoother user experience, so I decided to stay.

Maybe I can help you here… What you want is that Blueprint converted for ZHA?

1 Like

On my Blueprint I don’t take in account the “from” side, I just use the side the needed showing up after each action.

1 Like

@EdwardTFN @Sir_Goodenough

Sometimes simplicity the best solultion, I can guarantee you that if I start talking about angles to control devices with my wife, she is going to through that cube out the window.

I think in my household, I will be using both your blueprints :smiley:

thanks again for your awesome dev work here!!

1 Like

From side that were not flip actions was fun. I happened to notice that if you were really careful you could get it into that mode. It is completely impractical, however. Not useful beyond a ‘secret’ way to activate a trigger for something…

I mostly added it so I could say there were over 100 ways to trigger it… (albeit some ridiculous…)

Anything anyone wants to take from my code into their code go right ahead. Attribution is nice but not required…

If someone can think of a tweak for mine suggest away.

1 Like

Of course any copy of your Blueprint will require giving you the credits.

My point is more that “convert” a Blueprint originally designed to Z2MQTT in a way it can work with ZHA is not a big issue.
And I’m not sharing my Blueprint to compete with other Blueprint. I’m doing this in order to support someone who could have a similar use case that I had. It is a collaboration mindset, not a competitive mindset.
And if someone need help converting an existing Blueprint designed to Z2MQTT into a ZHA Blueprint I can help. :wink:
I’m not gonna offer to do the opposite by the simple fact that I don’t have a Z2MQTT environment to run my tests.

Go for it. Glad to share.
I have an old sonoff Zigbee V1 brick that someday I’m going it install ZHA for testing and porting stuff, but It hasn’t happened yet. Maybe late fall. So go right ahead.

1 Like

Flip degrees is 90, 180 and not the rotation degrees

That’s right, @mouth4war, the rotation will be on relative_degrees, which I think is not included in this Blueprint. Thanks for catching that.

        "command": "rotate_right",
        "args": {
            "relative_degrees": 76.14999389648438

I will take a look if I can add this info to the blueprint.

Ok, the value is available on trigger.event.data.args.relative_degrees. I’ve added this to the blueprint.

1 Like

Noticed a bug. When I double tap on face 2 it changes the helper to 5.

1 Like

Hi @mouth4wa, are you sure about this? I couldn’t reproduce what you are saying and basically the blueprint will use the face info it is receiving from the event.

The face numbering is a but tricky and I believe the best representation I found was this on from this other Blueprint: ZHA - Aqara Magic Cube (57 actions), which is also just using the info received by the event (from the Zigbee integration).