Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mi Smart Power Plug 2 (chuangmi.plug.212a01) requires real did for multirequests #1896

Open
LZY-SPCA opened this issue Feb 15, 2024 · 4 comments
Labels

Comments

@LZY-SPCA
Copy link

Describe the bug
A clear and concise description of what the bug is.
I want to use genericmiot to control Mi Smart Power Plug 2 (Wi-Fi and Bluetooth Gateway), but when I use 'status' parameter it said did need. And when I use 'actions' it return nothing.

Version information (please complete the following information):

  • OS: Ubuntu 22.04
  • python-miio: miiocli, version 0.6.0.dev0

Device information:
Running command info
Model: chuangmi.plug.212a01
Hardware version: esp32
Firmware version: 2.1.8_0044
Supported using: GenericMiot
Command: miiocli genericmiot --ip 192.168.10.245 --token
Supported by genericmiot: True

To Reproduce
Steps to reproduce the behavior:
1.

Expected behavior
A clear and concise description of what you expected to happen.

Console output
DEBUG:miio.miioprotocol:192.168.10.245:54321 (ts: 1970-01-01 07:41:19+00:00, id: 2) << {'error': {'code': -32602, 'message': 'need did'}, 'exe_time': 10, 'id': 2}
ERROR:miio.click_common:Exception: {'code': -32602, 'message': 'need did'}

@LZY-SPCA LZY-SPCA added the bug label Feb 15, 2024
@rytilahti
Copy link
Owner

This error is coming from the device and one could only guess that this device/firmware doesn't like the way this library is using the did in the requests. At the moment, this is used to store a simplified name, but perhaps this device requires a real did of the device?

You could try to use raw_command command of the tool with a payload you see in your debug logs, but replacing the did part with the real device id. You can find that id in the debug output of protocol responses, there's a field called device_id which has it as a hex-encoded string:

device_id = unhexlify('02f2abba')

For the raw payload, you want to convert this to an integer, for example using python:

python -c 'print(int("02f2abba", 16))'
49458106

Let me know if that helps!

@LZY-SPCA
Copy link
Author

I change all the did to real device id and it works, but when I run each property separately it can run without changing the did. I also use API to get single property from the device without did and it also works. However, if I get more than one property without changing the 'did' it just failed and say that I need 'did' .I'm confused.
QQ图片20240216163933

@rytilahti
Copy link
Owner

Yeah, that's a firmware bug. Let's keep this issue open, we need to add some type of quirk handling for such cases, likely by passing the real did for listed models.

@LZY-SPCA
Copy link
Author

Thank you so much!

@rytilahti rytilahti changed the title Can't control Mi Smart Power Plug 2 with miiocli Mi Smart Power Plug 2 (chuangmi.plug.212a01) requires real did for multirequests Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants