Aqara Cube ZHA - Simplified face-based device control

It’s not that, the video was to show it clearly happening. It isn’t the way it is being used, it is something registering the wrong side for the action. Trust me, I’ve done a lot of testing.

I have 3 cubes, I can’t get any of them to do that unless I tip it slow like that and it doesn’t register the flip. I use a different BP, but this code looks sound and I don’t think it’s that.
You could verify that by trying another BP and see if it acts the same for you.

Same here, it seemed to start after a HA update around December.

If you watch the video you can see the cube clearly recognising the flip, even if it does seem gentle, it recognises it. What then happens is that when I slide the cube, it changes from “2” to “5”. Watch the “last face activated” register.

@EdwardTFN, any ideas what it could be - I don’t think it’s your code, that looks solid.

I don’t believe last face is reported by the cube itself on slides as the face doesn’t change. Therefore it probably selects a default and somehow reports a 5.
Shake, drop, rotate probably do the same. I think the cube only reports last side for the 90 flip and the 180 flip.

If you want a last side that is accurate you need to create a number helper and store it, like I do with my BP’s.

I’m using @EdwardTFN number helper, that’s where the data on the movement is coming from. Here is a list of what it is doing:

Face 1
Flip to face 1 - actions on device on face 1
Rotate CW & CWW - actions on device on face 1
Slide - actions on device on face 1

Face 2
Flip to face 2 - actions on device on face 2
Rotate CW & CWW - actions on device on face 2
Slide - actions activate against face 5

Face 3
Flip to face 3 - actions on device on face 3
Rotate CW & CWW - actions on device on face 3
Slide/Knock - actions on device on face 6

Face 4
Works as per face 1 works but on face 4

Face 5
Works as per face 2 works but with 5 & 2 transposed

Face 6
Works as per face 3 works but with 6 & 3 transposed.

As per the video, when you flip it it reports the correct side, happens all the time. When you slide it on certain faces then it changes the last face activated to the number above in the list. Always. It’s never a different ‘random’ number, it always changes to the same number for the same action no matter what the orientation is (sliding to the right or left or up or down with different face number facing the direction of travel makes zero difference, the number always changes to the one in the list above)

I’m 100% certain I am using the cube correctly. It’s not hard to do to be fair but if anyone wants further videos showing it them I’m happy to do them.

Can you give us any more information? Are you able to look at the helper ‘last face’ and do some tests to see if it is the same numbers as mine or different? That would be a great help.

I keep opening the kitchen blind when I’m meant to be dimming the breakfast bar lights :crazy_face:

I’m loading this BP and will test it. Which cube are you using, the older one or the new version?

I can tell you one thing. The actual cube is not doing that. My BP’s would be all messed up if they were. It has to be in the BP.
I see one possible problem that may or may not be an issue, but I need to test it.

It’s just a matter of looking at the variables in the traces to see what happened.

Update…
I don’t seem to be able to make it do what you say.
Everything works as it’s supposed to, using this BP.
I didn’t put action commands in it, but I loaded the BP and triggered every side every way and the BP always reports the expected result.

Hi, thanks for sticking with it, sorry about delays in getting back. I is the 1st gen one and I only have one and I don’t see where it’s going wrong. It’s not user error, I’ve been meticulous in checking that. If it was occasional then I’d say it was but it is repeatable and occurs all the time under different circumstances. I might just wipe the whole BP, device and helpers and rebuild and see if it does the same. Someone else in this thread said theirs did the same, occurred about end of 2022, just like mine did.

My advice is to wipe it and try a different BP. There are several to pick from, but if you pick mine I will be better able to help.
Mine have the red fire extinguisher in the title.

It’s fine if you share the link for you blueprint here. This is a collaboration arena, not a competition arena. :wink:

2 Likes

Mine started doing the same with knock, it changes consistently to another face (the opposite one specifically). The interesting bit is that it wasn’t like this when I started setting up the blueprint. Any fix or are we still trying to find the issue?

I kind of gave up to be honest because as per normal internet, everyone has an opinion and the original poster is always wrong about something despite not actually being wrong. Any posts saying “it works fine for me” are quite possibly the most useless replies you could ever post on a forum.

It’s a great helper but I don’t think the issue is the code, I think it’s an Aqara reporting/hardware issue.

For what it’s worth. this person
ZHA - Aqara Magic Cube (69 actions).
Has a conversion to change the activated face to fix what you described, @Fireblade .

I will say I didn’t seem to be able to duplicate your report but now this is 2 independant sources of the same issue, so I will look further.

My BP uses logic very similar to Edwards here, so I’m going to check it again and see if I can verify what mine’s doing. If I find a problem I’ll come back here after I fix it.

The problem is still most likely NOT Aqara. We get the data from the ZHA implementation and conversion used thru the zigpy libraries. There would need to be an issue reported there. Z2M implementation has had no reports of this to my knowledge.

:frowning_face: UPDATE —>

I still cannot verify this. All sides report as expected in all cases. I did find a bug in the BP event sensor that I create to monitor the cube / help train operators, But the functions all work and all the stuff does what it is supposed to on the sides that it is supposed to…

Now it’s down to maybe integration and cube I guess.
My assumptions are you are using the current release of ZHA and have the original style cube. I didn’t retest the T1-Pro cube. That is using the same zigpy library as the old cube and is a messed up affair, with a bunch of stuff not working. I’ve had an issue raised for 11mo now and no takers to fix it. I have no idea how that works, looking for someone to take that on…

@Fireblade could you share the version of firmware on your cube, as well as the model. Perhaps that would shed some light.

1 Like

Thank you @EdwardTFN this is brilliantly simple! (Not to dismiss the work from other template contributors, but I can only keep up to a certain level of complexity :smiley: ).

Is there a reason why you didn’t bring ‘shake’ and ‘drop’ commands? I was actually to add ‘shake’ without success, but that may just be my limited blueprints skills…

As expected, this was me… I managed to add the ‘shake’ action.
Also, now understand the yaml indentation jokes!

2 Likes

Nice!
Feel free to share with others or make a PR on the repository. :wink:

Hi James,

Model is: MFKZQ01LM
Firmware would be a bit tricky as it is only in HA, I don’t have an Aqara hub so unless someone can give me an idea of where to look for the F/W version I can’t help I’m afraid.

Can I just add that both you and @EdwardTFN have been magnificent in continuing to look into this. I get frustrated when people say things that aren’t helpful and tend to give up for periods. I’m very technical but this is not my field of expertise so appreciate the tenacity of you both, thank you.

Got my cube a couple days ago was very excited to find this. Unfortunately the last face helper doesn’t work because it only ever uses the activated face to the time of change which is always the current face.

Set up some extra helpers to do some maths from the automation and was getting the active face information NOT the deactivated face. Roll from 3 to 1 and was getting last face as 1 not 3. This immediately screwed my initial use so I’ve expanded your wonderful work @EdwardTFN to make that a possibility.

However, I’d prefer to not upload it as my own as its yours apart from deactivated and activated face storing correctly.

I added this to the inputs:

current_face_input:
      name: Current face up numeric helper
      description: Please select a Numeric Helper to be used to record the last face
        up.
      selector:
        entity:
          domain:
          - input_number
          multiple: false

And this above activated face:

deactivated_face: '{{iif((command == ''slide'' or command == ''knock'' or command == ''flip''), trigger.event.data.args.deactivated_face, states(temp_last_face_input)) | int(0) }}'

And changed this bit to cope with the last face being last face and current being the current:

- service: input_number.set_value
  target:
    entity_id: !input last_face_input
  data:
    value: '{{ deactivated_face }}'
- service: input_number.set_value
  target:
    entity_id: !input current_face_input
  data:
    value: '{{ activated_face }}'