rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.55k stars 543 forks source link

Can't do anything with chuangmi.remote.v2 #1020

Open oblitum opened 3 years ago

oblitum commented 3 years ago

Hi, first thanks for this project.

I have a Xiaomi IR Remote, and I have got the token as instructed:

{
  "code": 0,
  "message": "ok",
  "result": {
    "list": [
      {
        "did": "106967454",
        "token": "<redacted>",
        "longitude": "<redacted>",
        "latitude": "<redacted>",
        "name": "Remote control",
        "pid": "0",
        "localip": "<redacted>",
        "mac": "<redacted>",
        "ssid": "<redacted>",
        "bssid": "<redacted>",
        "parent_id": "",
        "parent_model": "",
        "show_mode": 1,
        "model": "chuangmi.remote.v2",
        "adminFlag": 1,
        "shareFlag": 0,
        "permitLevel": 16,
        "isOnline": true,
        "desc": "Device online ",
        "extra": {
          "isSetPincode": 0,
          "fw_version": "2.0.6_0006",
          "needVerifyCode": 0,
          "isPasswordEncrypt": 0
        },
        "uid": 6444606189,
        "pd_id": 65567,
        "password": "",
        "p2p_id": "",
        "rssi": -30,
        "family_id": 0,
        "reset_flag": 0
      },
      {
        "did": "ir.1384676911791915008",
        "token": "",
        "longitude": "<redacted>",
        "latitude": "<redacted>",
        "name": "TV Remote Control",
        "pid": "15",
        "localip": "",
        "mac": "",
        "ssid": "<redacted>",
        "bssid": "<redacted>",
        "parent_id": "106967454",
        "parent_model": "chuangmi.remote.v2",
        "show_mode": 1,
        "model": "miir.tv.ir01",
        "adminFlag": 1,
        "shareFlag": 0,
        "permitLevel": 16,
        "isOnline": true,
        "desc": "Device online ",
        "extra": { "isSetPincode": 0 },
        "uid": 6444606189,
        "pd_id": 65725,
        "password": "",
        "p2p_id": "",
        "rssi": 0,
        "family_id": 0,
        "reset_flag": 0
      }
    ],
    "virtualModels": [
      { "model": "zhimi.airpurifier.m1", "state": 0, "url": "" },
      { "model": "yunmi.waterpurifier.v2", "state": 0, "url": "" },
      { "model": "zimi.powerstrip.v2", "state": 0, "url": "" }
    ]
  }
}

In the Mi Home application, I've easily set up a kind of "sub device" for this universal IR, which is a "TV Remote Control" as can be seen. I have no idea whether I'm able to control this child device as it doesn't have a token itself, only the parent remote has it. It would be great if possible to get the button hex/raw codes or something.

I've tried to "learn" commands with miiocli chuangmiir --ip <remote ip> --token <remote token> learn 1 but miiocli instantly returns "Learning command into storage key 1 ['ok']", and a read shows the slot now has a raw code but it actually doesn't learn anything, no idea where these codes are coming from. I don't understand why it doesn't wait for me to click my TV control to read the IR code, as it happens from Mi Home app, and since it can't learn any code, I'm out of ideas how to send them.

At this moment I'm trying to find any hex code that works for my remote to trying sending it raw without the learning step, so far, no luck with it either.

frest-de commented 2 years ago

I have the same problem, the learn command does not work anymore. It returns "OK" immediately, but does not learn anything. Sending the commands still works. Learning did work some months ago with the same device. ;)

rytilahti commented 2 years ago

Maybe they changed the protocol for learning? These devices are black boxes, and there isn't much that can done if they suddenly change the protocol besides that someone figures out how to do the same with an updated firmware, and update the code accordingly.