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

Add support for MI Air Conditioner Companion MCN #52

Closed
jianyun8023 opened this issue Jul 1, 2021 · 14 comments
Closed

Add support for MI Air Conditioner Companion MCN #52

jianyun8023 opened this issue Jul 1, 2021 · 14 comments

Comments

@jianyun8023
Copy link

jianyun8023 commented Jul 1, 2021

Hello,

Would it be possible to add support for the Mi Air Conditioner Companion MCN?

Model: lumi.acpartner.mcn02
SKU: KTBL03LM
Link: https://www.mi.com/buy/detail?product_id=9726

When setup in the plugin, it seems to connect successfully and is seen as a switch, but there are no additional controls.
I see that python-miio has his support, you can refer to python-miio#809.
If there is anything I can provide (logs, testing, etc.), I would be happy to help the best I can.

@merdok
Copy link
Owner

merdok commented Jul 1, 2021

Hi,

I am wondering myself how this actually works that outlets can be air conditioners?😅

Anyway, yes adding support for the device should be straight forward, the only thing which we will need to find out if this is actually a miio or miot device. From the issue you linked I saw that they use miio commands. When you right now add the device when you try to use the switch, does it actually do anything? Could you post debug log when you use the switch so we can check out if the device accepts the command?

If the device does not accept miot commands locally then I can use the MiCloud to make it work. So we just need to figure out if the device can be controlled locally using miot or if it requires MiCloud...

@jianyun8023
Copy link
Author

The air conditioner on the socket, I researched some time ago, it should be a miot device.

https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:air-conditioner:0000A004:lumi-mcn02:1

The following is the desensitization log of homebridge:
hb.log

@merdok
Copy link
Owner

merdok commented Jul 1, 2021

What i can see from the log is that the property fetch call times out and this is a strong indicator that the device is not a miot device. Older devices use the old miio protocol but xiaomi built in a translator in the cloud to convert the miot commands from the specs which you posted here to local miio commands. So yes, i can add support for the device but it will require a MiCloud connection. You can also already check out now if the device will work with MiCloud by adding the following lines to your device config in the config.json:

"micloud":
 {
          "username": "email",
          "password": "pwd",
          "country": "cn",
         "forceMiCloud": true
},

Add your username and password and also the cloud country where your devices are located. That should make the device successfully sync the power property. Let me know if that is the case, and then i will add it.

@jianyun8023
Copy link
Author

jianyun8023 commented Jul 1, 2021

@merdok Thanks for your help~
I use micloud to successfully control the power switch.

[7/2/2021, 12:36:20 AM] [miot] [lumi.acpartner.mcn02] Splitting properties into chunks. Number of chunks: 1. Chunk size: 14
[7/2/2021, 12:36:20 AM] [miot] [lumi.acpartner.mcn02] Chunks:  [
 [
  "power"
 ]
]
[7/2/2021, 12:36:20 AM] [miot] [lumi.acpartner.mcn02] MiCloud request https://api.io.mi.com/app/miotspec/prop/get - {"_nonce":"oFnyPHZXxsIBnUyE","data":"{\"params\":[{\"did\":\"333641900\",\"siid\":2,\"piid\":1}]}","signature":"Sg+tJCHFHghc/v4MAw5b+PmXf8in3bV5850z+3/2MBA="}
[7/2/2021, 12:36:20 AM] [miot] [lumi.acpartner.mcn02] Device properties updated: 
 [
  {
    "name": "power",
    "value": true
  }
]

[7/2/2021, 12:38:01 AM] [miot] [lumi.acpartner.mcn02] Set power property request! RAW: {"did":"333641900","siid":2,"piid":1,"value":false}
[7/2/2021, 12:38:01 AM] [miot] [lumi.acpartner.mcn02] MiCloud request https://api.io.mi.com/app/miotspec/prop/set - {"_nonce":"fksI9hG/ZPsBnUyG","data":"{\"params\":[{\"did\":\"333641900\",\"siid\":2,\"piid\":1,\"value\":false}]}","signature":"ja9ky0UA/1LBaw0TFzb6iZYspc/9OyxrTl1XaCtDDYE="}
[7/2/2021, 12:38:01 AM] [miot] [lumi.acpartner.mcn02] Successfully set property power to value false! Response: [{"did":"333641900","siid":2,"piid":1,"code":0}]
[7/2/2021, 12:38:02 AM] [miot] [lumi.acpartner.mcn02] Set power property request! RAW: {"did":"333641900","siid":2,"piid":1,"value":true}
[7/2/2021, 12:38:02 AM] [miot] [lumi.acpartner.mcn02] MiCloud request https://api.io.mi.com/app/miotspec/prop/set - {"_nonce":"M2r43PuZa+MBnUyG","data":"{\"params\":[{\"did\":\"333641900\",\"siid\":2,\"piid\":1,\"value\":true}]}","signature":"F435MotsgSn+t/+VryCDV9bgz5QpS6y/PwSuS6W+wxo="}
[7/2/2021, 12:38:02 AM] [miot] [lumi.acpartner.mcn02] Successfully set property power to value true! Response: [{"did":"333641900","siid":2,"piid":1,"code":0}]

image

@merdok
Copy link
Owner

merdok commented Jul 1, 2021

Perfect! So as expected this is a miio device. I will add full support for it in the next update! Will let you know when the update is ready!

@jianyun8023
Copy link
Author

@merdok Wow, that’s great~ Thank you very much.

@merdok
Copy link
Owner

merdok commented Jul 4, 2021

Version 0.9.7 is now online with support for the device. Please try it and let me know!

@ahmadnazirafiq
Copy link

ahmadnazirafiq commented Jul 18, 2021

Hi,

Works great. However, when trying to tap and hold the tile in the Home app, it defaults to OFF thus turning it back off everytime I wanted to adjust the temperature. Also, the temperature meter stated 0.0 all the time.

IMG_9564

Here's the log on the dashboard:

[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Poll failed 4 times in a row! Stopping polling and trying to reconnect!
(node:11151) UnhandledPromiseRejectionWarning: TypeError: this.getDevice(...).supportsSwingModes is not a function
at AirConditionerAccessory.updateDeviceStatus (/usr/local/lib/node_modules/homebridge-miot/lib/modules/airconditioner/AirConditionerAccessory.js:245:56)
at LumiAcpartnerMcn02. (/usr/local/lib/node_modules/homebridge-miot/index.js:126:33)
at LumiAcpartnerMcn02.emit (events.js:387:35)
at /usr/local/lib/node_modules/homebridge-miot/lib/protocol/MiotDevice.js:221:16
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:11151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 27)
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Connected to device: lumi.acpartner.mcn02
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Setting up device!
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Doing device specific setup
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Device requires MiCloud! Trying to connect!
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Successfully connected to MiCloud!
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Doing initial property fetch
[18/07/2021, 10:26:53] [homebridge-miot] [Aircond] Device setup finished! Device ready, you can now control your device!
[18/07/2021, 10:27:14] [homebridge-miot] [Aircond] Poll failed 4 times in a row! Stopping polling and trying to reconnect!
(node:11151) UnhandledPromiseRejectionWarning: TypeError: this.getDevice(...).supportsSwingModes is not a function
at AirConditionerAccessory.updateDeviceStatus (/usr/local/lib/node_modules/homebridge-miot/lib/modules/airconditioner/AirConditionerAccessory.js:245:56)
at LumiAcpartnerMcn02. (/usr/local/lib/node_modules/homebridge-miot/index.js:126:33)
at LumiAcpartnerMcn02.emit (events.js:387:35)
at /usr/local/lib/node_modules/homebridge-miot/lib/protocol/MiotDevice.js:221:16
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:11151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 28)
[18/07/2021, 10:27:14] [homebridge-miot] [Aircond] Connected to device: lumi.acpartner.mcn02
[18/07/2021, 10:27:14] [homebridge-miot] [Aircond] Setting up device!
[18/07/2021, 10:27:14] [homebridge-miot] [Aircond] Doing device specific setup
[18/07/2021, 10:27:14] [homebridge-miot] [Aircond] Device requires MiCloud! Trying to connect!
[18/07/2021, 10:27:15] [homebridge-miot] [Aircond] Successfully connected to MiCloud!
[18/07/2021, 10:27:15] [homebridge-miot] [Aircond] Doing initial property fetch
[18/07/2021, 10:27:15] [homebridge-miot] [Aircond] Device setup finished! Device ready, you can now control your device!

@merdok
Copy link
Owner

merdok commented Jul 18, 2021

I think you do not have the latest version of the plugin hece there is the the error in the console. Please update to the latest version.

The temperature will be reported as 0.0 by the accessory since the device does not support temperature reporting

@ahmadnazirafiq
Copy link

ahmadnazirafiq commented Jul 18, 2021

Hi,

Appreciate your response. The plugin runs on the latest version tho, which is 0.9.7.

As for the temperature report, maybe if it could follow the temperature we manually adjust in the tile? I’m using a separate “Mi Heatercooler” plugin for the the old version of Mi Air Conditioner Controller and it does that.

@merdok
Copy link
Owner

merdok commented Jul 18, 2021

Ah, you are right, it will be fixed in the next update. Also after the update the tile will show the temperature which you set.

@ahmadnazirafiq
Copy link

Thank you! You're awesome!

@merdok
Copy link
Owner

merdok commented Jul 25, 2021

Should now be fixed in version 0.9.8

@ahmadnazirafiq
Copy link

Hi,

I can confirmed that its fixed now. Works really well. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants