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

Tuya JM-TRH-ZGB-V1 clock error #18002

Closed
z-x-f opened this issue Jun 12, 2023 · 14 comments
Closed

Tuya JM-TRH-ZGB-V1 clock error #18002

z-x-f opened this issue Jun 12, 2023 · 14 comments
Labels
problem Something isn't working

Comments

@z-x-f
Copy link
Contributor

z-x-f commented Jun 12, 2023

What happened?

Since the update of (ddcab82), my tuya jm-trh-zgb-v1 has a clock error. Please help me to find out where the problem is.

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.31.2-dev commit: 0dd8996

Adapter firmware version

20230410

Adapter

zigstar

Debug log

No response

@z-x-f z-x-f added the problem Something isn't working label Jun 12, 2023
@b2un0
Copy link

b2un0 commented Jun 12, 2023

i have the same issue with this two devices:
M-TRH-ZGB-V1
SZ-T04

@Koenkk
Copy link
Owner

Koenkk commented Jun 12, 2023

@z-x-f does it still work in z2m 1.31.0?

@z-x-f
Copy link
Contributor Author

z-x-f commented Jun 12, 2023

1.31.0 commit: f440c860, have the same problem.
Sorry, the test was not re-added just now, resulting in a test error. Retested, 1.31.0 works fine.

@z-x-f
Copy link
Contributor Author

z-x-f commented Jun 12, 2023

21f5125 works normally, but 7df6b2b is abnormal again.

@z-x-f
Copy link
Contributor Author

z-x-f commented Jun 16, 2023

DataConfirmError: Command 0xa4c1383a1e6417c1/1 manuSpecificTuya.mcuSyncTime({"payloadSize":8,"payload":[100,null,140,236,100,null,140,108]}, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":false,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Data request failed with error: 'No network route' (205))
    at ZStackAdapter.sendZclFrameToEndpointInternal (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/src/adapter/z-stack/adapter/zStackAdapter.ts:415:23)
    at Queue.executeNext (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/src/utils/queue.ts:32:32) {
  code: 205 

Is this error unrelated to the problem?

@Koenkk
Copy link
Owner

Koenkk commented Jun 17, 2023

It is, this is the time sync command. It seems for some reason the device is not reachable, did you already try to re-pair it?

@b2un0
Copy link

b2un0 commented Jun 17, 2023

I tried to repair the affected devices, it does not help.

@z-x-f
Copy link
Contributor Author

z-x-f commented Jun 19, 2023

When the time synchronization is wrong, I found that there is null in the payload, I'm not sure why it is like this?

This is the normal log when the time is synchronized:

  Zigbee2MQTT:debug 2023-06-19 21:06:00: Received Zigbee message from '0xa4c1386584b6bf43', type 'commandMcuSyncTime', cluster 'manuSpecificTuya', data '{"payloadSize":117}' from endpoint 1 with groupID 0
  zigbee-herdsman:controller:endpoint Command 0xa4c1386584b6bf43/1 manuSpecificTuya.mcuSyncTime({"payloadSize":8,"payload":[100,144,82,184,100,144,195,56]}, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":false,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) +131ms
  zigbee-herdsman:controller:endpoint DefaultResponse 0xa4c1386584b6bf43/1 61184(36, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":1,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) +0ms

This is the log when the time synchronization is not normal:

Zigbee2MQTT:debug 2023-06-19 21:01:09: Received Zigbee message from '0xa4c1386584b6bf43', type 'commandMcuSyncTime', cluster 'manuSpecificTuya', data '{"payloadSize":75}' from endpoint 1 with groupID 0
  zigbee-herdsman:controller:endpoint Command 0xa4c1386584b6bf43/1 manuSpecificTuya.mcuSyncTime({"payloadSize":8,"payload":[100,null,144,149,100,null,144,21]}, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":false,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) +129ms
  zigbee-herdsman:controller:endpoint DefaultResponse 0xa4c1386584b6bf43/1 61184(36, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":1,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) +0ms
utcTime:1687183379
localTime:1687212179

{
  payloadSize: 8,
  payload: [
    100, NaN, 144,
     19, 100, NaN,
    144, 147
  ]
}

@z-x-f
Copy link
Contributor Author

z-x-f commented Jun 19, 2023

I modified convertDecimalValueTo4ByteHexArray as follows, which temporarily solved the problem. Is this modification feasible?

function convertDecimalValueTo4ByteHexArray(value) {
    const hexValue = Number(value).toString(16).padStart(8, '0');
    const chunk1 = parseInt(hexValue.substring(0, 2), 16);
    const chunk2 = parseInt(hexValue.substring(2, 4), 16);
    const chunk3 = parseInt(hexValue.substring(4, 6), 16);
    const chunk4 = parseInt(hexValue.substring(6), 16);
    return [chunk1, chunk2, chunk3, chunk4];
}
=============
utcTime: 1687191707
localTime: 1687220507
=============
{
  payloadSize: 8,
  payload: [
    100, 144, 128,
    155, 100, 144,
    241,  27
  ]
}

@Koenkk
Copy link
Owner

Koenkk commented Jun 19, 2023

Yes, but I don't know what the diff with existing code is. Does the following also work?

function convertDecimalValueTo4ByteHexArray(value) {
    const hexValue = Number(value).toString(16).padStart(8, '0');
    const chunk1 = hexValue.substring(0, 2);
    const chunk2 = hexValue.substring(2, 4);
    const chunk3 = hexValue.substring(4, 6);
    const chunk4 = hexValue.substring(6);
    return [chunk1, chunk2, chunk3, chunk4].map((hexVal) => parseInt(hexVal, 16));
}

@z-x-f
Copy link
Contributor Author

z-x-f commented Jun 20, 2023

This is also working fine.

function convertDecimalValueTo4ByteHexArray(value) {
    const hexValue = Number(value).toString(16).padStart(8, '0');
    const chunk1 = hexValue.substring(0, 2);
    const chunk2 = hexValue.substring(2, 4);
    const chunk3 = hexValue.substring(4, 6);
    const chunk4 = hexValue.substring(6);
    return [chunk1, chunk2, chunk3, chunk4].map((hexVal) => parseInt(hexVal, 16));
}

=============
utcTime: 1687228201
localTime: 1687257001
=============
{
  payloadSize: 8,
  payload: [
    100, 145,  15,  41,
    100, 145, 127, 169
  ]
}

By the way, test the original again, there is still an error.

=============
utcTime: 1687228553
localTime: 1687257353
=============
{
  payloadSize: 8,
  payload: [
    100, NaN, 145, 137,
    100, NaN, 145,   9
  ]
}

It seems to be caused by different substring(startIndex, endIndex) substr(startIndex, length)methods.

@Koenkk
Copy link
Owner

Koenkk commented Jun 20, 2023

Thanks, pushed the fix!

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

@b2un0
Copy link

b2un0 commented Jun 21, 2023

i have the same issue with this two devices: M-TRH-ZGB-V1 SZ-T04

can confirm, both devices works again. 🎉
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants