xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"
https://xzetsubou.github.io/hass-localtuya/
GNU General Public License v3.0
287 stars 30 forks source link

[Bug]: S11 PRo IR RF Remote Gateway not wrking #211

Closed vimalv4u closed 2 months ago

vimalv4u commented 2 months ago

LocalTuya Version

3.2.5.2b6

Home Assistant Version

2024.4.4

Environment

What happened?

My smart IR remote control SR11 IR RF pro showing this error after attempting automatic setup. If I add 0 as per the #189 bug report, it does add, but I can't get it to work. The gateway category is "wnykq" still other remote control I integrated does not work. I have attached the discovery log for the current device set below. One is IR, which is my AC, and the other one is RF, which is my Garage door. Any help would be great. I been trying to get it work for while to get local control but till now not managed to do so. I just found this GitHub repo and find it more promising.

config_entry-localtuya-78d9168c469bf79b2941c54e69c8361e_New2.json

Steps to reproduce.

I have added the device using DPID 0 but do not know how to make it work. I have tried adding this several times and in several ways. The Gateway DPID, as per Tuya standard instructions, are ir_send and ir_study_code, and they correspond to DPIS 201 and 202. The RF remote standard instructions are scene_1, scene_2, scene_3, scene_4, ir_send, and ir_study_code. The DPIs are 1,2,3,4,201 and 202. I could not see any activity in this device when I used the Smart Tuya app. All activities were in the Gateway device. The AC IR Remote I have not got that far, but all controls are showing activity on this device, but this device will not get auto-discovered in local tuya. In Tuya portal those devices are listed under category "qn".

Relevant log output

No response

Diagnostics information.

No response

vimalv4u commented 2 months ago

Kindly find the IR Send for Garage Door from Tuya portal. 2024-04-26 23:10:30 Publish ir_send {"rf_type":"sub_2g","mode":0,"key1":{"times":6,"intervals":0,"delay":0,"code":"eyJudW0iOjEsInZlciI6IjIiLCJzdHVkeV9mZXEiOiI0MzMuODIiLCJkYXRhMCI6ImVnOFBBNFVCRHdPMUFROERoUUVQQTdVQkR3T0ZBUThEdFFFUEE0VUJoUUVQQTRVQkR3T0ZBUThEaFFFUEE0VUJEd09GQVE4RER3T0ZBWVVCRHdNUEE0VUJEd09GQVE4RGhRRVBBNFVCRHdPMUFROERoUUdGQVE4RER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PR0FZWUJURCtHQVlZQmhnR0dBWVlCaGdHR0FZWUJoZ0dHQVlZQmhnR0dBWVlCaGdHMUFZWUJ0UUdHQVlZQmhnRzFBWVlCIiwibHYiOlswXX0="},"feq":0,"rate":0,"control":"rfstudy_send","ver":"2"} cloud

And for the AC 2024-04-26 23:53:37 Report Switch on device itself
2024-04-26 23:53:37 Report Mode Heat device itself
2024-04-26 23:53:37 Report Temperature 21 device itself
2024-04-26 23:53:37 Report Air volume low device itself

AC Standard Instruction set

Code Type Values F ENUM
{ "min": 0, "max": 3, "scale": 0, "step": 1, "type": "Integer" } M ENUM
{ "min": 0, "max": 4, "scale": 0, "step": 1, "type": "Integer" } PowerOff STRING
"PowerOff" PowerOn STRING
"PowerOn" T ENUM
{ "min": 16, "max": 30, "scale": 0, "step": 1, "type": "Integer" } AC Standard Status Set Code Type Values wind ENUM
{ "min": 0, "max": 3, "scale": 0, "step": 1, "type": "Integer" } mode ENUM
{ "min": 0, "max": 4, "scale": 0, "step": 1, "type": "Integer" } power BOOLEAN {} temp ENUM
{ "min": 16, "max": 30, "scale": 0, "step": 1, "type": "Integer" }

xZetsubou commented 2 months ago

RF currently isn't supported and I don't have RF Remote to go more deep into it.

I think there's misunderstanding here you can't add the devices that has been created using Remote device in Tuya Apps. such as Garage Door or Aircon Living Room because these device created and useable from Tuya IoT only.

LocalTuya works different you will need to learn/send the command your self using learn_command and send_command services in Home Assistant the button codes that learned will be saved in .storage This a guide of the concept https://youtu.be/lWCHZm9xWno?t=189

vimalv4u commented 2 months ago

Perfect thanks for the quick response. I will try it out and let you know.

vimalv4u commented 2 months ago

@xZetsubou i tried the learning as u sujested and did not work. I got the following message on HA. Anything I am missing hear.

Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/commands.py:798 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 4:31:00 PM (1 occurrences) Last logged: 4:31:00 PM

[547096917568] Failed to learn: start

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:1933 First occurred: 4:31:00 PM (1 occurrences) Last logged: 4:31:00 PM

websocket_api script: Error executing script. Error for call_service at pos 1: Failed to learn: start

xZetsubou commented 2 months ago

Enable the debug for both device and integration Report a bug and paste the logs here when error raised.

vimalv4u commented 2 months ago

I deleted the device and read it, restarting HA. It seems to have fixed the error. It learned the command. Let me keep going at it.

xZetsubou commented 2 months ago

If something went wrong feel free to reply.

vimalv4u commented 2 months ago

Is there a way to get the current temperature using this method? Also, somehow, once I was testing, I managed to get the RF key learning into the storage folder to localtuya config. I deleted and restarted to learn new code and now I do not know how I managed to make it work, RF is something you will look into in the feature. It's the same scenario as IR, but the IR_send command has some additional parameters while learning and sending for RF. IR_Study code seems similar in Tuya Device log. IR Code.txt

xZetsubou commented 2 months ago

If you mean the temperature of the device you are controlling, then no, this is an IR remote it can't know what device type that begins controlled of.

Actually, it's opposite RF is the one who has more parameters. There was an attempt to add RF support, but the user who was testing it said it didn't work for him. You can give it a try. Replace yourcustom_components/localtuya/remote.py

with this https://github.com/xZetsubou/hass-localtuya/blob/support_rf_commands/custom_components/localtuya/remote.py

vimalv4u commented 2 months ago

Let me try and get back. Thanks for the support man.

vimalv4u commented 2 months ago

I got this error when i replaced the remote.py file and restarted HA. Log details (ERROR) Logger: homeassistant.setup Source: setup.py:316 First occurred: 2:19:23 PM (1 occurrences) Last logged: 2:19:23 PM

Setup failed for custom integration 'localtuya': Unable to import component: No module named 'custom_components.localtuya.common' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 979, in async_get_component comp = await self.hass.async_add_import_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1037, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/localtuya/init.py", line 54, in CONFIG_SCHEMA = config_schema() ^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 1160, in config_schema platform_schema(plats, range(1, 256), yaml=True) for plats in PLATFORMS.values() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 1125, in platform_schema return vol.Schema(schema).extend(flow_schema(platform, dps_strings)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 1143, in flow_schema return import_module("." + platform, integration_module).flow_schema(dps_strings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/localtuya/remote.py", line 32, in from .common import LocalTuyaEntity, async_setup_entry ModuleNotFoundError: No module named 'custom_components.localtuya.common'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 316, in _async_setup_component component = await integration.async_get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 997, in async_get_component self._component_future.result() File "/usr/src/homeassistant/homeassistant/loader.py", line 989, in async_get_component comp = self._get_component() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1037, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/localtuya/init.py", line 54, in CONFIG_SCHEMA = config_schema() ^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 1160, in config_schema platform_schema(plats, range(1, 256), yaml=True) for plats in PLATFORMS.values() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 1125, in platform_schema return vol.Schema(schema).extend(flow_schema(platform, dps_strings)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/localtuya/config_flow.py", line 1143, in flow_schema return import_module("." + platform, integration_module).flow_schema(dps_strings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/config/custom_components/localtuya/remote.py", line 32, in from .common import LocalTuyaEntity, async_setup_entry ModuleNotFoundError: No module named 'custom_components.localtuya.common'

xZetsubou commented 2 months ago

I updated the file to make it works with the latest localtuya version copy it again and paste on your local remote.py https://github.com/xZetsubou/hass-localtuya/blob/support_rf_commands/custom_components/localtuya/remote.py

vimalv4u commented 2 months ago

The remote failed to learn the code and I got this error. I will upload the debug log soon. Also just noticed when i learn RF command the device blue light do not turn on.

image

image

The Debug Log is attached I have also included web socket logs. I have sanitised the log. @xZetsubou

home-assistant_localtuya_2024-04-28T08-37-36.351Z.log

vimalv4u commented 2 months ago

The Query thing data model for RF looks something like below { "result": { "model": "{\"modelId\":\"000002vhjq\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[{\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"scene_1\",\"description\":\"{ \\"range\\": [ \\"scene\\" ], \\"type\\": \\"enum\\" }\n\",\"extensions\":{\"attribute\":\"256\"},\"name\":\"场景1\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"scene\"]}},{\"abilityId\":2,\"accessMode\":\"rw\",\"code\":\"scene_2\",\"description\":\"{ \\"range\\": [ \\"scene\\" ], \\"type\\": \\"enum\\" }\n\",\"extensions\":{\"attribute\":\"256\"},\"name\":\"场景2\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"scene\"]}},{\"abilityId\":3,\"accessMode\":\"rw\",\"code\":\"scene_3\",\"description\":\"{ \\"range\\": [ \\"scene\\" ], \\"type\\": \\"enum\\" }\n\",\"extensions\":{\"attribute\":\"256\"},\"name\":\"场景3\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"scene\"]}},{\"abilityId\":4,\"accessMode\":\"rw\",\"code\":\"scene_4\",\"description\":\"{ \\"range\\": [ \\"scene\\" ], \\"type\\": \\"enum\\" }\n\",\"extensions\":{\"attribute\":\"256\"},\"name\":\"场景4\",\"typeSpec\":{\"type\":\"enum\",\"range\":[\"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\":{\"attribute\":\"640\"},\"name\":\"红外控制下发\",\"typeSpec\":{\"type\":\"string\",\"maxlen\":3072}},{\"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\":{\"attribute\":\"640\"},\"name\":\"红外学习值上报\",\"typeSpec\":{\"type\":\"raw\",\"maxlen\":128}}]}]}" }, "success": true, "t": 1714351580528, "tid": "e537ba4905c111ef9a8e62f092a4528b" }

xZetsubou commented 2 months ago

Similar to that last logs you sent can you enable the debug for the device but try learn/send RF command from Tuya app. we may get something in the logs.

vimalv4u commented 2 months ago

Yp, it seems to learn some commands. Please find the log below.

home-assistant_localtuya_2024-04-29T04-30-16.777Z.log

xZetsubou commented 2 months ago

In the logs it seems you were trying to learn/send from Home Assistant, Can you try learn/send from Tuya app or smart life app.

vimalv4u commented 2 months ago

In the logs it seems you were trying to learn/send from Home Assistant, Can you try learn/send from Tuya app or smart life app.

No I used the SmartLife app for the learning. I did not save the learning. Do you want me to save it. I just learned and quit the learning once the shutter opened.

The log from Tuya API 2024-04-29 16:46:48 Device semaphore Device semaphore signal intensity:-55||Remaining memory:31832||UTC:1714373208||DST:1714373208 device itself
2024-04-29 15:46:48 Device semaphore Device semaphore signal intensity:-58||Remaining memory:31832||UTC:1714369608||DST:1714369608 device itself
2024-04-29 14:46:48 Device semaphore Device semaphore signal intensity:-56||Remaining memory:31832||UTC:1714366008||DST:1714366008 device itself
2024-04-29 14:29:08 Report ir_study_code eyJudW0iOjEsInZlciI6IjIiLCJzdHVkeV9mZXEiOiI0MzMuMzQiLCJkYXRhMCI6InRROFBBNU1Ca3dFUEF3OERrd0dUQVE4RER3T1RBWk1CRHdNUEExY0Jrd0VQQTVNQkR3T1RBUThEa3dFUEExY0JEd09UQVE4RGt3RVBBdzhEa3dFUEE1TUJEd09UQVE4RGt3RVBBNU1CRHdPVEFROERrd0dUQVE4RER3T1RBUThEa3dFUEE1TUJEd09UQVE4RGt3RVBBNU1Ca3dFUEF3OERrd0VQQTVNQmt3RVBBNU1CRHdNUEE1TUJrd0VQQXc4RGt3R1RBUThEa3dFUEF3OERrd0dUQVE4RGt3RVBBdzhEa3dHVEFROERWd0VQQTVNQkR3T1RBUThERHdPVEFaTUJEd01QQTVNQkR3T1RBUThEa3dFUEE1TUJEd09UQVE4RGt3RVBBNU1CRHdPVEFROERrd0VQQTVNQkR3T1RBUThEa3dFUEE1TUJrd0VQQXc4RGt3RVBBNU1CRHdPVEFaTUJLeitUQVpNQmt3R1RBWk1Ca3dHVEFaTUJrd0dUQVpNQmt3RlhBWk1Ca3dHVEFWY0Jrd0ZYQVpNQmt3R1RBVmNCIiwibHYiOlswXX0= device itself
2024-04-29 13:46:19 Device semaphore Device semaphore signal intensity:-57||Remaining memory:37992||UTC:1714362379||DST:1714362379