zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Mi Cube (MFKZQ01LM) improvement.

Open niai opened this issue 8 years ago • 11 comments

Hi it would be nice if you could give what side is facing up when you rotate the Mi Cube (MFKZQ01LM), this way we can use the rotate to control different thing depending on the side.

Thanks for all the good work.

niai avatar Sep 13 '18 23:09 niai

Doesnt we Show the side already? I know that we show the side change.. Have to check.

tb-killa avatar Sep 16 '18 10:09 tb-killa

the following samples from MFKZQ01LM - Xiaomi Mi smart home cube (EndDevice)

payload: '{"action":"flip90","from_side":5,"to_side":1,"linkquality":21}'
payload: '{"action":"flip90","from_side":1,"to_side":3,"linkquality":92}'
payload: '{"action":"flip90","from_side":3,"to_side":4,"linkquality":99}'
payload: '{"action":"flip90","from_side":4,"to_side":2,"linkquality":94}'
payload: '{"action":"flip90","from_side":2,"to_side":1,"linkquality":97}'
payload: '{"action":"flip90","from_side":2,"to_side":3,"linkquality":94}'

AnhDuc85 avatar Sep 16 '18 11:09 AnhDuc85

All you get when you rotate is

{"battery":"100.00","voltage":3005,"linkquality":131,"action":"rotate_right","angle":31.87}

I did look in to the "zigbee-shepherd-converters" fromZigbee.js and it looks like the cube may not send the side when it rotates, so I am now not sure if it can be done.

niai avatar Sep 16 '18 16:09 niai

It´s because if you only rotate without flip side .. cube doesn´t trigger MFKZQ01LM_action_multistate event .. only if you flip side we got the event and know the new side .. its from the cube themselve (firmware) so we actually doesn´t could change them .. maybe someone got an idea ... ?

tb-killa avatar Sep 16 '18 18:09 tb-killa

Could we just save the last side the cube was flipped to (from payload {"action":"flip90","from_side":2,"to_side":3,"linkquality":94}) and add it to {"battery":"100.00","voltage":3005,"linkquality":131,"action":"rotate_right","angle":31.87}? The only problem I see is, that the side would be "null" if the cube has never been flipped after initialisation.

sebastianheierhoff avatar Sep 18 '18 08:09 sebastianheierhoff

yuk. I don't like the idea of saving previous attributes and resending them, that's the best solution to get unreliable mqtt messages ;-) I'm pretty sure I can rotate my cube and not get any zigbee msg from it as a result.

lolorc avatar Sep 18 '18 09:09 lolorc

Aye if you are going to implement a dirty hack like that, it should probably be done in your own automation. It wouldn't be to hard to do in Node Red with retain message on.

From what i have looked in to and what has been said here, it looks like it's not really a feasible fix. I think this can be closed I will leave it up to the devs just in case they want more input. Thanks.

niai avatar Sep 18 '18 15:09 niai

What about using state caching (https://github.com/Koenkk/zigbee2mqtt/commit/9396bde1f3b022e0f634487d1a37d2a5127c8cb3#diff-f68567477d803b49930337bf7fe1556bR16)?

sebastianheierhoff avatar Sep 18 '18 20:09 sebastianheierhoff

I would recommend managing as little state as possible in zigbee2mqtt. If you want state create a custom component in the "brains" which is HA to save all the state you need.

Considering the original issue message I think this topic should be closed and if you really want to discuss further regarding saving state in zigbee2mqtt raise a new issue specific to this.

ciotlosm avatar Sep 27 '18 13:09 ciotlosm

What about using state caching (9396bde#diff-f68567477d803b49930337bf7fe1556bR16)?

From my perspective the caching should keep the old values of the topic payload and just overwrite new values of recent (new) keys in the key-value pairs.

I tested the cache flag for the cube and it seems to show only the current state. Does the coverter need to be modified to hold the state?

david-kracht avatar Oct 24 '18 20:10 david-kracht

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 23 '18 21:12 stale[bot]