Kakise / homebridge-tuya-door-cloud

Homebridge plugin to add support for door sensors
GNU General Public License v3.0
5 stars 0 forks source link

Problem with the iot Tuya api, wrong response returned #3

Open skyfacexD opened 2 years ago

skyfacexD commented 2 years ago

[7/6/2021, 10:04:05 AM] [homebridge-tuya-door-cloud] This plugin threw an error from the characteristic 'Target Position': Unhandled error thrown inside read handler for characteristic: Cannot read property 'expire_time' of undefined. See https://git.io/JtMGR for more info. (node:9049) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'expire_time' of undefined at /usr/local/lib/node_modules/homebridge-tuya-door-cloud/src/tuyaContactSensor.ts:88:44 at processTicksAndRejections (internal/process/task_queues.js:95:5) at TuyaApi.getDoorSensorStatus (/usr/local/lib/node_modules/homebridge-tuya-door-cloud/src/tuyaContactSensor.ts:102:5)

Kakise commented 2 years ago

Hello !

Could you please start homebridge in debug mode (homebridge -D) so I can have more logs ? Also please attach your config files (make sure to delete the sensitive parts like your api key, secret, and device ids)

EDIT: it seems that the problem resides in the api throwing an error, so I suspect that you don't have the proper permissions for your API endpoint

skyfacexD commented 2 years ago

Hey, How I can start homebridge in debug mode?

My config: { "bridge": { "name": "Homebridge XXXX", "username": "XX:XX:XX:XX:XX:XX", "port": XXXX, "pin": "XXX-XX-XXX" }, "accessories": [ { "accessory": "Roomba", "name": "Roomba", "blid": "XXXXXXXXXXXXXXXX", "robotpwd": ":X:XXXXXXXXXX:XXXXXXXXXXXXXXXXX", "ipaddress": "XXX.XXX.X.XXX" } ], "platforms": [ { "name": "Chromecast", "category": "TELEVISION", "platform": "ChromecastTelevision" }, { "name": "Config", "port": 8581, "platform": "config" }, { "name": "TuyaWebPlatform", "options": { "username": "XXXXX@XXX.de", "password": "XXXXXXX", "countryCode": "49", "platform": "smart_life" }, "scenes": false, "platform": "TuyaWebPlatform" }, { "options": { "access_id": "XXX", "secret_id": "XXX", "cloudCode": "eu" }, "name": "DoorSensorPlatform", "defaults": [ { "display_name": "Sensor", "device_id": "XXX" } ], "platform": "TuyaDoorCloud" } ] }

Kakise commented 2 years ago

Hi again !

Your config file looks correct to me. To start home bridge in debug, you need to quit homebridge first, then use the command homebridge -D

I think that the problem might be in your API configuration directly. The can't read property XXX from undefined means that for some reason, the request is throwing an error (I am still working on error catching for the next minor version of this plugin oops).

Please double check your cloud region, and on iot.tuya.com, if the devices are properly registered. You can send me your access key and access secret by email at sam.taa@icloud.com if you want, that would help me reproduce the error and debug locally.

VigoKrumins commented 2 years ago

I got the same error using this plugin. :/

Nocternity commented 2 years ago

I tried to use this today and also got the same error. I also noticed that Tuya has changed the way they handle requests with newly created accounts (like mine), as is described here: https://developer.tuya.com/en/docs/iot/singnature?id=Ka43a5mtx1gsc

Perhaps this is why the plugin isn't working for some of us, in case the accounts have been set up on iot.tuya.com in the last three weeks?

Kakise commented 2 years ago

I tried to use this today and also got the same error. I also noticed that Tuya has changed the way they handle requests with newly created accounts (like mine), as is described here: https://developer.tuya.com/en/docs/iot/singnature?id=Ka43a5mtx1gsc

Perhaps this is why the plugin isn't working for some of us, in case the accounts have been set up on iot.tuya.com in the last three weeks?

Thank you very much for this link, it might effectively be the problem because the error code means that tuya api doesn't answer correctly to the request. I am preparing a hot fix, should be up by tonight @ 10pm CEST.

Nocternity commented 2 years ago

I tried to use this today and also got the same error. I also noticed that Tuya has changed the way they handle requests with newly created accounts (like mine), as is described here: https://developer.tuya.com/en/docs/iot/singnature?id=Ka43a5mtx1gsc Perhaps this is why the plugin isn't working for some of us, in case the accounts have been set up on iot.tuya.com in the last three weeks?

Thank you very much for this link, it might effectively be the problem because the error code means that tuya api doesn't answer correctly to the request. I am preparing a hot fix, should be up by tonight @ 10pm CEST.

Awesome! I'm gonna give it a go tonight or tomorrow then and update you with how it went!

Jens-Wymeersch commented 2 years ago

Hello,

I'm not sure I have the same problem (see error message below). I'm running homebridge on

The door sensor isn't responding and I get the following error message

at Timeout._onTimeout (/usr/lib/node_modules/homebridge-tuya-door-cloud/src/platformAccessory.ts:45:21) (node:1055) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 110) (node:1055) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'expire_time' of undefined at /usr/lib/node_modules/homebridge-tuya-door-cloud/src/tuyaContactSensor.ts:88:44 at processTicksAndRejections (internal/process/task_queues.js:95:5) at TuyaApi.getDoorSensorStatus (/usr/lib/node_modules/homebridge-tuya-door-cloud/src/tuyaContactSensor.ts:102:5)

Nocternity commented 2 years ago

Hello,

I'm not sure I have the same problem (see error message below).

I'm running homebridge on

  • Ubuntu Focal Fossa (20.04.2 LTS) VM on Proxmox

  • lastest version of Homebridge (installed today)

  • Node.js Version | v14.17.2

  • npm v6.14.13

The door sensor isn't responding and I get the following error message

` at Timeout._onTimeout (/usr/lib/node_modules/homebridge-tuya-door-cloud/src/platformAccessory.ts:45:21)

(node:1055) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 110)

(node:1055) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'expire_time' of undefined

at /usr/lib/node_modules/homebridge-tuya-door-cloud/src/tuyaContactSensor.ts:88:44

at processTicksAndRejections (internal/process/task_queues.js:95:5)

at TuyaApi.getDoorSensorStatus (/usr/lib/node_modules/homebridge-tuya-door-cloud/src/tuyaContactSensor.ts:102:5)`

Hello! It is the same error as I'm having and will hopefully be resolved with the pending hotfix!

Kakise commented 2 years ago

Sorry for the late answer, the hot fix is still being worked on, their new signature method really is hard to implement, @codetheweb/tuyapi does have a fix merged and I'm looking into just changing completely the method connection is handled to their api as it would make my work far easier

polmonta commented 2 years ago

Hey! Any updates on this? Thanks :)

VigoKrumins commented 2 years ago

Hey @polmv123! As an alternative you can use this https://github.com/tuya/tuya-homebridge until there is no fixes. I contributed to this repo to bring contact sensors support. It's been there for some time now and I have been using it daily, works like a charm. :)

polmonta commented 2 years ago

Hey @VigoKrumins! Thanks for the quick response. I tried using the tuya-homebridge plaftorm but I keep getting error 2406.

TuyaOpenAPI response: {"code":2406,"msg":"skill id invalid","success":false,"t":1635807073478} path = /v1.0/iot-01/associated-users/actions/authorized-login TypeError: Cannot destructure property 'access_token' of 'res.result' as it is undefined. at TuyaSHOpenAPI._refreshAccessTokenIfNeed (C:\Users\polmo\AppData\Roaming\npm\node_modules\homebridge-tuya-platform\lib\tuyashopenapi.js:48:11) at processTicksAndRejections (internal/process/task_queues.js:95:5) at TuyaSHOpenAPI.request (C:\Users\polmo\AppData\Roaming\npm\node_modules\homebridge-tuya-platform\lib\tuyashopenapi.js:144:7) at TuyaSHOpenAPI.getDevices (C:\Users\polmo\AppData\Roaming\npm\node_modules\homebridge-tuya-platform\lib\tuyashopenapi.js:62:15) at TuyaPlatform.initTuyaSDK (C:\Users\polmo\AppData\Roaming\npm\node_modules\homebridge-tuya-platform\index.js:90:19) Attention⚠️ ⚠️ ⚠️ ! You get an error! Failed to get device information. Please check if the config.json is correct.

Also the instructions say to type a specific endPoint, but I don't see any endPoint section in the config. Thanks :)

polmonta commented 2 years ago

Got it working. https://github.com/tuya/tuya-homebridge/issues/144