Comments (24)
from node-red-contrib-tuya-smart-device.
@msillano I had fixed the timeouts and the multiple states emitted errors. Now the state is emitted only when it is changed. hence no duplicates.
You can check the changes in the branch feature/fix-timeouts
I am still looking in to the unhandled exception case.
from node-red-contrib-tuya-smart-device.
Ok, good job.
After more test, in compact form dashboard:
// ----- regular start, device Wifi plug ON, OK
3/6/2021, 18:02:22node: STATE "DISCONNECTED"
3/6/2021, 18:02:22node: STATE "DISCONNECTED"
3/6/2021, 18:02:23node: STATE "CONNECTING"
3/6/2021, 18:02:23node: STATE "CONNECTING"
3/6/2021, 18:02:23node: STATE "CONNECTED"
3/6/2021, 18:02:24node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2702 }
3/6/2021, 18:02:24node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 3261 }
3/6/2021, 18:02:25node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2000 }
// ------------ now set OFF (via power strip)
3/6/2021, 18:09:27 power strip : { dps: "2", set: false }
3/6/2021, 18:09:35node: STATE "DISCONNECTED"
3/6/2021, 18:09:40node: STATE"CONNECTING"
3/6/2021, 18:09:40node: { operation: "CONTROL", action: "SET_F"CONNECTING"IND_TIMEOUT", value: 2502 }
// ----------- note: after the "CONNECTING" non more re-try !
// ------------ now set ON device (via power strip) don't change the drive block
3/6/2021, 18:14:21 power strip : { dps: "2", set: true }
// ------------ no retry, also if auto-connect is true
// ------------ but If I send a COMMAND CONNECT: retry OK
3/6/2021, 18:16:44node: { operation: "CONTROL", action: "CONNECT" }
3/6/2021, 18:16:44node: "DISCONNECTED"
3/6/2021, 18:16:45node: "CONNECTING"
3/6/2021, 18:16:45node: "CONNECTING"
3/6/2021, 18:16:45node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2535 }
3/6/2021, 18:16:45node: "CONNECTED"
3/6/2021, 18:16:45node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 3403 }
3/6/2021, 18:16:45node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2000 }
// ------- now restart flows, and device OFF
3/6/2021, 18:19:56node: "DISCONNECTED"
3/6/2021, 18:19:57node: "CONNECTING"
3/6/2021, 18:19:58node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2500 }
3/6/2021, 18:20:07node: "ERROR" // ???
3/6/2021, 18:20:10node: "CONNECTING" (time + 13 (10+ 2.5))
3/6/2021, 18:20:10node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2536 }
3/6/2021, 18:20:20node: "ERROR"
3/6/2021, 18:20:22node: "CONNECTING" (time + 12 (10+2.5))
3/6/2021, 18:20:22node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 3331 }
3/6/2021, 18:20:32node: "ERROR"
3/6/2021, 18:20:36node: "CONNECTING" (time + 14 (10+3.3))
3/6/2021, 18:20:36node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 3907 }
3/6/2021, 18:20:46node: "ERROR"
.... omissis
3/6/2021, 18:24:20node: "CONNECTING"
3/6/2021, 18:24:20node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 25996 }
3/6/2021, 18:24:30node: "ERROR"
3/6/2021, 18:24:56node: "CONNECTING" (time + 36 (10+25.9)) OK
3/6/2021, 18:24:56node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 30393 }
// --------- also with "ERROR" (??) the findTimeout works, OK
..... omissis
// ------ device Wifi plug ON (via power strip), OK
3/6/2021, 18:30:28node: power strip : { dps: "2", set: true }
3/6/2021, 18:31:29node: "CONNECTING"
3/6/2021, 18:31:30node: "CONNECTING"
3/6/2021, 18:31:31node: "CONNECTED"
3/6/2021, 18:31:31node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2000 } OK
// ------- test COMMANDS CONNECT/DISCONNECT
3/6/2021, 18:39:05node: { operation: "CONTROL", action: "DISCONNECT" }
3/6/2021, 18:39:05node: "DISCONNECTED"
3/6/2021, 18:39:05node: "DISCONNECTED"
... nothing
3/6/2021, 18:39:24node: { operation: "CONTROL", action: "CONNECT" }
3/6/2021, 18:39:24node: "DISCONNECTED"
3/6/2021, 18:39:25node: "CONNECTING"
3/6/2021, 18:39:25node: "CONNECTING"
3/6/2021, 18:39:25node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2638 }
3/6/2021, 18:39:25node: "CONNECTED"
3/6/2021, 18:39:25node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2728 }
3/6/2021, 18:39:26node: { operation: "CONTROL", action: "SET_FIND_TIMEOUT", value: 2000 }
// -------- works as expected, OK
It is like an 'auto-connect' problem: if device OFF => ON the 'auto-connect' don't starts, but the COMMAND CONNECT does.
The errors are a problem apart: the UnhandledPromiseRejectionWarning
(systematic when the device goes ON => OFF) and the msg state 'ERROR'. (??)
PS: 'ERROR' is OK, is the catch of 'tuyAPY Error: find() timed out.' . It is sent at any retry... maybe superfluous? It is normal in a retry loop waiting for a connection to have it... it is a signal, not an ERROR. But it is not a problem, just ignore it.
I'm using the 4.1 with all devices, (I updated the project) but the tests are done with the 'wifi plug' because it is easy to turn it ON/OFF using a second device 'power strip' so I have records of times.
Best regards
m.s.
from node-red-contrib-tuya-smart-device.
In my case if i turn off the light , i will get a connection timeout and then it starts to retry.
TuyAPI Error event from socket. 192.168.1.71 Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
} +9s
3 Jun 22:29:08 - [info] [tuya-smart-device:Tv Light] Retrying reconnect after 1001 milliseconds
TuyAPI Socket closed: 192.168.1.71 +3ms
3 Jun 22:29:08 - [info] [tuya-smart-device:Tv Light] Disconnected from tuyaDevice.
3 Jun 22:29:08 - [info] [tuya-smart-device:Tv Light] Retrying reconnect after 1001 milliseconds
TuyAPI Connecting to 192.168.1.71... +1s
Regarding the UnhandledPromiseRejectionWarning, the tuya API is not giving error event in such cases. Only when the error is emitted, the node tries to reconnect.
from node-red-contrib-tuya-smart-device.
You cannot overload tuyaAPI to catch also this event/promise?
from node-red-contrib-tuya-smart-device.
Nope .
as per your log the error occurred at line 446
(node:16444) UnhandledPromiseRejectionWarning: Error: connection timed out
at Socket.<anonymous> (d:\node-red\flow-1984\node_modules\tuyapi\index.js:446:18)
at Object.onceWrapper (events.js:421:28)
at Socket.emit (events.js:315:20)
which is
// Periodically send heartbeat ping
this.pingpongTimeout = setInterval(async () => {
await this._sendPing();
}, this._pingPongPeriod * 1000);
so error is thrown from this await, but sadly it is there inside a setInterval, hence i cannot handle it. TuyaAPI has to handle it.
from node-red-contrib-tuya-smart-device.
But in my case after some time 10 secs or so, Tuya sends a error event.
from node-red-contrib-tuya-smart-device.
In your case can you please confirm after the error is shown in the log, what is the status in the dashboard ? Is it showing still connected ?
from node-red-contrib-tuya-smart-device.
Open an Issue on tuyapi ISSUE#477.
About in the dashboard ? Not, after error thr device is dead. see @3/6/2021, 18:09:40
from node-red-contrib-tuya-smart-device.
from node-red-contrib-tuya-smart-device.
I confirm, the 'more test, in compact form' is from dashboard.
This is a trace of a try with a different device 'switch module#1'.
Exactly same behavior seen before:
... omissis
3 Jun 19:55:25 - [info] [tuya-smart-device:switch module#1] Recieved the config {"id":"3db1955********","type":"tuya-smart-device","z":"173260fb.d021ff","deviceName":"switch module#1","disableAutoStart":false,"deviceId":"bfa355aa196********","deviceKey":"10ad2960f******","deviceIp":"","retryTimeout":"100193","findTimeout":"100207","tuyaVersion":"3.1","eventMode":"event-both","x":1270,"y":1660,"wires":[["2ec83963.a7d146"],["668d3a7b.f2a8e4","2523b8e2.0abbf8"]],"info":"CUSTOMIZATION\n\n - duplicate for any new device\n - set proprties: deviceId (or IP), key, retry timeout (1000 ms), find timeout (5000 ms)."}
3 Jun 19:55:25 - [info] [tuya-smart-device:switch module#1] Event subscription : shouldSubscribeData=>true , shouldSubscribeRefreshData=>true
3 Jun 19:55:25 - [info] [tuya-smart-device:switch module#1] Auto start probe on connect...
3 Jun 19:55:25 - [info] [tuya-smart-device:switch module#1] Cleaning up the state
3 Jun 19:55:25 - [info] [tuya-smart-device:switch module#1] Clearing the find timeout handler
... omissis
3 Jun 19:55:26 - [info] [tuya-smart-device:switch module#1] Connecting to Tuya with params {"id":"bfa355aa196********","key":"10ad2960f********","ip":"","issueGetOnConnect":false,"nullPayloadOnJSONError":false,"version":"3.1"} , findTimeout : 100207 , retryTimeout: 100193
3 Jun 19:55:26 - [info] [tuya-smart-device:switch module#1] Initiating the find command
... omissis
3 Jun 19:55:30 - [info] [tuya-smart-device:switch module#1] Connected to device! bfa355aa196********
... omissis
// --------------------- at 19:56, Power OFF to switch
3 Jun 19:56:32 - [info] [tuya-smart-device:switch module#1] Disconnected from tuyaDevice.
(node:13800) UnhandledPromiseRejectionWarning: Error: connection timed out
at Socket.<anonymous> (d:\node-red\flow-1984\node_modules\tuyapi\index.js:446:18)
at Object.onceWrapper (events.js:421:28)
at Socket.emit (events.js:315:20)
at Socket._onTimeout (net.js:483:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13800) 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: 1)
(node:13800) [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.
... omissis
// ------------ the device is dead
from node-red-contrib-tuya-smart-device.
more tests
The feature/fix-timeouts is with many problems:
- THE COMMANDs looks don't work:
The test was done using your example flow, a little modified
Start: device ON, dashboard after a 'restart flow' :
!! missed the initial STATE (CONNECTED|DISCONNECTED)
5/6/2021, 11:26:26node: Device INPUT
msg.payload : Object { dps: 1, set: true }
5/6/2021, 11:26:26node: Device Data
msg.payload.data.dps : object 1: true
------ OK swtch ON
5/6/2021, 11:28:07node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "DISCONNECT" }
!! No STATE change
5/6/2021, 11:28:14node: Device INPUT
msg.payload : Object { dps: 1, set: false }
5/6/2021, 11:28:14node: Device Data
msg.payload.data.dps : Object 1: false
!! switch change OFF
5/6/2021, 11:28:23node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "RECONNECT" }
!! No STATE change
5/6/2021, 11:28:23node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "CONNECT" }
!! No STATE change
Same but now starting with device OFF
5/6/2021, 11:41:26node: e63245d0.e6cdc8
msg : error
"Error: find() timed out. Is the device powered on and the ID or IP correct?"
5/6/2021, 11:41:27node: e63245d0.e6cdc8
!! Not catch by node,
!! No STATE ERROR
msg : error
"Error: find() timed out. Is the device powered on and the ID or IP correct?"
5/6/2021, 11:41:37node: e63245d0.e6cdc8
msg : error
"Error: find() timed out. Is the device powered on and the ID or IP correct?"
---------------- Turned ON by hand
5/6/2021, 11:41:38node: e63245d0.e6cdc8
msg : error
"Error: find() timed out. Is the device powered on and the ID or IP correct?"
5/6/2021, 11:41:45node: Device Data
--------- on flow the status change to green-connected
!! no STATE CHANGE, no error tcatch
msg.payload.data.dps : Object
{ 1: true, 9: 0 }
!! Unrequested SCHEMA - not all dps: see (http://localhost/tuyadaemontoolkit/crud_devicedpoints.php?dName=Wifi_Plug)
5/6/2021, 11:42:38node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "DISCONNECT" }
!! CONTROL without consequences
---------------- Turned OFF by hand
!! any consequence
5/6/2021, 11:52:44node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "CONNECT" }
--------- on flow the status change to yellow-connecting
!! Don't change from jellow.... until:
--------- sending a SET request:
5/6/2021, 11:53:07node: Device INPUT
msg.payload : Object { dps: 1, set: true }
5/6/2021, 11:53:07node: Device Data
msg.payload.data.dps : Object { 1: true }
!! not CONNECTED, but accepts data
!! now the flow status change to green-connected
!! no STATE CHANGE
More notes on version 4:
The test was done using your example flow, a little modified
Start: device ON, dashboard after a 'restart flow
!! device looks disconnected (red, disconnected)
5/6/2021, 12:17:50node: Node State
msg.payload : Object { state: "DISCONNECTED" }
5/6/2021, 12:17:51node: Node State
msg.payload : Object { state: "DISCONNECTED" }
--- OK status at start, but why 2?
!! ---- no more retry for auto-connect
------ sending COMMAND 'CONNECT'
5/6/2021, 12:18:24node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "CONNECT" }
5/6/2021, 12:18:24node: Node State
msg.payload : Object { state: "DISCONNECTED" }
5/6/2021, 12:18:25node: Node State
msg.payload : Object { state: "CONNECTING" }
5/6/2021, 12:18:29node: Node State
msg.payload : Object { state: "CONNECTING" }
5/6/2021, 12:18:29node: Node State
msg.payload : Object { state: "CONNECTED" }
---- for test, a SET
5/6/2021, 12:18:48node: Device INPUT
msg.payload : Object{ dps: 1, set: true }
5/6/2021, 12:18:49node: Node State
msg.payload : Object{ state: "CONNECTED" }
!! -- ??
5/6/2021, 12:18:49node: Device Data
msg.payload.data.dps : Object { 1: true }
---- OK, data SET
---- sending COMMAND 'CONNECT' to an already connected device
5/6/2021, 12:18:56node: Device INPUT
msg.payload : Object{ operation: "CONTROL", action: "CONNECT" }
5/6/2021, 12:18:56node: Node State
msg.payload : Object { state: "DISCONNECTED" }
5/6/2021, 12:18:56node: Node State
msg.payload : Object { state: "DISCONNECTED" }
5/6/2021, 12:18:57node: Node State
msg.payload : Object{ state: "CONNECTING" }
5/6/2021, 12:18:57node: Node State
msg.payload : Object{ state: "CONNECTING" }
5/6/2021, 12:18:57node: Node State
msg.payload : Object{ state: "CONNECTED" }
!! ------- all redundant messages: nothing to do
---------------- now sending : COMMAND 'DISCONNECT'
5/6/2021, 12:19:11node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "DISCONNECT" }
5/6/2021, 12:19:11node: Node State
msg.payload : Object{ state: "DISCONNECTED" }
5/6/2021, 12:19:11node: Node State
msg.payload : Object{ state: "DISCONNECTED" }
------ sending SET to a 'DISCONNECTED' device:
5/6/2021, 12:19:16node: Device INPUT
msg.payload : Object { dps: 1, set: false }
5/6/2021, 12:19:17node: Node State
msg.payload : Object { state: "CONNECTED" }
!! -- ??
5/6/2021, 12:19:17node: Node State
msg.payload : Object { state: "CONNECTED" }
5/6/2021, 12:19:17node: Device Data
msg.payload.data.dps : Object{ 1: false }
5/6/2021, 12:19:21node: Node State
msg.payload : Object{ state: "CONNECTED" }
5/6/2021, 12:19:21node: Device Data
msg.payload.data.dps : Object { 18: 60, 19: 52, 20: 2287 }
!! ----- data PUSH from 'DISCONNECTED' device
5/6/2021, 12:19:23node: Node StateNotes:
5/6/2021, 12:19:23node: Device Data
msg.payload.data.dps : Object{ 18: 0, 19: 0 }
!! ----- data PUSH from 'DISCONNECTED' device
Notes
- The command COMMAND 'DISCONNECT|CONNECT|RECONNECT' MUST prevail on any GET/SET/PUSH automatisms, if state is DISCONNECTED the request SET/GET and PUSH MUST be ignored.
- The COMMAND CONNECT on an already connected device and the COMMAND DISCONNECT on an already disconnected device MUST be ignored,
- At the start, the absence of auto-connect is a BUG.
- At the start, the absence of any STATE msq, is a BUG
- After power OFF and sequential power ON the COMMAND CONNECT works OK, but not the auto-connect: it is a BUG.
- Why the output2 msg is not the standard 'status' (e.g. msg.status:{fill:"green",shape:"ring",text:"node-red:common.status.connected"}) but a custom 'msg.payload.strate' ?
- Maybe also for the 'state' is better to use "node-red:common.status.connected" in place of the constant "CONNECTED", etc...
Best regards
m.s.
from node-red-contrib-tuya-smart-device.
from node-red-contrib-tuya-smart-device.
"Auto connect featured is used to connect to the device on node red restart or start. "
OK, but also if the device goes OFF, must do continue retry, and when the device goes back ON it must connect., This is not the case.
"Instead of custom logs can you please share unmodified logs for a particular scenario."
I confirm you that the last traces are unmodified debug pad log, using only your example circuit, to eliminate any interference.
If it is more convenient for you, I can try to put the various scenarios in a more schematic, and, I hope, reproducible way. Let me know.
Best regards
m.s.
from node-red-contrib-tuya-smart-device.
I had updated the code with some more logs. Can you please try your not working scenario for reconnection. can share me the compete logs ( the server logs)
from node-red-contrib-tuya-smart-device.
- Tests using
bug-fix/connection-issue/src/tuya-smart-device.js.
- Device 'wifi plug' (https://github.com/msillano/tuyaDAEMON/blob/main/devices/Wifi_Plug/device_Wifi_Plug.pdf): anonymized as "device5-id****"
- node-red: all flow disabled, only 'test ver. 4.1' enabled
A test
start conditions: debug trace: ON, device: ON, node-red: Deploy/restart flows
6 Jun 16:50:02 - [info] Stopped flows
6 Jun 16:50:02 - [info] Starting flows
6 Jun 16:50:02 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
TuyAPI Finding missing IP undefined or ID device5-id**** +5ms
6 Jun 16:50:02 - [info] Started flows
socket.io-parser encoding packet {"type":2,"data":["ui-controls",{"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}},"theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#2a8e93","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"},"themeState":{"base-color":{"default":"#097479","value":"#2a8e93","edited":true},"page-titlebar-backgroundColor":{"value":"#2a8e93","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#41c2c9","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#2a8e93","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}}},"menu":[],"globals":[]}],"nsp":"/"} +1m
socket.io-parser encoded {"type":2,"data":["ui-controls",{"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}},"theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#2a8e93","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"},"themeState":{"base-color":{"default":"#097479","value":"#2a8e93","edited":true},"page-titlebar-backgroundColor":{"value":"#2a8e93","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#41c2c9","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#2a8e93","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}}},"menu":[],"globals":[]}],"nsp":"/"} as 2["ui-controls",{"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}},"theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#2a8e93","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"},"themeState":{"base-color":{"default":"#097479","value":"#2a8e93","edited":true},"page-titlebar-backgroundColor":{"value":"#2a8e93","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#41c2c9","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#2a8e93","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}}},"menu":[],"globals":[]}] +0ms
TuyAPI Socket closed: 192.168.1.17 +8ms
TuyAPI Received UDP message. +278ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.12',
TuyAPI gwId: 'device18-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'rqxvfakd',
TuyAPI version: '3.3',
TuyAPI lan_cap: 500,
TuyAPI lan_seq: 11
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +0ms
TuyAPI Received UDP message. +1s
TuyAPI UDP data: +2ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.7',
TuyAPI gwId: 'device24-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyf9fsmuufeywsr',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +816ms
TuyAPI UDP data: +2ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.10',
TuyAPI gwId: 'device19-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'key7axydcvmea3x9',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +1ms
TuyAPI Received UDP message. +218ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.16',
TuyAPI gwId: 'device17-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keys83qyuhuqrdn7',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +285ms
TuyAPI UDP data: +2ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.20',
TuyAPI gwId: 'device23-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'key5nck4tavy43jp',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +1ms
TuyAPI Received UDP message. +135ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.15',
TuyAPI gwId: 'device15-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keys83qyuhuqrdn7',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +63ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.14',
TuyAPI gwId: 'device10-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keya4gvchmtapm8n',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +1ms
TuyAPI Received UDP message. +300ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.17',
TuyAPI gwId: 'device5-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keym9qkuywghyrvs',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Connecting to 192.168.1.17... +4ms
TuyAPI Socket connected. +82ms
6 Jun 16:50:05 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +32ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +3ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +60ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +3ms
TuyAPI Pong from 192.168.1.17 +1ms
............... omissis
note:
- test ok, device connected.
ERROR: no 'state' message from device-node. Expected 3 state messages: initial "DISCONNECTED", then "CONNECTING", then "CONNECTED" (in 4.1 state msgs are sent).
B test
start conditions: debug trace: ON, device: OFF, node-red: Deploy/restart flows
............. omissis
TuyAPI gwId: 'device17-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keys83qyuhuqrdn7',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +3ms
TuyAPI Received UDP message. +414ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.15',
TuyAPI gwId: 'device15-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keys83qyuhuqrdn7',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +46ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.6',
TuyAPI gwId: 'device6-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyf9fsmuufeywsr',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +1ms
TuyAPI Received UDP message. +292ms
TuyAPI UDP data: +2ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.10',
TuyAPI gwId: 'device19-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'key7axydcvmea3x9',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +4ms
TuyAPI Received UDP message. +112ms
TuyAPI UDP data: +4ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.5',
TuyAPI gwId: 'device27-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'c0nh3LmEk0NDebrq',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +407ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.14',
TuyAPI gwId: 'device10-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keya4gvchmtapm8n',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +6ms
TuyAPI Received UDP message. +301ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.11',
TuyAPI gwId: 'device20-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyfa7hya4gfa7g9',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
6 Jun 17:25:28 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
6 Jun 17:25:28 - [info] [tuya-smart-device:e63245d0.e6cdc8] Cannot find the device, re-trying...
6 Jun 17:25:29 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
TuyAPI Finding missing IP undefined or ID device5-id**** +2s
TuyAPI Received UDP message. +762ms
TuyAPI UDP data: +2ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.20',
TuyAPI gwId: 'device23-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'key5nck4tavy43jp',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +658ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.16',
TuyAPI gwId: 'device17-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keys83qyuhuqrdn7',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +413ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.15',
TuyAPI gwId: 'device15-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keys83qyuhuqrdn7',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +46ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.6',
TuyAPI gwId: 'device6-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyf9fsmuufeywsr',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +296ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.10',
TuyAPI gwId: 'device19-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'key7axydcvmea3x9',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +109ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.5',
TuyAPI gwId: 'device27-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'c0nh3LmEk0NDebrq',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +3ms
TuyAPI Received UDP message. +415ms
TuyAPI UDP data: +0ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.14',
TuyAPI gwId: 'device10-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keya4gvchmtapm8n',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +1ms
TuyAPI Received UDP message. +306ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.11',
TuyAPI gwId: 'device20-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyfa7hya4gfa7g9',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +3ms
TuyAPI Received UDP message. +1s
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.7',
TuyAPI gwId: 'device24-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyf9fsmuufeywsr',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +61ms
TuyAPI UDP data: +2ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.13',
TuyAPI gwId: 'device16-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'ds0dztbnkfwlnhrk',
TuyAPI version: '3.3',
TuyAPI token: true
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
TuyAPI Received UDP message. +358ms
TuyAPI UDP data: +0ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.12',
TuyAPI gwId: 'device18-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'rqxvfakd',
TuyAPI version: '3.3',
TuyAPI lan_cap: 500,
TuyAPI lan_seq: 11
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +1ms
............... omissis
note:
-. test ok, but why the test to other devices? (all flows are disabled)
ERROR: no 'state' message from device-node. Expected many state messages: initial "DISCONNECTED", then many "CONNECTING", then "DISCONNECTED"
ERROR: the "find() timed out." is sent as an error and not as STATE msg (in 4.1 state msgs are sent).
C test
start conditions: debug trace: ON, device: ON, node-red: Deploy/restart flows
- now, after the device connection (same as A) the device is turned OFF
............... omissis.... like A test
TuyAPI Received UDP message. +227ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.6',
TuyAPI gwId: 'device6-id****',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyf9fsmuufeywsr',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +2ms
............ here I turn OFF the device
TuyAPI Received UDP message. +97ms
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.17',
TuyAPI gwId: 'device5-id****',
TuyAPI active: 2,
TuyAPI ablilty: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keym9qkuywghyrvs',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +3ms
TuyAPI Connecting to 192.168.1.17... +3ms
TuyAPI Socket connected. +112ms
6 Jun 17:03:11 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +5ms
TuyAPI Parsed: +0ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +0ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +66ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +2ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Disconnect +2s
6 Jun 17:03:43 - [info] [tuya-smart-device:e63245d0.e6cdc8] Disconnected from tuyaDevice.
TuyAPI Socket closed: 192.168.1.17 +4ms
TuyAPI Connecting to 192.168.1.17... +1s
(node:14400) UnhandledPromiseRejectionWarning: Error: connection timed out
at Socket.<anonymous> (d:\node-red\flow-1984\node_modules\tuyapi\index.js:442:18)
at Object.onceWrapper (events.js:421:28)
at Socket.emit (events.js:315:20)
at Socket._onTimeout (net.js:483:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:14400) 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: 1)
(node:14400) [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.
TuyAPI Socket closed: 192.168.1.17 +5s
note:
- no more trace until 17:09 !!!
- after the device disconnected, no connection retry for more than 300 sec.
- after that, if I turn ON the device: nothing happens in trace
- after that, if I turn ON the device AND if I send COMMAND CONNECT: nothing happens in trace (in 4.1 it is working).
ERROR: no 'state' message from device-node. Expected state messages: "DISCONNECTED", then many: "CONNERCTING", "DISCONNECTED".
ERROR: impossible to reconnect: the condition of test B is not restored.
D test
start conditions: debug trace: ON, device: ON, node-red: Deploy/restart flows
- now, after the device connection (same as A) I send a COMMAND DISCONNECT then SET dp 1 true
............... omissis
6 Jun 17:57:33 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +33ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +2ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +58ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +2ms
TuyAPI Pong from 192.168.1.17 +0ms
//--------- sending DISCONNECT
express:router dispatching POST /inject/1991e72.c15c719 +23s
express:router query : /inject/1991e72.c15c719 +1ms
express:router expressInit : /inject/1991e72.c15c719 +3ms
express:router mounted_app : /inject/1991e72.c15c719 +1ms
express:router dispatching POST /inject/1991e72.c15c719 +0ms
express:router query : /inject/1991e72.c15c719 +1ms
express:router expressInit : /inject/1991e72.c15c719 +0ms
express:router corsMiddleware : /inject/1991e72.c15c719 +1ms
express:router jsonParser : /inject/1991e72.c15c719 +1ms
body-parser:json content-type undefined +23s
body-parser:json skip parsing +1ms
express:router urlencodedParser : /inject/1991e72.c15c719 +1ms
body-parser:urlencoded content-type undefined +1ms
body-parser:urlencoded skip parsing +1ms
express:router mounted_app : /inject/1991e72.c15c719 +2ms
express:router dispatching POST /inject/1991e72.c15c719 +1ms
express:router query : /inject/1991e72.c15c719 +0ms
express:router expressInit : /inject/1991e72.c15c719 +8ms
express:router serveStatic : /inject/1991e72.c15c719 +1ms
express:router mounted_app : /inject/1991e72.c15c719 +1ms
express:router dispatching POST /inject/1991e72.c15c719 +0ms
express:router query : /inject/1991e72.c15c719 +1ms
express:router expressInit : /inject/1991e72.c15c719 +0ms
express:router mounted_app : /inject/1991e72.c15c719 +1ms
express:router dispatching POST /inject/1991e72.c15c719 +1ms
express:router query : /inject/1991e72.c15c719 +0ms
express:router expressInit : /inject/1991e72.c15c719 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +9ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +6ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +329ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +2ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +56ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +3ms
TuyAPI Pong from 192.168.1.17 +1ms
// ---------------- sending SET DP 1, TRUE
express:router dispatching POST /inject/993c8470.01a278 +31s
express:router query : /inject/993c8470.01a278 +0ms
express:router expressInit : /inject/993c8470.01a278 +1ms
express:router mounted_app : /inject/993c8470.01a278 +0ms
express:router dispatching POST /inject/993c8470.01a278 +0ms
express:router query : /inject/993c8470.01a278 +0ms
express:router expressInit : /inject/993c8470.01a278 +0ms
express:router corsMiddleware : /inject/993c8470.01a278 +1ms
express:router jsonParser : /inject/993c8470.01a278 +0ms
body-parser:json content-type undefined +31s
body-parser:json skip parsing +0ms
express:router urlencodedParser : /inject/993c8470.01a278 +0ms
body-parser:urlencoded content-type undefined +0ms
body-parser:urlencoded skip parsing +0ms
express:router mounted_app : /inject/993c8470.01a278 +1ms
express:router dispatching POST /inject/993c8470.01a278 +0ms
express:router query : /inject/993c8470.01a278 +0ms
express:router expressInit : /inject/993c8470.01a278 +0ms
express:router serveStatic : /inject/993c8470.01a278 +0ms
express:router mounted_app : /inject/993c8470.01a278 +0ms
express:router dispatching POST /inject/993c8470.01a278 +1ms
express:router query : /inject/993c8470.01a278 +0ms
express:router expressInit : /inject/993c8470.01a278 +0ms
express:router mounted_app : /inject/993c8470.01a278 +0ms
express:router dispatching POST /inject/993c8470.01a278 +0ms
express:router query : /inject/993c8470.01a278 +0ms
express:router expressInit : /inject/993c8470.01a278 +0ms
TuyAPI SET Payload: +724ms
TuyAPI {
TuyAPI devId: 'device5-id****',
TuyAPI gwId: 'device5-id****',
TuyAPI uid: '',
TuyAPI t: 1622995104,
TuyAPI dps: { '1': true }
TuyAPI } +0ms
TuyAPI Received data: 000055aa00000000000000080000004b00000000332e3300000000000025bc00000001f201d2835a8b2f14b961521e3bdf5f8489748518094b5b4479590774debe58042cf0e2b2889cd070607529db3514ca5f2494d1bf0000aa55 +113ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: { dps: { '1': true }, t: 1622995103 },
TuyAPI leftover: false,
TuyAPI commandByte: 8,
TuyAPI sequenceN: 0
TuyAPI } +0ms
TuyAPI Received DATA packet +1ms
6 Jun 17:58:24 - [info] [tuya-smart-device:e63245d0.e6cdc8] [object Object]
TuyAPI Received data: 000055aa00000006000000070000000c00000000d876af4c0000aa55 +69ms
TuyAPI Parsed: +0ms
TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 6 } +1ms
TuyAPI Got SET ack. +0ms
TuyAPI Pinging 192.168.1.17 +9s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +72ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +3ms
TuyAPI Pong from 192.168.1.17 +1ms
TuyAPI Pinging 192.168.1.17 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +109ms
TuyAPI Parsed: +0ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +1ms
TuyAPI Pong from 192.168.1.17 +1ms
........................ omissis
note:
- COMMAND DISCONNECT don't works, SET is OK
Here the node-red debug pad:
6/6/2021, 17:57:54node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "DISCONNECT" }
6/6/2021, 17:58:24node: Device INPUT
msg.payload : Object { dps: 1, set: true }
6/6/2021, 17:58:24node: Device Data
msg.payload.data.dps : Object { 1: true }
ERROR: no 'state' message from device-node. Expected state messages: "DISCONNECTED" (in 4.1 state msgs are sent)
ERROR: COMMAND DISCONNECT don't work: the SET OK after the COMMAND DISCONNECT
Hope that can help you. Feel free to ask for more trace if that useful.
Best regards
m.s.
from node-red-contrib-tuya-smart-device.
from node-red-contrib-tuya-smart-device.
new test series
- Tests using
bug-fix/connection-issue/src/tuya-smart-device.js.
- Device wifi plug: anonymized as "device5-id****"
- node-red: all flow disabled, only 'test ver. 4.1' enabled
A test
start conditions: debug trace: OFF, device: ON, node-red: from node-red start
Welcome to Node-RED
===================
7 Jun 14:46:19 - [info] Node-RED version: v1.2.6
7 Jun 14:46:19 - [info] Node.js version: v14.15.1
7 Jun 14:46:19 - [info] Windows_NT 10.0.18363 x64 LE
7 Jun 14:46:20 - [info] Loading palette nodes
7 Jun 14:46:22 - [info] Dashboard version 2.29.1 started at /ui
7 Jun 14:46:23 - [info] Settings file : d:\node-red\flow-1984\settings.js
7 Jun 14:46:23 - [info] Context store : 'default' [module=memory]
7 Jun 14:46:23 - [info] User directory : d:\node-red\flow-1984
7 Jun 14:46:23 - [warn] Projects disabled : editorTheme.projects.enabled=false
7 Jun 14:46:23 - [info] Flows file : d:\node-red\flow-1984\flows_i7-4770.json
7 Jun 14:46:23 - [info] Server now running at http://127.0.0.1:1984/
7 Jun 14:46:23 - [info] Starting flows
7 Jun 14:46:23 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:46:23 - [info] Started flows
D:\node-red>REM the dashboard:
D:\node-red>dashboard-1984.html
D:\node-red>REM the interface
D:\node-red>start chrome http://localhost:1984
7 Jun 14:46:28 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
7 Jun 14:46:40 - [info] [tuya-smart-device:e63245d0.e6cdc8] Disconnected from tuyaDevice.
7 Jun 14:46:41 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
note:
- test ok, device connected.
ERROR: no 'state' message from device-node. Expected 3 state messages: initial "DISCONNECTED", then "CONNECTING", then "CONNECTED" (in 4.1 state msgs are sent).
B test
start conditions: debug trace: OFF, device: OFF, node-red: from node-red start
Welcome to Node-RED
===================
7 Jun 14:51:39 - [info] Node-RED version: v1.2.6
7 Jun 14:51:39 - [info] Node.js version: v14.15.1
7 Jun 14:51:39 - [info] Windows_NT 10.0.18363 x64 LE
7 Jun 14:51:40 - [info] Loading palette nodes
7 Jun 14:51:43 - [info] Dashboard version 2.29.1 started at /ui
7 Jun 14:51:43 - [info] Settings file : d:\node-red\flow-1984\settings.js
7 Jun 14:51:43 - [info] Context store : 'default' [module=memory]
7 Jun 14:51:43 - [info] User directory : d:\node-red\flow-1984
7 Jun 14:51:43 - [warn] Projects disabled : editorTheme.projects.enabled=false
7 Jun 14:51:43 - [info] Flows file : d:\node-red\flow-1984\flows_i7-4770.json
7 Jun 14:51:43 - [info] Server now running at http://127.0.0.1:1984/
7 Jun 14:51:43 - [info] Starting flows
7 Jun 14:51:43 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:51:43 - [info] Started flows
D:\node-red>REM the dashboard:
D:\node-red>dashboard-1984.html
D:\node-red>REM the interface
D:\node-red>start chrome http://localhost:1984
7 Jun 14:51:53 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
7 Jun 14:51:53 - [info] [tuya-smart-device:e63245d0.e6cdc8] Cannot find the device, re-trying...
7 Jun 14:51:54 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:52:04 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
7 Jun 14:52:04 - [info] [tuya-smart-device:e63245d0.e6cdc8] Cannot find the device, re-trying...
7 Jun 14:52:05 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:52:15 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
7 Jun 14:52:15 - [info] [tuya-smart-device:e63245d0.e6cdc8] Cannot find the device, re-trying...
7 Jun 14:52:16 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:52:26 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
7 Jun 14:52:26 - [info] [tuya-smart-device:e63245d0.e6cdc8] Cannot find the device, re-trying...
7 Jun 14:52:27 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:52:37 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
7 Jun 14:52:37 - [info] [tuya-smart-device:e63245d0.e6cdc8] Cannot find the device, re-trying...
7 Jun 14:52:38 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:52:48 - [error] [tuya-smart-device:e63245d0.e6cdc8] Error: find() timed out. Is the device powered on and the ID or IP correct?
................... same never ending
note:
-. test ok, but why the test to other devices (see debug log)? (all flows are disabled)
ERROR: no 'state' message from device-node. Expected many state messages: initial "DISCONNECTED", then many "CONNECTING", then "DISCONNECTED"
ERROR: the "find() timed out." is sent as an error and not as STATE msg (in 4.1 state msgs are sent).
C test
start conditions: debug trace: OFF, device: ON, node-red: from node-red start
- now, after the device connection (same as A) the device is turned OFF
Welcome to Node-RED
===================
7 Jun 14:58:11 - [info] Node-RED version: v1.2.6
7 Jun 14:58:11 - [info] Node.js version: v14.15.1
7 Jun 14:58:11 - [info] Windows_NT 10.0.18363 x64 LE
7 Jun 14:58:12 - [info] Loading palette nodes
7 Jun 14:58:14 - [info] Dashboard version 2.29.1 started at /ui
7 Jun 14:58:15 - [info] Settings file : d:\node-red\flow-1984\settings.js
7 Jun 14:58:15 - [info] Context store : 'default' [module=memory]
7 Jun 14:58:15 - [info] User directory : d:\node-red\flow-1984
7 Jun 14:58:15 - [warn] Projects disabled : editorTheme.projects.enabled=false
7 Jun 14:58:15 - [info] Flows file : d:\node-red\flow-1984\flows_i7-4770.json
7 Jun 14:58:15 - [info] Server now running at http://127.0.0.1:1984/
7 Jun 14:58:15 - [info] Starting flows
7 Jun 14:58:15 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 14:58:15 - [info] Started flows
D:\node-red>REM the dashboard:
D:\node-red>dashboard-1984.html
D:\node-red>REM the interface
D:\node-red>start chrome http://localhost:1984
7 Jun 14:58:19 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
----------------- at 14:59 I turn OFF the device power
7 Jun 14:59:11 - [info] [tuya-smart-device:e63245d0.e6cdc8] Disconnected from tuyaDevice.
(node:9296) UnhandledPromiseRejectionWarning: Error: connection timed out
at Socket.<anonymous> (d:\node-red\flow-1984\node_modules\tuyapi\index.js:442:18)
at Object.onceWrapper (events.js:421:28)
at Socket.emit (events.js:315:20)
at Socket._onTimeout (net.js:483:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9296) 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: 1)
(node:9296) [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.
note:
- no more trace until 15:05 !!!
- after the device disconnected, no connection retry for more than 300 sec.
- after that, if I turn ON the device: nothing happens in trace
- after that, if I turn ON the device AND if I send COMMAND CONNECT: nothing happens in trace (in 4.1 it is working).
ERROR: no 'state' message from device-node. Expected state messages: "DISCONNECTED", then many: "CONNERCTING", "DISCONNECTED".
ERROR: impossible to reconnect: the condition of test B is not restored.
D test
start conditions: debug trace: OFF, device: ON, node-red: from node-red start
- now, after the device connection (same as A) I send a COMMAND DISCONNECT then SET dp 1 true
Welcome to Node-RED
===================
7 Jun 15:04:31 - [info] Node-RED version: v1.2.6
7 Jun 15:04:31 - [info] Node.js version: v14.15.1
7 Jun 15:04:31 - [info] Windows_NT 10.0.18363 x64 LE
7 Jun 15:04:32 - [info] Loading palette nodes
7 Jun 15:04:35 - [info] Dashboard version 2.29.1 started at /ui
7 Jun 15:04:35 - [info] Settings file : d:\node-red\flow-1984\settings.js
7 Jun 15:04:35 - [info] Context store : 'default' [module=memory]
7 Jun 15:04:35 - [info] User directory : d:\node-red\flow-1984
7 Jun 15:04:35 - [warn] Projects disabled : editorTheme.projects.enabled=false
7 Jun 15:04:35 - [info] Flows file : d:\node-red\flow-1984\flows_i7-4770.json
7 Jun 15:04:35 - [info] Server now running at http://127.0.0.1:1984/
7 Jun 15:04:35 - [info] Starting flows
7 Jun 15:04:35 - [info] [tuya-smart-device:e63245d0.e6cdc8] initiating the find command
7 Jun 15:04:35 - [info] Started flows
7 Jun 15:04:35 - [info] [tuya-smart-device:e63245d0.e6cdc8] Connected to device! device5-id****
D:\node-red>REM the dashboard:
D:\node-red>dashboard-1984.html
D:\node-red>REM the interface
D:\node-red>start chrome http://localhost:1984
------- at 15:06:07 I send COMMAD DISCONNECT
----------- NONE ON TRACE !
------- at 15:06:43 I send 'SET dp 1, false:
7 Jun 15:06:43 - [info] [tuya-smart-device:e63245d0.e6cdc8] [object Object]
------- nothing more
note:
- COMMAND DISCONNECT don't works, SET is OK
Here the node-red debug pad:
7/6/2021, 15:06:07node: Device INPUT
msg.payload : Object { operation: "CONTROL", action: "DISCONNECT" }
7/6/2021, 15:06:43node: Device INPUT
msg.payload : Object { dps: 1, set: false }
7/6/2021, 15:06:43node: Device Data
msg.payload.data.dps : Object { 1: false }
ERROR: no 'state' message from device-node. Expected state messages: "DISCONNECTED"
ERROR: COMMAND DISCONNECT don't work: the SET OK after the COMMAND DISCONNECT
Complete logs, but I don't see big differences...
Ok, good luck.
Best regards
m.s.
from node-red-contrib-tuya-smart-device.
Quick check are you checking on this branch feature/fix-timeouts ?
In the logs I see another bugfix branch,.....
from node-red-contrib-tuya-smart-device.
Pls. try the modified tuya-smart-device version here, I tried to solve the main problems:
-
UnhandledPromiseRejectionWarning : solved
-
power ON => OFF: restart of the reconnect: solved
-
multiple STATE messages : solved
-
initial start STATE message : solved
-
SET/GET on DISONNECTED STATE: solved
-
COMMAND CONNECT/DISCONNECT supetflous: solved
I tested it with only one device.
Nex days I will try more.
Best regards
m. s.
from node-red-contrib-tuya-smart-device.
I cannot modify custom versions. Have you taken the correct branch?
from node-red-contrib-tuya-smart-device.
The file attached to the previous comment, is the file tuya-smart-device.zip, in https://github.com/vinodsr/node-red-contrib-tuya-smart-device/files/6611494/tuya-smart-device.zip.
I can't send it by mail, because of Google restrictions. Maybe changing the name... Let me know.
from node-red-contrib-tuya-smart-device.
Thanks for the changes. I think you were working on old code . most of the changes in this has already been done.
I had incorporated the unhandled exception part and the error handling for the timeout while setting.
The updated code base in there in the fix timeout branch https://github.com/vinodsr/node-red-contrib-tuya-smart-device/tree/feature/fix-timeouts
Please take the latest version and test your cases. I am unable to test the unhandled exception as it is not happening in my case.
Thank you for your dedication. :)
from node-red-contrib-tuya-smart-device.
Released 4.1.1
Please verify your issues are fixed
from node-red-contrib-tuya-smart-device.
Related Issues (20)
- Weird key format? HOT 3
- Tuya protocol 3.4, 3.5 support missed HOT 1
- An unusual response - 2 HOT 1
- Node does not work in conjunction with Http in node HOT 1
- how to connect to sub-devices that are managed by a tuya gateway? HOT 2
- Bi-Meter disconnects from node red HOT 5
- GET response the same for schema and DPS ID HOT 3
- unreadable 'data' output from node HOT 2
- Device not connected. Can't send the SET commmand HOT 1
- where do i set the api credentials HOT 1
- [announce] nr_Tuya_OpenAPI_2.0, a node_red flow to access Tuya Cloud HOT 1
- Manage all Tuya devices with node-red HOT 1
- Cluttered log file HOT 5
- Problem with Error code "Payload must be a number in range 0-100" HOT 1
- Error in tuyapi
- More finner log info control
- Data refresh very Slow HOT 1
- Node not works if some characters in the key HOT 8
- unreadable 'data' output from node HOT 1
- tuya ir remote control with virtual device id
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-red-contrib-tuya-smart-device.