Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ver. 4.0.1 #54

Closed
msillano opened this issue Apr 12, 2021 · 8 comments · Fixed by #58
Closed

Problem with ver. 4.0.1 #54

msillano opened this issue Apr 12, 2021 · 8 comments · Fixed by #58

Comments

@msillano
Copy link

msillano commented Apr 12, 2021

Updated to ver. 4.0.1. I found a big problem, missed the output msg!
Example:
The simplest flow, using a Smart_Switch plus 2 nodes:

[{"id":"4c90f0fb.6e6d2","type":"tab","label":"extra.test","disabled":false,"info":""},{"id":"9aec7c62.dedc2","type":"debug","z":"4c90f0fb.6e6d2","name":"FROM SWITCH","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":320,"y":80,"wires":[]},{"id":"adcdaeb2.6e71f","type":"inject","z":"4c90f0fb.6e6d2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"dps\":\"1\",\"set\":false}","payloadType":"json","x":130,"y":160,"wires":[["5ba5abff.f3fcb4"]]},{"id":"5ba5abff.f3fcb4","type":"tuya-smart-device","z":"4c90f0fb.6e6d2","deviceName":"switch module#1","deviceId":"bfa355aa196ae*******","deviceKey":"10ad2960ff******","deviceIp":"","retryTimeout":"4000","findTimeout":"4000","tuyaVersion":"3.1","x":110,"y":80,"wires":[["9aec7c62.dedc2"]]}]

The debug output:

  TuyAPI Pinging 192.168.1.16 +10s
  TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +119ms
  TuyAPI Parsed: +2ms
  TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +3ms
  TuyAPI Pong from 192.168.1.16 +1ms
  express:router dispatching POST /inject/adcdaeb2.6e71f +2m
  express:router query  : /inject/adcdaeb2.6e71f +1ms
  express:router expressInit  : /inject/adcdaeb2.6e71f +3ms
  express:router mounted_app  : /inject/adcdaeb2.6e71f +1ms
  express:router dispatching POST /inject/adcdaeb2.6e71f +1ms
  express:router query  : /inject/adcdaeb2.6e71f +0ms
  express:router expressInit  : /inject/adcdaeb2.6e71f +1ms
  express:router corsMiddleware  : /inject/adcdaeb2.6e71f +1ms
  express:router jsonParser  : /inject/adcdaeb2.6e71f +1ms
  body-parser:json content-type undefined +2m
  body-parser:json skip parsing +0ms
  express:router urlencodedParser  : /inject/adcdaeb2.6e71f +2ms
  body-parser:urlencoded content-type undefined +1ms
  body-parser:urlencoded skip parsing +1ms
  express:router mounted_app  : /inject/adcdaeb2.6e71f +1ms
  express:router dispatching POST /inject/adcdaeb2.6e71f +5ms
  express:router query  : /inject/adcdaeb2.6e71f +0ms
  express:router expressInit  : /inject/adcdaeb2.6e71f +3ms
  express:router serveStatic  : /inject/adcdaeb2.6e71f +0ms
  express:router mounted_app  : /inject/adcdaeb2.6e71f +1ms
  express:router dispatching POST /inject/adcdaeb2.6e71f +0ms
  express:router query  : /inject/adcdaeb2.6e71f +1ms
  express:router expressInit  : /inject/adcdaeb2.6e71f +0ms
  express:router mounted_app  : /inject/adcdaeb2.6e71f +1ms
  express:router dispatching POST /inject/adcdaeb2.6e71f +0ms
  express:router query  : /inject/adcdaeb2.6e71f +1ms
  express:router expressInit  : /inject/adcdaeb2.6e71f +0ms
  TuyAPI SET Payload: +8s
  TuyAPI {
  TuyAPI   devId: 'bfa355aa196ae*******',
  TuyAPI   gwId: 'bfa355aa196ae*******',
  TuyAPI   uid: '',
  TuyAPI   t: 1618227689,
  TuyAPI   dps: { '1': false }
  TuyAPI } +4ms
  TuyAPI Received data: 000055aa00000021000000070000000c00000000167be2e10000aa55 +218ms
  TuyAPI Parsed: +1ms
  TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 33 } +1ms
  TuyAPI Got SET ack. +1ms
  TuyAPI Received data: 000055aa00000000000000080000004b00000000332e3300000000000000ac00000001f3fc6d8608d019e3d7c7e5022c16e184883cc6cbd441c8b209250a0222ae613e4ab9f738ccf13e1cc293961a60ddb6431b66f5220000aa55 +97ms
  TuyAPI Parsed: +0ms
  TuyAPI {
  TuyAPI   payload: { dps: { '1': false }, t: 1618227687 },
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 8,
  TuyAPI   sequenceN: 0
  TuyAPI } +2ms
  TuyAPI Received DATA packet +1ms
  TuyAPI Pinging 192.168.1.16 +2s
  TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +54ms
  TuyAPI Parsed: +2ms
  TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +2ms
  TuyAPI Pong from 192.168.1.16 +2ms
  engine:ws received "2" +19s
  engine:socket packet +19s
  engine:socket got ping +2ms
  engine:socket sending packet "pong" (undefined) +0ms
  engine:socket flushing buffer to transport +1ms
  engine:ws writing "3" +4ms`

The log shows data send and received by tuyapi, but nothing in output from node-red-contrib-tuya-smart-device !! Strange.

p.s.
Reinstalled ver. 3.0.2: all works well with all devices.

Best regards
m.s.

@vinodsr
Copy link
Owner

vinodsr commented Apr 12, 2021 via email

@msillano
Copy link
Author

  1. Using ver 3.0.2 and tuyapi 6.1.1
    ================ output (OK) :
     object
		payload: object
			data: object
				dps: object
					1: false
				t: 1618324008
		deviceId: "bfa355aa196ae5975cy6ii"
		deviceName: "switch module#1"
	_msgid: "2d3df1b1.32761e"
  1. updating to 4.0.2, using palette, restarted node-rerd:
    ================ output (BAD) : nothing

The log:

 TuyAPI SET Payload: +5s
  TuyAPI {
  TuyAPI   devId: 'bfa355aa196ae5975cy6ii',
  TuyAPI   gwId: 'bfa355aa196ae5975cy6ii',
  TuyAPI   uid: '',
  TuyAPI   t: 1618324599,
  TuyAPI   dps: { '1': false }
  TuyAPI } +0ms
  TuyAPI Received data: 000055aa00000001000000070000000c00000000a505a9140000aa55 +229ms
  TuyAPI Parsed: +1ms
  TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 1 } +0ms
  TuyAPI Got SET ack. +1ms
  TuyAPI Received data: 000055aa00000000000000080000004b00000000332e3300000000000000c200000001f3fc6d8608d019e3d7c7e5022c16e18406d0bec5f45b020a11b4373b024dbf50b61ffb0660ed11097028967164685eda204d01950000aa55 +92ms
  TuyAPI Parsed: +0ms
  TuyAPI {
  TuyAPI   payload: { dps: { '1': false }, t: 1618324599 },
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 8,
  TuyAPI   sequenceN: 0
  TuyAPI } +1ms
  TuyAPI Received DATA packet +0ms
  1. using 4.0.2, modified so:
106 ......
      tuyaDevice.on('dp-refresh', data => {
          node.log(`dp-refresh from device: ${JSON.stringify(data)}`);
          setStatusConnected();
          node.send({
              payload: {
                  data: data,
                  deviceId: node.deviceId,
                  deviceName: node.deviceName
              }
          });
      });
     tuyaDevice.on('data', data => {
          node.log(`data from device: ${JSON.stringify(data)}`);
          setStatusConnected();
          node.send({
              payload: {
                  data: data,
                  deviceId: node.deviceId,
                  deviceName: node.deviceName
              }
          });
      });

================ output (OK) ( but from 'data' event):

The log:

 TuyAPI Got SET ack. +0ms
 TuyAPI Received data: 000055aa00000000000000080000004b00000000332e3300000000000000c500000001f3fc6d8608d019e3d7c7e5022c16e184d3d9699d020f52eda405b5d1c484ef3cb61ffb0660ed11097028967164685edaa93e69560000aa55 +96ms
 TuyAPI Parsed: +1ms
 TuyAPI {
 TuyAPI   payload: { dps: { '1': false }, t: 1618327749 },
 TuyAPI   leftover: false,
 TuyAPI   commandByte: 8,
 TuyAPI   sequenceN: 0
 TuyAPI } +1ms
 TuyAPI Received DATA packet +1ms
13 Apr 17:29:11 - [info] [tuya-smart-device:switch module#1] data from device: {"dps":{"1":false},"t":1618327749}
 TuyAPI Pinging 192.168.1.16 +7s
  1. using tuyapi 6.1.1, so modified:
50      nullPayloadOnJSONError = false,
        issueGetOnConnect = false,
        issueRefreshOnConnect = true

801    throw new Error('find() timed out device ' + this.device.id);

and ADDED a second device (AC meter):
I get the data packet from "dp_refresh" and from "data" events from the same device:

================ output (OK)

The Log:

TuyAPI Received data: 000055aa00000000000000080000006b00000000332e330000000000000401000000018c83b36d05731852accc351738c9da074287d07fa9a93b83e680bc4317031bf38f8848c06fc97ef23e9e3a907e6d813d4d8404c890341f6e1f17d43f57240276780babfe07ab875790c509da561b996646763f250000aa55 +275ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI   payload: { devId: '486441603c6105ca6f51', dps: { '20': 2300 }, t: 1618329950 },
TuyAPI   leftover: false,
TuyAPI   commandByte: 8,
TuyAPI   sequenceN: 0
TuyAPI } +1ms
TuyAPI Received DP_REFRESH packet. +0ms
13 Apr 18:05:50 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"486441603c6105ca6f51","dps":{"20":2300},"t":1618329950}
TuyAPI Pinging 192.168.1.22 +8s
(omissis...)
TuyAPI Got SET ack. +2ms
TuyAPI Received data: 000055aa00000000000000080000006b00000000332e330000000000000402000000018c83b36d05731852accc351738c9da074287d07fa9a93b83e680bc4317031bf3df1921081dfb2fe75b15f2efcbc2359d86af3ad5a068d2d5c0e7c91fbee2abcdfd064abafbec9b14a5a1e906aea7805c4453b7180000aa55 +45ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI   payload: { devId: '486441603c6105ca6f51', dps: { '1': true }, t: 1618329987 },
TuyAPI   leftover: false,
TuyAPI   commandByte: 8,
TuyAPI   sequenceN: 0
TuyAPI } +3ms
TuyAPI Received DATA packet +2ms
13 Apr 18:06:27 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"486441603c6105ca6f51","dps":{"1":true},"t":1618329987}
TuyAPI Pinging 192.168.1.22 +1s
(omissis...)
TuyAPI Received data: 000055aa00000000000000080000005b00000000332e330000000000000403000000018c83b36d05731852accc351738c9da074287d07fa9a93b83e680bc4317031bf3ed233fc246199abe22fce613ed4836b3e5fb3f5b072881d3062276de407e50460b9294030000aa55 +1s
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI   payload: { devId: '486441603c6105ca6f51', dps: { '18': 0 }, t: 1618330031 },
TuyAPI   leftover: false,
TuyAPI   commandByte: 8,
TuyAPI   sequenceN: 0
TuyAPI } +4ms
TuyAPI Received DP_REFRESH packet. +2ms
13 Apr 18:07:11 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"486441603c6105ca6f51","dps":{"18":0},"t":1618330031}
TuyAPI Pinging 192.168.1.22 +7s
(omissis...)
TuyAPI GET Payload: +4s
TuyAPI {
TuyAPI   gwId: '486441603c6105ca6f51',
TuyAPI   devId: '486441603c6105ca6f51',
TuyAPI   t: '1618330425',
TuyAPI   dps: {},
TuyAPI   uid: '486441603c6105ca6f51'
TuyAPI } +0ms
TuyAPI Received data: 000055aa000000330000000a0000006c000000008c83b36d05731852accc351738c9da074287d07fa9a93b83e680bc4317031bf3ea5438c333565d9b521b86bdc708906ffb71a2916bb5f8ba76d4c31fad8ea6bbe35a47e326940699d5cb788a96194ee02a4466b17970d17566ceadabca79aa158e7d0b150000aa55 +209ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI   payload: {
TuyAPI     devId: '486441603c6105ca6f51',
TuyAPI     dps: { '1': true, '9': 0, '18': 0, '19': 44, '20': 2300, '101': 108 }
TuyAPI   },
TuyAPI   leftover: false,
TuyAPI   commandByte: 10,
TuyAPI   sequenceN: 51
TuyAPI } +4ms
TuyAPI Received DATA packet +3ms
13 Apr 18:13:45 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"486441603c6105ca6f51","dps":{"1":true,"9":0,"18":0,"19":44,"20":2300,"101":108}}
TuyAPI Pinging 192.168.1.22 +4s
 (omissis...)
TuyAPI Pong from 192.168.1.16 +1ms
TuyAPI Received data: 000055aa00000000000000080000006b00000000332e330000000000000405000000018c83b36d05731852accc351738c9da074287d07fa9a93b83e680bc4317031bf3857d8a0a6ec06c1c6fadff21ddbfca2fc29015c85b3e3208abb8034e026ad7d0780babfe07ab875790c509da561b99667714e3e80000aa55 +894ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI   payload: { devId: '486441603c6105ca6f51', dps: { '20': 2321 }, t: 1618330431 },
TuyAPI   leftover: false,
TuyAPI   commandByte: 8,
TuyAPI   sequenceN: 0
TuyAPI } +3ms
TuyAPI Received DP_REFRESH packet. +2ms
13 Apr 18:13:51 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"486441603c6105ca6f51","dps":{"20":2321},"t":1618330431}

Conclusion:
- I will test some days this last option, to see if it is okay in any situations (I'm now using 20+ devices in 2 O.S.).

Best regards
m.s.

@vinodsr
Copy link
Owner

vinodsr commented Apr 13, 2021

@msillano what I see for your log is that the messages are not repeated for data and data refresh events..may be I need to subscribe for both.

Waiting for further updates from your testing.

@msillano
Copy link
Author

msillano commented Apr 14, 2021

Using an 'AC meter' (https://m.made-in-china.com/product/Dds238-2-WiFi-Single-Phase-DIN-Rail-Type-WiFi-Remote-Control-Energy-Meter-790065132.html).

dP Key: 1 switch, 9: countdown, 18: Current (mA), 19: Watt * 10, 20: V * 10, 101: KWh * 100

SCHEMA {"operation":"GET", "schema":true}: as expected.

14 Apr 16:27:00 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":117}}
14 Apr 16:27:01 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":117}}
14 Apr 16:27:02 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":117}}
14 Apr 16:27:03 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":117}}
14 Apr 16:27:04 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"101":118},"t":1618410423}  (note: PUSH by device)
14 Apr 16:27:07 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":118}}
14 Apr 16:28:23 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":118}}
14 Apr 16:30:16 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2312,"101":118}}
14 Apr 16:30:19 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":556},"t":1618410618} (note: PUSHed)
14 Apr 16:30:20 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"19":199},"t":1618410619} (note: PUSHed)
14 Apr 16:30:20 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":99},"t":1618410620}  (note: PUSHed)
14 Apr 16:30:20 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"19":87},"t":1618410620}  (note: PUSHed)
14 Apr 16:30:21 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":99,"19":87,"20":2312,"101":118}}
14 Apr 16:30:32 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":99,"19":87,"20":2312,"101":118}}

GET {"operation":"GET","dps":"20"}: strange, like SCHEMA

14 Apr 15:53:23 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2308,"101":117}}
14 Apr 15:53:24 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2308,"101":117}}
14 Apr 15:53:25 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2308,"101":117}}
14 Apr 15:53:26 - [info] [tuya-smart-device:AC meter] data from device: {"devId":"48644******","dps":{"1":true,"9":0,"18":57,"19":44,"20":2308,"101":117}}

SET null {"dps":"20", "set":null}: as expected

14 Apr 15:55:52 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2310},"t":1618408551}
14 Apr 15:55:53 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2310},"t":1618408552}
14 Apr 15:55:55 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2310},"t":1618408554}
14 Apr 15:55:56 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2310},"t":1618408555}
14 Apr 15:55:57 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2310},"t":1618408556}
14 Apr 15:55:58 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2310},"t":1618408557}

As you can see data don't change. Very low sampling rate: see timing.

Changed code in tuya-smart-device.js:

 32       switch (operation) {
               case "RFR":
                    tuyaDevice.refresh(msg.payload);
                    break;
                case "SET":

RFR 20 {"operation":"RFR", "dps":"20"} repeat every 1 sec:

14 Apr 16:04:58 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2301},"t":1618409097}
14 Apr 16:04:59 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2299},"t":1618409098}
14 Apr 16:05:00 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":58},"t":1618409099}
14 Apr 16:05:00 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2300},"t":1618409099}
14 Apr 16:05:01 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":57},"t":1618409100}
14 Apr 16:05:02 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"19":43},"t":1618409101}
14 Apr 16:05:02 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2299},"t":1618409101}
14 Apr 16:05:03 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"19":44},"t":1618409102}
14 Apr 16:05:03 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2298},"t":1618409102}
14 Apr 16:05:05 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":58},"t":1618409104}
14 Apr 16:05:05 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2299},"t":1618409104}
  1. data changes every reading, Fast sampling rate (every request, now 1 sec.)
  2. some data look missed (e.g. 16:05:04)
  3. I asked for dps 20, but I get results also for 18, 19...
  4. maybe data is sent only in case of change: that justifies both 2 and 3.

Works also so : {"operation":"RFR"} repeat every 1 sec:

14 Apr 16:12:59 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"19":45},"t":1618409578}
14 Apr 16:12:59 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2302},"t":1618409578}
14 Apr 16:13:00 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":57},"t":1618409579}
14 Apr 16:13:00 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"19":44},"t":1618409579}
14 Apr 16:13:00 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2304},"t":1618409579}
14 Apr 16:13:01 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"18":58},"t":1618409580}
14 Apr 16:13:01 - [info] [tuya-smart-device:AC meter] dp-refresh from device: {"devId":"48644******","dps":{"20":2305},"t":1618409580}

Conclusion.

  • In some devices, the REFRESH command (18) can change the default device sample rate, as fast as 1 sec.
  • The GET not: it uses the default sample rate, and repeat the last data send (From MQTT engine?).
  • Some dps look not interested by the REFRESH: in this case the dps 1, 9, 101.
  • Normally some dps are PUSHed as 'dp-refresh' at any variation (?) (see dps 18, 19), some not (dps 20): it does some averages?
  • Here SCHEMA and GET are always 'data' events, so I think you must use both events: 'data' and 'dp-refresh', as I do.
  • As usual with Tuya devices, this behavior can change from device to device.
  • For that, I don't like the wired 'magic' dps arrays present in tuyapi - index.js, at lines 104 and 732. Strange, but eliminating the arrays, the result doesn't change!

Best regards
m.s.

@vinodsr
Copy link
Owner

vinodsr commented Apr 18, 2021

@msillano in order to avoid complex flows, what i am planning is

  • add option to refresh as a command
  • by default the node will subscribe for both data and data refresh events. but this behavior can be set from the node's config page.

I will push the changes to a separate branch and you can test it.

@vinodsr
Copy link
Owner

vinodsr commented Apr 18, 2021

@msillano Can you please verify the new feature @ feature/add-support-for-refresh branch

Now you can send the new operation "REFRESH".

You can also listen to multiple events in the config page. (for both single and generic node)

@msillano
Copy link
Author

msillano commented Apr 20, 2021

It works well... Thanks

20 Apr 16:42:52 - [info] [tuya-smart-device:power strip] Data from device  [event:data]: {"devId":"3613666124a1600db127","dps":{"1":false,"2":false,"3":false,"4":false,"5":false,"9":0,"10":0,"11":0,"12":0,"13":0}}
20 Apr 16:43:04 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"103":15},"cid":"00158d00056a19ad","t":1618929783}
20 Apr 16:43:04 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"101":55},"cid":"00158d00*****","t":1618929783}
// FAST mode, 6s
20 Apr 16:45:44 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"19":45},"t":1618929943}
20 Apr 16:45:44 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2331},"t":1618929944}
20 Apr 16:45:50 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"18":57},"t":1618929949}
20 Apr 16:45:50 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"19":44},"t":1618929949}
20 Apr 16:45:50 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2329},"t":1618929949}
20 Apr 16:45:56 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2331},"t":1618929955}
20 Apr 16:45:58 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"19":45},"t":1618929957}
20 Apr 16:46:02 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"18":58},"t":1618929962}
20 Apr 16:46:02 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2333},"t":1618929962}
// back to slow mode
20 Apr 16:48:04 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2324},"t":1618930083}
20 Apr 16:52:17 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2335},"t":1618930336}
20 Apr 16:54:24 - [info] [tuya-smart-device:power strip] Data from device  [event:data]: {"devId":"3613666124*****","dps":{"1":true,"2":true,"3":true,"4":true,"5":true},"t":1618930463}
20 Apr 16:54:28 - [info] [tuya-smart-device:power strip] Data from device  [event:data]: {"devId":"3613666124*****","dps":{"1":false,"2":false,"3":false,"4":false,"5":false},"t":1618930468}
20 Apr 16:54:58 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"18":58},"t":1618930497}
20 Apr 16:56:58 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2332},"t":1618930617}
20 Apr 16:58:11 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2320},"t":1618930690}
20 Apr 16:58:24 - [info] [tuya-smart-device:meter] Data from device  [event:dp-refresh]: {"devId":"48644160*****","dps":{"20":2331},"t":1618930703}
20 Apr 16:58:38 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"103":14},"cid":"00158d00*****","t":1618930717}
20 Apr 16:58:40 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"101":54},"cid":"00158d00*****","t":1618930717}
20 Apr 16:59:00 - [info] [tuya-smart-device:Smart IR #1] initiating the find command
20 Apr 16:59:59 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"115":"DQ0NDQ0MDAwMDA0MDA0NDQ0AAAAAAAAA"},"cid":"60a423ff*****","t":1618930798}
20 Apr 17:00:00 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"110":"EBAQEBAQEBATExMTExMTExMAAAAAAAAA"},"cid":"60a423ff*****","t":1618930799}
20 Apr 17:00:01 - [info] [tuya-smart-device:Zigbee Gateway] Data from device  [event:dp-refresh]: {"dps":{"119":"ZGRkZGRkZGRkZGRkZGRkZGQAAAAAAAAA"},"cid":"60a423ff*****","t":1618930800}

  • In FAST mode data are send every 6 seconds (as set in looptimer2 node) OK
  • In slow mode data rate is very variable: 2 min... 13 sec. OK
  • As you can see, some devices send [event:data] OK

'by default the node will subscribe for both data and data refresh events. but this behavior can be set from the node's config page.': the unique reason I see to change the default is the case of duplicated data.
But that never happened on my devices.

P.S.
The extra nodes in ISSUE#56 are required to get an easy REFRESH use:

  • the looptimer2 sends an auto 'REFRESH command at the required user data rate (set on interface per single device).
  • the function node enables the user control of FAST mode (i.e. ON/OFF of looptimer2) using an extra DP, called '_fast', or if you like '201', or..., handled as a native dp.
  • Explicit 'REFRESH' commands still pass through.

This way the FAST control can be done with SET: { dp:"_fast", set: true|false }. Also GET/MULTIPLE works as expected, i.e. as a native dp. SCHEMA sends 2 data packets: one for the '_fast' dp only, one from the device.

Best regards
m.s.

@vinodsr
Copy link
Owner

vinodsr commented Apr 23, 2021

Changes are now merged. Please check version 4.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants