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

Multicast events from Aqara AC Partner #79

Open
aganov opened this issue Nov 22, 2017 · 11 comments
Open

Multicast events from Aqara AC Partner #79

aganov opened this issue Nov 22, 2017 · 11 comments

Comments

@aganov
Copy link

aganov commented Nov 22, 2017

Hello. Is it possible to enable LAN Protocol for the gateway, in order to accept device events from it? As I can see lumi.gateway.v3 have support for this feature, which can be enabled from the app. But when I try to enable it for the AC Partner (lumi.acparner.v1), instead of showing me
local area network communication protocol switch, it's showing me some JSON with gateway information:

{
  "fw_ver": "1.4.1_145",
  "hw_ver": "MW300",
  "model": "lumi.acparner.v1",
  "wifi_fw_ver": "SD8778x-14x76.36.p84-702.1.0-WM",
  "token": "....",
}

I was able to fetch some device's data from lumi.weather sensors, But I want to receive events from the ac partner (gateway) such as click, dobleclick from the lumi.switch devices.

device.on('action', action => /* do something useful */);

Thanks!

@mateutek
Copy link

I'm not sure if this will help you, but here is issue i found with device actions

I think i have figured out how to listen for the properties
When creating subdevice the this._propertiesToMonitor = []; is empty, but after getting the capabilities of the subdevice it should be automaticly filled.
For now i use such code to fix it by hand

device.devices.forEach(device =>{
    device.defineProperty('temperature',v=>v/100);
    device.defineProperty('humidity',v=>v/100);
    device.on('propertyChanged', data=> console.log(data));
}

@aholstenson
Copy link
Owner

Thanks for opening an issue! The library tries to activate the developer mode automatically when it connects to the AC Partner Gateway.

  1. Have you tested the developer mode with other libraries? Do they work?
  2. What is the model reported by the miio-command? lumi.acpartner.v1?
  3. Does miio --control deviceIdOrModel --method get_lumi_dpf_aes_key output something that looks like a secret key?

@aganov
Copy link
Author

aganov commented Nov 24, 2017

@aholstenson Thank you for your reply

  1. Nope, I've tried only miio
  2. After manually provided device token, I was able to get
Device ID: 54980697
Model info: Unknown
Address: 192.168.88.237
Token: ef77134c5f44e90c9dd629381da7fe69 via stored token
Support: Unknown

Device ID: 158d0001a68933
Model info: lumi.weather (sensor)
Address: Owned by 54980697
Token: Automatic via parent device
Support: At least basic

Device ID: 158d0001a1f9a1
Model info: lumi.weather (sensor)
Address: Owned by 54980697
Token: Automatic via parent device
Support: At least basic

Device ID: 158d0001a6751f
Model info: lumi.sensor_switch (controller)
Address: Owned by 54980697
Token: Automatic via parent device
Support: At least basic

PS: I've added lumi.sensor_switch.aq2 (Squared wifi switch) ID: 51. I will submit pull request once I'm able to make it work...

 INFO  Attempting to control 54980697

 INFO  Got result:
[
  "hcgx2cz7epswqma1"
]
  1. inspect
 INFO  Attempting to inspect 54980697

Device ID: 54980697
Model info: lumi.acpartner.v1 (gateway)
Address: 192.168.88.237
Token: ef77134c5f44e90c9dd629381da7fe69 via stored token
Support: At least basic

Firmware version: 1.4.1_145
Hardware version: MW300
MCU firmware version: 0143

WiFi: JackU (6C:3B:6B:07:35:00) RSSI: -65
WiFi firmware version: SD878x-14.76.36.p84-702.1.0-WM

Remote access (Mi Home App): UDP

Properties:
  - illuminance: 231
  - rgb: { red: 0, green: 0, blue: 0 }
  - brightness: 0

@aholstenson
Copy link
Owner

It looks like miio has enabled the LAN protocol (developer API) so you should be seeing events coming in. The only thing that looks a bit weird is that it's listed as a generic model when you run discover.

I'm currently looking at the multicast events as several users have reported similar issues and I've experienced a few weird cases when testing the gateway using different WiFi-setups.

@aganov
Copy link
Author

aganov commented Dec 11, 2017

Can anyone confirm that acpartner.v1 emitting multicast events? LASER-Yi mentioned here that

Xiaomi didn't make LAN protocol for AC Partner.

Currently, ac partner emitting just some dns traffic (udp/53), which I can fetch via tcpdump.

Edit: Seems like ac partner (v1 and v2) are commented here - http://bbs.xiaomi.cn/t-13665990 But I've lost myself in translation. Google Translate did not help much here.

@aholstenson
Copy link
Owner

Sorry I've been assuming that it supports the Developer API as its possible to call set_lumi_dpf_aes_key without errors. So yes, would be great if anyone can confirm that it actually has support. Or that it doesn't.

@cxlwill
Copy link

cxlwill commented Dec 15, 2017

@aganov Let me do a quick translation for you. The result of discussion is no, AC partner failed to open port 9898, which normal gateway use. Another interesting thing is that in the latest iOS (Only) MiHome App Xiaomi open the entrance for AC partner to get gateway KEY. That's quite awkward because firmware itself didn't update to follow it. So even you get the KEY successfully, miIO could not get response of AC partner.

@aholstenson
Copy link
Owner

Thank you for the translation and help with this. For now I'm thinking that the next release will implement support for the actual AC-control of the gateway and hide details about the child devices.

Let's hope that support for the developer API is added later on, it would be nice for people to be able to use the AC Partner Gateway as the other gateway.

@cxlwill
Copy link

cxlwill commented Mar 4, 2018

Well, the good news finally launches. With the latest miio and miio discover, here's the result:

Device ID: 59846390
Model info: lumi.acpartner.v2
Address: 192.168.50.236
Token: xxxxx via stored token
Support: At least basic

Device ID: 158d0001872099
Model info: lumi.switch
Address: Owned by miio:59846390
Token: Automatic via parent device
Support: At least basic

And I used nc tool to check the UDP port: nc -uz ac_ip 9898. Here's the result:
Connection to ac_ip port 9898 [udp/monkeycom] succeeded!

I think finally the UDP/TCP port of AC partner is open and we can regard it as gateway. I'm willing to do further test.

@Etran-H
Copy link

Etran-H commented Mar 5, 2018

@aganov

http://bbs.xiaomi.cn/t-13665990

这篇帖子中还提到在node_modules\miio\lib\models.js 中把它作为gateway 识别可以得到如下信息。
This post also mentions that node_modules\miio\lib\models.js recognizes it as gateway to get the following information.

http://cdn.fds.api.xiaomi.com/b2c-bbs/cn/attachment/07b1c970cda6c9d6fb5810a1df1d5631.txt

他认为无法使用9898端口的协议,但可以使用54321端口的协议。
He thought it was impossible to use the 9898 port protocol, but could use the 54321 port protocol.

Translate using Google Translate.

@cxlwill
Copy link

cxlwill commented Mar 5, 2018

不过当时他发贴的时候是伴侣的9898端口还未开放,现在倒是开放了,原因是绿米启用了二代的局域网通信协议。我还是希望绿米可以 Update 一下它们的技术文档这样让大家可以更清晰地探索这个问题。
Translate: At that time, Port 9898 of AC partner is blocked. But now Aqara open it, I guess they started to use second version of protocol. Hope they update the Dev Docs actively.

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

No branches or pull requests

5 participants