msillano / IoTwebUI

WEB APP for Tuya, with customizable functions that increase the performance of your IoT system
MIT License
1 stars 0 forks source link

permission deny call to homes #12

Open yersey20037 opened 3 months ago

yersey20037 commented 3 months ago

Hello, your project seems very interesting to me. I try to run it but I get this error message. Do you know what permission this refers to?

Captura de pantalla 2024-07-10 221500

msillano commented 3 months ago

The message 'Token expires...' is OK and proves that your Tuya login details are accepted!

The TUYA ERROR is about the API (the second is consequential): Cloud Services - API Reference - Smart Home - Smart Home Basic Service - Home Management - Search for Home (You can see it in Tuya documentation)

From Tuya documentation we get: 1106 | permission deny | No permission. | You are not authorized to access the API or device. Find the error details by TID from the API logs, or check if the device has been linked.


We need to find the source of the error, but I can't duplicate the situation so I would appreciate your cooperation. What I can do is ignore the error: But the presence of one Home is essential.!

Do you have one Home defined? (in SmartLife 'Home Management' page)? Could you try to define one home? You should provide me with information on the structure of the Home you use, whether you are the 'administrator' etc...

msillano commented 3 months ago

immagine_2024-07-12_133500913

I tested a patch that you can apply yourself, so as not to block the program. In the file 'tuyaui02.1.js': before:

  445      sleep(20);
  446       const h = callAPI('GET', "/v1.0/homes/" + home);

after:

  445      sleep(20);
  446       const h = callAPI('GET', "/v1.0/homes/" + home)  || {} ;

In the image, how the tree looks without 'homes': devices are still grouped by 'rooms', but they are isolated. Best regards

If you confirm that working, I will put it in ver 2.2.

yersey20037 commented 3 months ago

Hi, When reviewing the code I see that after obtaining the token, the next step consults the existing spaces and the next one uses the id of the space found to consult as a home but that is not the id of the home but of the space.

msillano commented 3 months ago

It's correct. "Space" is an abstraction introduced with the API ver 2, The smart-home definitions ("home", "room",...) are derived from the abstract space definitions. (ver.1). The code is correct and works (usually). :)

Again: the problem is the Tuya ERROR in the API call. :( I think the problem is in your "Home" definitions. Send a screenshot of SmartLife Home page.

Have you set the correct "const data_center" in 'config.js' ? ERRATA "I think so, because you received the correct token... " CORRIGE the token is independent from 'data_center' definition !

msillano commented 3 months ago

I confirm: after further tests, the cause of this behavior is caused by an error in the "data_center" value in 'config.js': not consistent with the one used by SmartLife/Tuya. See https://github.com/tuya/tuya-home-assistant/wiki/Countries-Regions-and-Tuya-Data-Center

Updated user 'configuration' instructions.

Sincerely In version 2.2 I will capture the error and add a specific warning.