Skip to content

Zigbee subdevice dp-refresh not working #695

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

Open
serseb opened this issue Feb 22, 2025 · 7 comments
Open

Zigbee subdevice dp-refresh not working #695

serseb opened this issue Feb 22, 2025 · 7 comments
Labels

Comments

@serseb
Copy link

serseb commented Feb 22, 2025

I have a ZigBee plug which I can control successfully (ON/OFF) by sending requests to the gateway and using cid to specify the subdevice. However, when I try to issue a forced refresh in order to get the power consumption, I get a DP_REFRESH event without data, as following:

TuyAPI GET Payload (refresh): +818ms
TuyAPI {
TuyAPI gwId: 'GATEWAY_ID',
TuyAPI devId: 'GATEWAY_ID',
TuyAPI t: '1740192863',
TuyAPI dpId: [ 4, 5, 6, 18, 19, 20 ],
TuyAPI uid: 'GATEWAY_ID',
TuyAPI cid: 'SUBDEVICE_MAC_NO_COLONS'
TuyAPI } +1ms
TuyAPI Received data: 000055aa00004e81000000120000002800000000b82db93d716f2e95a05604143f0971ea5f41bd1fc93423a63c884686d2c630710000aa55 +10ms
TuyAPI Parsed: +4ms
TuyAPI { payload: false, leftover: false, commandByte: 18, sequenceN: 20097 } +0ms
TuyAPI Received DP_REFRESH response packet without data - resolve +1ms

The subdevice does support this feature as whenever I have the device "Electric" screen in SmartLife app I do get the DP_REFRESH event successfully every few seconds. Otherwise, I will only get a DP_REFRESH at every 60 seconds or so.

I also tried to use the device Virtual ID instead of the MAC address, without success.

Please advise if there is a known bug / missing feature, or I'm missing something.

@Apollon77
Copy link
Collaborator

Without more infos it is hard to tell. So what exactly you call? Ideally please provide more log that we also see what is sent before. There are devices that suprt GET and other need a set before ... So please add more log

@serseb
Copy link
Author

serseb commented Feb 26, 2025

Thank you for your reply Apollon77,

That's all I'm sending to this ZigBee device in this particular example. Remember, this a a ZigBee device, therefore it's connected to the gateway, so I'm not connecting directly to it. First I connect to the gateway, as usual, and then as I wish to get the power consumption figures from the device, I'm sending the command shown to the gateway, but targeted to this ZigBee device by using "cid". Everything works fine when I try to change the power state of the device, with the set() method, and I receive the state change immediately. The problem lies when I try to get the read-only values, like wattage (dps 19), amperage (18), or voltage (20). These will come automatically every few minutes, but never when I issue the dp-refresh command, as shown in the first post. They do come however every few seconds, when I have the device screen open in the Smart Life app, so the ZigBee device does have the capability the send this data on demand.

Here is the log with the 3 steps performed:

  1. Successfully connected to the gateway:

TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to 10.0.0.100... +0ms
TuyAPI Socket connected. +2ms
TuyAPI Protocol 3.4, 3.5: Negotiate Session Key - Send Msg 0x03 +1ms
TuyAPI Received data: 000055aa0000eba90000000400000068000000002ed066769ae4bc6e2e1cc74eb4313a6fb32a1659ac8b64dcafe19d304ee07eb9c3d7111319e98363fd7433d7d4f1e
80564b6d0a3eb5d38b90a0368227a75eced0a00a4727c967fa0ed647fecd9aac588e53fff66640d8d5980f5c55b53ebc4140000aa55 +15ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: <Buffer 66 39 38 62 31 62 30 62 64 32 34 30 32 36 38 33 87 6a 50 b7 ef 2b 36 3a 79 09 44 f0 a4 8d 11 95 8f 50 65 e3 5a fa dc 2b 74 47 88
d1 7a d3 13 a4>,
TuyAPI leftover: false,
TuyAPI commandByte: 4,
TuyAPI sequenceN: 60329
TuyAPI } +0ms
TuyAPI Protocol 3.4, 3.5: Local Random Key: HIDDEN +1ms
TuyAPI Protocol 3.4, 3.5: Remote Random Key: HIDDEN +0ms
TuyAPI Protocol 3.4, 3.5: Session Key: HIDDEN +1ms
TuyAPI Protocol 3.4, 3.5: Initialization done +0ms

  1. Successfully turned on the ZigBee device:

TuyAPI SET Payload: +21ms
TuyAPI {
TuyAPI data: { ctype: 0, dps: { '1': true }, cid: 'SUBDEVICE_CID' },
TuyAPI protocol: 5,
TuyAPI t: 1740529754
TuyAPI } +0ms
TuyAPI Received data: 000055aa0000ebad0000000d000000280000000064f5ec5f9585d1b74cd86f6e028a3e9a2c0d7f60bcd304176dd6d3b314e39a770000aa55 +9ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 13, sequenceN: 60333 } +0ms
TuyAPI Got SET ack. +0ms
TuyAPI Received data: 000055aa0000ebae000000080000008800000000306959519828cc7d7c58fc5d395787fc91a45c15fc0f42e44f724dee41f5e1169e91146a827da1dde365e926efa7d
741394de9b00290532c9db1b9bb1d5cf3d364bfe803139f0bf4acc2471a897ea94b5f33b7cb275f670a9241d559c70f98c8fee0d7e1a8470474222238b24db00ae2168b7f150d90f1f9ac508366b6
69e2420000aa55 +129ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: { dps: { '1': true }, cid: 'SUBDEVICE_CID', t: 1740529754 },
TuyAPI leftover: false,
TuyAPI commandByte: 8,
TuyAPI sequenceN: 60334
TuyAPI } +0ms
TuyAPI Received DATA packet +0ms
TuyAPI data: 8 : {"dps":{"1":true},"cid":"SUBDEVICE_CID","t":1740529754} +1ms

  1. Failed attempt to refresh dps 18 19 & 20 on the ZigBee device:

TuyAPI GET Payload (refresh): +825ms
TuyAPI {
TuyAPI gwId: 'GATEWAY_ID',
TuyAPI devId: 'GATEWAY_ID',
TuyAPI t: '1740529755',
TuyAPI dpId: [ 18, 19, 20 ],
TuyAPI uid: 'GATEWAY_ID',
TuyAPI cid: 'SUBDEVICE_CID'
TuyAPI } +0ms
TuyAPI Received data: 000055aa0000ebaf000000120000002800000000a1682926de7e961587cde6c9841d3b3098f96ef825b4c302373f2da355fef45c0000aa55 +9ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 18, sequenceN: 60335 } +0ms
TuyAPI Received DP_REFRESH response packet without data - resolve +0ms

@Apollon77
Copy link
Collaborator

@serseb hm ... thats a difficult one. also because of that whole data encryption stuff I think we stay with 2 options:
In general looks all good.

What you can try is to issue a "set" ala:

           const setOptions = {
               dps: [ 18, 19, 20 ],
               set: null,
               cid:...
               ...
                isSetCallToGetData: true
          };
          data = await this.set(setOptions);

Do you get an snwer then?

@serseb
Copy link
Author

serseb commented May 17, 2025

Thanks for the suggestion but still doesn't work. it also triggers an error as it gets not response after that "set":

Error: Timeout waiting for status response from device id: bfe5538ec58a300568jmp3
at ...tuyapi\index.js:460:15

If it would be successful, then I would get something like this (this is what I receive if I keep the SmartLife app open on the "Electric" on that device):

TuyAPI Received data: 000055aa0000f4db00000008000000b800000000fcf3f5157f2c475da140340d23291d8553f4f30df288bc5b5b218c05b850593652bd6a464bac941f8ba2f76e6caa3
19a1030f3d52975ebc33b118889b9b73484fcc9461cbec4f125c5b584c2c5c616a61d860a8f243e556448e65dc449450f78fdfe33c27683a64cbb41ee49d371d17d9ba6fc1f34a2e564f2355d930f
900ce603482f34f6d5504b66f1702fa65ad645432c91e2f7b716adeab1b88ced28b6359a424b1e0479e1f3eea256de1dd649480000aa55 +801ms
TuyAPI Parsed: +0ms
TuyAPI {
TuyAPI payload: {
TuyAPI dps: { '18': 152, '19': 340, '20': 1900 },
TuyAPI cid: 'a4c1385b3a746a37',
TuyAPI type: 'query',
TuyAPI t: 1747489525
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 8,
TuyAPI sequenceN: 62683
TuyAPI } +1ms
TuyAPI Received DP_REFRESH packet. +0ms

Well, I guess if it's a difficult one, probably it's best to stick to the WiFi smart plugs and avoid ZigBee ones. Thanks for your help though.

@Apollon77
Copy link
Collaborator

thinkthe only way is to use Wireshark to sniff the localapp traffic to see what the app sends ... but because it is encrypted that might also be meehhh

@serseb
Copy link
Author

serseb commented May 20, 2025

I would have to sniff the traffic between the app and the gateway. Not sure that's even possible.

@Apollon77
Copy link
Collaborator

At least for iOS there are ways to get the "network" mapped to a localinterface and so see what happens... but yes not easy

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

No branches or pull requests

2 participants