unparagoned / njsTuya

Openhab interface for Tuya home automation devices sold under various names
27 stars 11 forks source link

Commands not send anymore #33

Closed Scuby4ever closed 5 months ago

Scuby4ever commented 3 years ago

Is there anything known why the tuyaAPI is not collecting the changes any more? Here is an example from my side:

node /etc/openhab2/scripts/node_modules/njstuya/njstuya.js -mode cloud -id xxxxx ON Result ON

But nothing on the APP or the switch If I try it directly again I get the following error

(node:7345) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'code' of undefined at switchStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:188:18) at processTicksAndRejections (internal/process/task_queues.js:86:5) (node:7345) 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(). (rejection id: 1) (node:7345) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Scuby4ever commented 3 years ago

Solved the issue, It seems to be that the payload was not handed over correctly. Here my solution in njstuya,js

async function setStateCloud(command, payload) { console.log("Function njstuya.setStateCloud - payload: " + payload.value); console.log("Function njstuya.setStateCloud - command: " + command); const resp = await api.setState({ devId: tuyaID, setState: payload.value, command, payload, }); debug(resp); return resp; }

unparagoned commented 3 years ago

I updated both njstuya and cloudtuya to support more general payloads. It looks like you may be using an old version of njstuya or cloudtuya. What version are you using?