make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.44k stars 559 forks source link

Request support for Moes Smart Remote IR + RF #929

Closed mikekornikh closed 9 months ago

mikekornikh commented 1 year ago

Log Message

Please paste logs here

Information about DPS mappings

{
  "result": {
    "model": "{\"modelId\":\"000003g1hj\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[
{\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"scene_1\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景1\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},
{\"abilityId\":2,\"accessMode\":\"rw\",\"code\":\"scene_2\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景2\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},
{\"abilityId\":3,\"accessMode\":\"rw\",\"code\":\"scene_3\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景3\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},
{\"abilityId\":4,\"accessMode\":\"rw\",\"code\":\"scene_4\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景4\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},
{\"abilityId\":201,\"accessMode\":\"rw\",\"code\":\"ir_send\",\"description\":\"{“rf_type”:”sub_1g”,\\\"control\\\":\\\"send_rf\\\",\\\"type\\\":4, \\\"head\\\":\\\"xxxxxx\\\", \\\"key1\\\":\\\"xxxxxx\\\", \\\"key2\\\":\\\"xxxxxx\\\",\\\"key3\\\":\\\"xxxxxx\\\",\\\"key4\\\":\\\"xxxxxx“,\\\"sup_freq\\\":[xxx,xxx]}\\n\\n转义后:{\\\\“rf_type\\\\”:\\\\”sub_1g\\\\”,\\\\\\\"control\\\\\\\":\\\\\\\"send_ir\\\\\\\",\\\\\\\"type\\\\\\\":4,,\\\\\\\"head\\\\\\\":\\\\\\\"xxxxxx\\\\\\\", \\\\\\\"key1\\\\\\\":\\\\\\\"xxxxxx\\\\\\\", \\\\\\\"key2\\\\\\\":\\\\\\\"xxxxxx\\\\\\\", \\\\\\\"key3\\\\\\\":\\\\\\\"xxxxxx\\\\\\\", \\\\\\\"key4\\\\\\\":\\\\\\\"xxxxxx\\\\\\\",\\\\“sup_freq\\\\\\\":[xxx,xxx]}\",\"extensions\":{\"iconName\":\"icon-icon-test11\",\"attribute\":\"640\"},\"name\":\"红外控制下发\",\"typeSpec\":{\"maxlen\":3072,\"type\":\"string\",\"typeDefaultValue\":\"\"}},
{\"abilityId\":202,\"accessMode\":\"ro\",\"code\":\"ir_study_code\",\"description\":\"{“rf_type”:”sub_1g”,“mode”:”xxx”,”freq”:”xxx”,“rate”:”xxxx”,”data”:”xxxxxxxx”}\\n\\n红外的产品还按之前透传方案,sub_1g的产品使用JSON内容上传,服务端兼容判断是否可以解析出指定JSON,不能解析按红外数据处理\",\"extensions\":{\"iconName\":\"icon-shangsheng\",\"attribute\":\"640\"},\"name\":\"红外学习值上报\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}}]}]}"
  },
  "success": true,
  "t": 1690409774925,
  "tid": "090c00d12c0211ee8c70fe98ebe72f12"
}

Product ID

{ "result": [ { "active_time": 1666126701, "category": "wnykq", "create_time": 1666126701, "custom_name": "Smart Remote IR + RF", "icon": "smart/icon/ay1528464118385ZKFKv/b0578eb5f3107aa4022c2273abe8766b.jpg", "id": "ebe229606e735257e9ktrc", "ip": "24.46.216.121", "is_online": true, "lat": "40.6561", "local_key": "681d100ac90cefbc", "lon": "-73.9586", "model": "URF02", "name": "USB Smart Hub", "product_id": "wbaloeb3kiwwhads", "product_name": "USB智能遥控器(通用)", "sub": false, "time_zone": "-04:00", "update_time": 1690153118, "uuid": "3907e919ab35f54e" } ], "success": true, "t": 1690409884614, "tid": "4a64ed5b2c0211ee9fecaa50f188a4b0" } # Information about how the device functions This is a small thumb-drive-like device that works as an IR RF blaster for controlling non-smart devices via their remote interfaces. Here's the product page https://moeshouse.com/products/tuya-smart-infrared-wifi-remote-controller-wireless-usb-ir-rf-controller-for-tv-fan?pr_prod_strat=use_description&pr_rec_id=7165b43d0&pr_rec_pid=6619915092049&pr_ref_pid=6925853655121&pr_seq=uniform
make-all commented 1 year ago

Needs generic ir remote support for the ir_learn and ir_send commands.

The rest of the documentation for the "scene" functions does not make sense to me. An enum with a single value?

make-all commented 11 months ago

Are the scenes reported by the device? (logs are missing from the report).

If they are reported, then the device should be detectable, and support will be able to be added using the newly added remote entity support.

make-all commented 10 months ago

As no feedback was received and there are no logs attached, nothing further can be done on this issue.

antonio1475 commented 10 months ago

Hi @make-all I have a similar device (same category, wnykq)

{
  "result": {
    "active_time": 1690551857,
    "bind_space_id": "522747",
    "category": "wnykq",
    "create_time": 1690551857,
    "custom_name": " IR RF",
    "icon": "smart/icon/ay1503986080106Gppjy/7cd6190fa4857f03ec35e47494d267e9.png",
    "id": "bff0b9153273a733c508k1",
    "ip": "xxx",
    "is_online": true,
    "lat": "xx",
    "local_key": "xxx",
    "lon": "xxx",
    "model": "带射频IR",
    "name": " IR  controller Pro",
    "product_id": "0gawnyfgyneswent",
    "product_name": "IR Pro",
    "sub": false,
    "time_zone": "+02:00",
    "update_time": 1706959096,
    "uuid": "6d580661045f35f1"
  },
  "success": true,
  "t": 1707132820244,
  "tid": "68d530e8c41a11ee84c772fd0bbfcb23"
}

Query Things Data Model

{
  "result": {
    "model": "{\"modelId\":\"00000437be\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"scene_1\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景1\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},{\"abilityId\":2,\"accessMode\":\"rw\",\"code\":\"scene_2\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景2\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},{\"abilityId\":3,\"accessMode\":\"rw\",\"code\":\"scene_3\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景3\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},{\"abilityId\":4,\"accessMode\":\"rw\",\"code\":\"scene_4\",\"description\":\"{ \\\"range\\\": [ \\\"scene\\\" ], \\\"type\\\": \\\"enum\\\" }\",\"extensions\":{\"iconName\":\"icon-dp_mode\",\"attribute\":\"320\"},\"name\":\"场景4\",\"typeSpec\":{\"range\":[\"scene\"],\"type\":\"enum\",\"typeDefaultValue\":\"scene\"}},{\"abilityId\":201,\"accessMode\":\"rw\",\"code\":\"ir_send\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-icon-test11\",\"attribute\":\"2048\"},\"name\":\"红外控制下发\",\"typeSpec\":{\"maxlen\":3072,\"type\":\"string\",\"typeDefaultValue\":\"\"}},{\"abilityId\":202,\"accessMode\":\"ro\",\"code\":\"ir_study_code\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-shangsheng\",\"attribute\":\"2048\"},\"name\":\"红外学习值上报\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}}]}]}"
  },
  "success": true,
  "t": 1707133617748,
  "tid": "4424e592c41c11ee84c772fd0bbfcb23"
}

Get the instruction set of the device and Get the instruction set of the category report basically nothing

The Tuya Cloud Device logs show this: image

But I'm not able to do anything in Debugging (I can on other devices): image

Adding it to tuya-local: image And nothing can be done: image

tuya-local debug logs: home-assistant_tuya_local_2024-02-05T11-42-43.138Z.log

Would any of this be useful? I don't think so but let me know if there's anything I can do so that we can use ir_send I'm a bit lost on the current state of IR/RF remotes in tuya-local. Using send command obviously fails with "unknown error" image

Cheers

make-all commented 10 months ago

Your device is added as a remote entity. It does not appear to do anything useful in the UI (there is an on/off switch, but typically Tuya remotes do not support powering the remote off) as the main use of a remote is to learn and send commands, which is done through services, which you can access from the Developer tools menu.

First you need to learn some commands with remote.learn_command, which will be saved in HA under the device and command name you specify. Then you can send those commands from an automation, or button in the UI using the remote.send_command service specifying the same device and command name. Tuya-local remotes mostly works the same as Broadlink, but currently command_type is not implemented (only important if you have a device that supports both IR and RF sending through the same dp by passing some argument with the command).

antonio1475 commented 10 months ago

@make-all thank you. I'm getting there. The hircr_remote_control to which it matched originally doesn't have DPs 201 & 202, so I built a simple file for it:

name: Universal remote control Antonio test
products:
  - id: 0gawnyfgyneswent
  - id: wm7qot5liwuzm2yh
primary_entity:
  entity: remote
  dps:
    - id: 201
      name: send
      type: string
      optional: true
    - id: 202
      name: receive
      type: string
      optional: true
      persist: false

Now I can learn and send IR commands, and the file /homeassistant/.storage/tuya_local_remote_bff0b9153273a733c508k1_codes is created:

{
  "version": 1,
  "minor_version": 1,
  "key": "tuya_local_remote_bff0b9153273a733c508k1_codes",
  "data": {
    "aire": {
      "on19high": "4iCXECMCaAYjAiMCIwIjAiMCIwIjAmgGIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCaAYjAmgGIwIjAiMCaAYjAiMCIwIjAiMCIwIjAmgGIwJoBiMCaAYjAjB1",
      "cancel": "yyCXECQCYAYkAiQCJAIkAiQCJAIkAmAGJAIkAiQCJAIkAiQCJAJgBiQCJAIkAmAGJAJgBiQCJAIkAiQCJAIkAiQCJAIkAiQCJAIkAiQCJAIkAiQCJAIkAiQCJAIkAiQCJAIkAiQCYAYkAiQCJAJgBiQCYAYkAjB1",
      "off": "8yCUECMCZQYjAiMCIwIjAiMCIwIjAmUGIwIjAiMCIwIjAiMCIwJlBiMCZQYjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCZQYjAiMCIwJlBiMCIwIjAiMCIwIjAiMCZQYjAjB1"
    }
  }
}

According to the documentation those are supposed to be Base64 codes, and they also work if I send them manually like this:

service: remote.send_command
target:
  entity_id:
    - remote.universal_remote_control_antonio_test
data:
  command: >-
    b64:8yCUECMCZQYjAiMCIwIjAiMCIwIjAmUGIwIjAiMCIwIjAiMCIwJlBiMCZQYjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCIwIjAiMCZQYjAiMCIwJlBiMCIwIjAiMCIwIjAiMCZQYjAjB1

However, they are very different to the Base64 codes I had for my previous Broadlink (the equivalent to the OFF above would be JgBAAGkAAUITMRMQEhASEBIyEBISEBIQEjISMhIQEhASEBERERASEBIQEhAQEhIQEhASMhIQEjISEBIQEhASMhIADQUAAAAAAAAAAA== and if I use this style, it doesn't seem to work. Any idea about this difference? or how they can be converted. I'll do more research, I would hate to have to relearn all the combinations.

Anyway, IR works. However, RF it "starts" learning (led turns off, waiting for input) but it doesn't receive anything `Failed to call service remote.learn_command. Timeout'

You said

but currently command_type is not implemented (only important if you have a device that supports both IR and RF sending through the same dp by passing some argument with the command).

Based on my previous logs and screenshots (copied snippet below), it does seem like command_type is needed since RF is sent through the same DP? Is it not implemented in HA or in tuya-local?

{
   "rf_type":"sub_2g",
   "mode":0,
   "key1":{
      "times":6,
      "intervals":0,
      "delay":0,
      "code":"eyJudW0iOjEsInZlciI6IjIiLCJzdHVkeV9mZXEiOiI0MzMuMzciLCJkYXRhMCI6IkNpQUJBOWNBQkFFQkF3RUQxd0FCQXdRQkJBRUJBd1FCQVFNRUFRRURCQUVCQXdFREJBRUJBd1FCQVFNRUFRRURCQUVFQVFFREJBRUJBd0VEQkFFRUFRRURCQUVCQXdRQkFRTUVBUUVEQkFFQkF3RURCQUVFQVFFREJBRUJBd1FCQVFNRUFRRURBUVBYQUFFRDF3QUJBd1FCQkFFQkF3UUJBUU1CQXdRQkFRTUVBUVFCIiwibHYiOlswXX0="
   },
   "feq":0,
   "rate":0,
   "control":"rfstudy_send",
   "ver":"2"
}

Let me know if I should open a new issue, this one is re-opened (I'd say it's basically the same device based on the category and the DPs), or it stays closed as it is.

Thank you for your support!

antonio1475 commented 9 months ago

I just checked this. Can confirm that 68f591d works, for IR only.

RF commands time-out when learning (the device goes into learning mode but doesn't learn anything). I don't know if command_type being implemented would solve anything...?

image

Thanks

make-all commented 9 months ago

From the translated doc strings in the original report:

Infrared products are still according to the previous transmittal scheme, sub_1g products use JSON content upload, server-side compatibility to determine whether the specified JSON can be parsed, can not be parsed according to the infrared data treatment.

It looks like there are several differences in the JSON data format for both learn and send commands, but I'm not sure if I can find a full version of the documentation for this on the Tuya site.

ve1koz111 commented 9 months ago

Using 2 different (but i supposed) very similar IR blaster

2024-02-23 09:19:49.626 WARNING (MainThread) [custom_components.tuya_local.config_flow] Device matches rgb_led_strip with quality of 83%. DPS: {"updated_at": 1708640386.9190733, "20": false, "21": "scene", "24": "000003e803e8", "25": "07464602000003e803e800000000464602007803e803e80000000046460200f003e803e800000000464602003d03e803e80000000046460200ae03e803e800000000464602011303e803e800000000", "26": 0, "34": true} 2024-02-23 09:19:49.626 WARNING (MainThread) [custom_components.tuya_local.config_flow] Report this to https://github.com/make-all/tuya-local/issues/

Query properties: { "result": { "properties": [ { "code": "ir_send", "custom_name": "", "dp_id": 201, "time": 1672038997843, "value": "{\"control\":\"study_exit\"}" }, { "code": "ir_study_code", "custom_name": "", "dp_id": 202, "time": 1667888518142, "value": "dCOTET4CPgI+Aj4CPgI+Aj4CPgI+Aj4CPgI+Aj4CPgI+Aj4CPgJ/Bj4CfwY+An8GPgJ/Bj4CPgI+An8GPgJ/Bj4CfwY+An8GPgJ/Bj4CfwY+Aj4CPgI+Aj4CPgI+Aj4CPgI+Aj4CPgI+Aj4CPgIw8j4CfwY+An8GPgJ/Bj4CfwY+An8GPgL/n3QjyQg+AjDydCPJCD4CMHU=" } ] }, "success": true, "t": 1708640932687, "tid": "c1e466d6d1d111eeb4228e673063ebcd" }

Device details:

{ "result": [ { "active_time": 1666500550, "bind_space_id": "32896952", "category": "wnykq", "create_time": 1641619794, "custom_name": "", "icon": "smart/icon/ay1573546958261faWcj/31b66c3fccb8386e62bdd4c3ad273096.png", "id": "bf9b913131XXX "ip": "X "is_online": true, "lat": X "local_key": X "lon": "X "model": "HMS06CBU", "name": "Smart IR", "product_id": "wm7qot5liwuzm2yh", "product_name": "HMS06CBU红外遥控器", "sub": false, "time_zone": "+11:00", "update_time": 1707811927, "uuid": "e829390a67f60602" } ], "success": true, "t": 1708640967220, "tid": "d67c4657d1d111ee99065aa890dc07f7" }

make-all commented 9 months ago

The log is for an RGB lightbulb. Your remote supports only the dps 201 and 202, which means it does not send anything when idle, so is not detectable by this integration.