iRayanKhan / homebridge-tuya

A Homebridge plugin to control Tuya devices locally.
MIT License
400 stars 166 forks source link

tuya-cli set does not set wifi power switch/relay though claims set succeeded #114

Closed cdprince closed 4 years ago

cdprince commented 4 years ago

Checklist

Describe the bug I have tried to set using the tuya-cli set command. The command says that it set with success, but it did not.

Not sure if this debug output line is significant: "dps: { '1': NaN } } +0ms"

Here is my output: I tried to turn a light that was plugged into the power outlet in #2 slot off -- no change resulted pi@raspberrypi: $ DEBUG=* tuya-cli set --ip '10.0.0.212' --id 73328546dc4f22eb3795 --key 153e74966709XXXX --dps 2 --set False TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.0.0.212... +11ms TuyAPI Socket connected. +24ms TuyAPI GET Payload: +2ms TuyAPI { gwId: '73328546dc4f22eb3795', TuyAPI devId: '73328546dc4f22eb3795', TuyAPI t: '1595366180', TuyAPI dps: {}, TuyAPI uid: '73328546dc4f22eb3795' } +1ms TuyAPI SET Payload: +18ms TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI gwId: '73328546dc4f22eb3795', TuyAPI uid: '', TuyAPI t: 1595366180, TuyAPI dps: { '2': NaN } } +0ms TuyAPI Received data: 000055aa000000010000000a00000063000000007b226465764964223a223733333238353436646334663232656233373935222c22647073223a7b2231223a747275652c2232223a747275652c2233223a747275652c2239223a302c223130223a302c223131223a307d7d02de649e0000aa55 +13ms TuyAPI Parsed: +6ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: TuyAPI { '1': true, '2': true, '3': true, '9': 0, '10': 0, '11': 0 } }, TuyAPI leftover: false, TuyAPI commandByte: 10, TuyAPI sequenceN: 1 } +1ms TuyAPI Received data: 000055aa00000002000000070000000c0000000018cfc5da0000aa55 +8ms TuyAPI Parsed: +1ms TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 2 } +0ms TuyAPI Got SET ack. +0ms TuyAPI Received data: 000055aa00000000000000080000008b00000000332e313232313230653137393066646630383945444a74713576434e7a646c66632b2f627766477133474d4130684d7a4b4d56625a6f4262536d2f6b4a2f6b674f4977594e493836766c424e65734430652b734662746d6c51672b394b39504963342f4a614e57684d34504d3967763677322b6858374775734a42556b733d3ebefe4b0000aa55 +60ms TuyAPI Parsed: +1ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: { '2': true }, TuyAPI t: 1595366179, TuyAPI s: 7 }, TuyAPI leftover: false, TuyAPI commandByte: 8, TuyAPI sequenceN: 0 } +1ms TuyAPI Disconnect +1ms Set succeeded. TuyAPI Socket closed: 10.0.0.212 +4ms

Tried to use NO --dps, it looks like in the help it is optional -- no change in device on/off pi@raspberrypi: $ DEBUG=* tuya-cli set --ip '10.0.0.212' --id 73328546dc4f22eb3795 --key 153e74966709XXXX --set False TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.0.0.212... +11ms TuyAPI Socket connected. +16ms TuyAPI GET Payload: +3ms TuyAPI { gwId: '73328546dc4f22eb3795', TuyAPI devId: '73328546dc4f22eb3795', TuyAPI t: '1595366325', TuyAPI dps: {}, TuyAPI uid: '73328546dc4f22eb3795' } +0ms TuyAPI SET Payload: +17ms TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI gwId: '73328546dc4f22eb3795', TuyAPI uid: '', TuyAPI t: 1595366324, TuyAPI dps: { '1': NaN } } +0ms TuyAPI Received data: 000055aa000000010000000a00000063000000007b226465764964223a223733333238353436646334663232656233373935222c22647073223a7b2231223a747275652c2232223a747275652c2233223a747275652c2239223a302c223130223a302c223131223a307d7d02de649e0000aa55 +16ms TuyAPI Parsed: +7ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: TuyAPI { '1': true, '2': true, '3': true, '9': 0, '10': 0, '11': 0 } }, TuyAPI leftover: false, TuyAPI commandByte: 10, TuyAPI sequenceN: 1 } +0ms TuyAPI Received data: 000055aa00000002000000070000000c0000000018cfc5da0000aa55 +17ms TuyAPI Parsed: +0ms TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 2 } +1ms TuyAPI Got SET ack. +0ms TuyAPI Received data: 000055aa00000000000000080000008b00000000332e313135363635343062313738613366656445444a74713576434e7a646c66632b2f627766477133474d4130684d7a4b4d56625a6f4262536d2f6b4a2b5367335a56436d2b562f62506348766b416c413472586e5a306c64626f75436b4c466674626b5177783545477667736965786f42467277426557356b635a6a6b3d3f2a573e0000aa55 +47ms TuyAPI Parsed: +2ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: { '1': true }, TuyAPI t: 1595366324, TuyAPI s: 8 }, TuyAPI leftover: false, TuyAPI commandByte: 8, TuyAPI sequenceN: 0 } +0ms TuyAPI Disconnect +2ms Set succeeded. TuyAPI Socket closed: 10.0.0.212 +6ms

Tried to use a "false" instead of a "False" because the debug output always uses false/true, not False/True -- error resulted pi@raspberrypi: $ DEBUG=* tuya-cli set --ip '10.0.0.212' --id 73328546dc4f22eb3795 --key 153e74966709XXXX --dps 2 --set false TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.0.0.212... +11ms TuyAPI Socket connected. +26ms TuyAPI GET Payload: +2ms TuyAPI { gwId: '73328546dc4f22eb3795', TuyAPI devId: '73328546dc4f22eb3795', TuyAPI t: '1595366395', TuyAPI dps: {}, TuyAPI uid: '73328546dc4f22eb3795' } +1ms TuyAPI SET Payload: +19ms TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI gwId: '73328546dc4f22eb3795', TuyAPI uid: '', TuyAPI t: 1595366394, TuyAPI dps: { '2': NaN } } +0ms TuyAPI Error event from socket. 10.0.0.212 { Error: write EPIPE at WriteWrap.afterWrite [as oncomplete] (net.js:789:14) errno: 'EPIPE', code: 'EPIPE', syscall: 'write' } +14ms events.js:174 throw er; // Unhandled 'error' event ^

Error: Error from socket at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:350:30) at Socket.emit (events.js:198:13) at errorOrDestroy (internal/streams/destroy.js:107:12) at onwriteError (_stream_writable.js:436:5) at onwrite (_stream_writable.js:461:5) at _destroy (internal/streams/destroy.js:49:7) at Socket._destroy (net.js:614:3) at Socket.destroy (internal/streams/destroy.js:37:8) at WriteWrap.afterWrite [as oncomplete] (net.js:791:10) Emitted 'error' event at: at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:350:16) at Socket.emit (events.js:198:13) [... lines matching original stack trace ...] at WriteWrap.afterWrite [as oncomplete] (net.js:791:10)

I tried to use no --dps to see if anything happened -- no change at all outlet socket powers the light whether I use a True, or False pi@raspberrypi:~/git/cs3250-2020wi-cyberphysicalsystems/LAB2_tempController $ DEBUG=* tuya-cli set --ip '10.0.0.212' --id 73328546dc4f22eb3795 --key 153e74966709XXXX --dps 2 --set "False" TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.0.0.212... +11ms TuyAPI Socket connected. +53ms TuyAPI GET Payload: +3ms TuyAPI { gwId: '73328546dc4f22eb3795', TuyAPI devId: '73328546dc4f22eb3795', TuyAPI t: '1595366611', TuyAPI dps: {}, TuyAPI uid: '73328546dc4f22eb3795' } +0ms TuyAPI SET Payload: +24ms TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI gwId: '73328546dc4f22eb3795', TuyAPI uid: '', TuyAPI t: 1595366610, TuyAPI dps: { '2': NaN } } +0ms TuyAPI Pinging 10.0.0.212 +10s TuyAPI Received data: 000055aa000000010000000a00000063000000007b226465764964223a223733333238353436646334663232656233373935222c22647073223a7b2231223a747275652c2232223a747275652c2233223a747275652c2239223a302c223130223a302c223131223a307d7d02de649e0000aa55 +1s TuyAPI Parsed: +11ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: TuyAPI { '1': true, '2': true, '3': true, '9': 0, '10': 0, '11': 0 } }, TuyAPI leftover: false, TuyAPI commandByte: 10, TuyAPI sequenceN: 1 } +1ms TuyAPI Received data: 000055aa00000002000000070000000c0000000018cfc5da0000aa55000055aa00000000000000080000008b00000000332e313731666537346663363234393831626245444a74713576434e7a646c66632b2f627766477133474d4130684d7a4b4d56625a6f4262536d2f6b4a2f6b674f4977594e493836766c424e65734430652b7338375237495251687745646d32677938444e624b525865454435784c37594f31425a4a7a416878616473303dc64c0e980000aa55 +168ms TuyAPI Parsed: +2ms TuyAPI { payload: false, TuyAPI leftover: TuyAPI <Buffer 00 00 55 aa 00 00 00 00 00 00 00 08 00 00 00 8b 00 00 00 00 33 2e 31 37 31 66 65 37 34 66 63 36 32 34 39 38 31 62 62 45 44 4a 74 71 35 76 43 4e 7a 64 ... >, TuyAPI commandByte: 7, TuyAPI sequenceN: 2 } +1ms TuyAPI Got SET ack. +2ms TuyAPI Parsed: +1ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: { '2': true }, TuyAPI t: 1595366618, TuyAPI s: 9 }, TuyAPI leftover: false, TuyAPI commandByte: 8, TuyAPI sequenceN: 0 } +0ms TuyAPI Disconnect +2ms Set succeeded. TuyAPI Socket closed: 10.0.0.212 +13ms

I tried to use FALSE too, just in case it may work -- it threw an error pi@raspberrypi:~/git/cs3250-2020wi-cyberphysicalsystems/LAB2_tempController $ DEBUG=* tuya-cli set --ip '10.0.0.212' --id 73328546dc4f22eb3795 --key 153e74966709XXXX --dps 2 --set "FALSE" TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.0.0.212... +11ms TuyAPI Socket connected. +51ms TuyAPI GET Payload: +3ms TuyAPI { gwId: '73328546dc4f22eb3795', TuyAPI devId: '73328546dc4f22eb3795', TuyAPI t: '1595367217', TuyAPI dps: {}, TuyAPI uid: '73328546dc4f22eb3795' } +0ms TuyAPI SET Payload: +21ms TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI gwId: '73328546dc4f22eb3795', TuyAPI uid: '', TuyAPI t: 1595367216, TuyAPI dps: { '2': NaN } } +1ms TuyAPI Error event from socket. 10.0.0.212 { Error: write EPIPE at WriteWrap.afterWrite [as oncomplete] (net.js:789:14) errno: 'EPIPE', code: 'EPIPE', syscall: 'write' } +21ms events.js:174 throw er; // Unhandled 'error' event ^

Error: Error from socket at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:350:30) at Socket.emit (events.js:198:13) at errorOrDestroy (internal/streams/destroy.js:107:12) at onwriteError (_stream_writable.js:436:5) at onwrite (_stream_writable.js:461:5) at _destroy (internal/streams/destroy.js:49:7) at Socket._destroy (net.js:614:3) at Socket.destroy (internal/streams/destroy.js:37:8) at WriteWrap.afterWrite [as oncomplete] (net.js:791:10) Emitted 'error' event at: at Socket.client.on.err (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:350:16) at Socket.emit (events.js:198:13) [... lines matching original stack trace ...] at WriteWrap.afterWrite [as oncomplete] (net.js:791:10)

To Reproduce provided commands

Expected behavior I should be able to turn on/off a power outlet, one socket at a time

Screenshots N/A

Environment (please complete the following information):

Additional context Add any other context about the problem here.

cdprince commented 4 years ago

Got it to work: You do not use the string [True | False], but [ 1 | 0 ] respectively -- perhaps a docs issue? $ DEBUG=* tuya-cli set --ip '10.0.0.212' --id 73328546dc4f22eb3795 --key 153e74966709XXXX --dps 1 --set 0 TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.0.0.212... +11ms TuyAPI Socket connected. +23ms TuyAPI GET Payload: +2ms TuyAPI { gwId: '73328546dc4f22eb3795', TuyAPI devId: '73328546dc4f22eb3795', TuyAPI t: '1595376309', TuyAPI dps: {}, TuyAPI uid: '73328546dc4f22eb3795' } +1ms TuyAPI SET Payload: +24ms TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI gwId: '73328546dc4f22eb3795', TuyAPI uid: '', TuyAPI t: 1595376309, TuyAPI dps: { '1': 0 } } +6ms TuyAPI Received data: 000055aa000000010000000a00000063000000007b226465764964223a223733333238353436646334663232656233373935222c22647073223a7b2231223a747275652c2232223a747275652c2233223a747275652c2239223a302c223130223a302c223131223a307d7d02de649e0000aa55 +13ms TuyAPI Parsed: +4ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: TuyAPI { '1': true, '2': true, '3': true, '9': 0, '10': 0, '11': 0 } }, TuyAPI leftover: false, TuyAPI commandByte: 10, TuyAPI sequenceN: 1 } +1ms TuyAPI Received data: 000055aa00000002000000070000000c0000000018cfc5da0000aa55 +13ms TuyAPI Parsed: +1ms TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 2 } +1ms TuyAPI Got SET ack. +1ms TuyAPI Received data: 000055aa00000000000000080000008b00000000332e313761396662396463333062356161656145444a74713576434e7a646c66632b2f627766477133474d4130684d7a4b4d56625a6f4262536d2f6b4a396d2b49363939367268632b744f7562536b59393265764941597269727033395a654e4b55566e7a486a4667586b37556b4c4143564469336432583379514c2f633dec2424a80000aa55 +51ms TuyAPI Parsed: +2ms TuyAPI { payload: TuyAPI { devId: '73328546dc4f22eb3795', TuyAPI dps: { '1': false }, TuyAPI t: 1595376308, TuyAPI s: 24 }, TuyAPI leftover: false, TuyAPI commandByte: 8, TuyAPI sequenceN: 0 } +0ms TuyAPI Disconnect +3ms Set succeeded. TuyAPI Socket closed: 10.0.0.212 +6ms

iRayanKhan commented 4 years ago

Hey, this plugin isn't integrated with Tuya-Cli (yet), please direct any issues to CodeTheWeb regarding it.