zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

customReadResponse not triggered when reading "genTime" cluster during interview phase

Open CubeZ2mDeveloper opened this issue 1 year ago • 5 comments

What happened?

I’m currently working with a Sonoff SWV smart water valve. In its definition, I implemented a custom customReadResponse method to handle time synchronization (including daylight saving time support). The implementation is similar to the customTimeResponse function in ZHC’s modernExtend.ts.

However, I found that when the device joins Zigbee2MQTT for the first time, my custom customReadResponse logic is not triggered, resulting in a time synchronization failure and causing the device to malfunction. To resolve this, I have to either power-cycle the SWV manually or wait about 45 minutes until the device automatically performs a second read genTime operation, after which the time synchronization completes successfully.

What did you expect to happen?

I hope the device can successfully synchronize its time upon the first join to Zigbee2MQTT,

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

2.4.0

Adapter firmware version

6.10.3

Adapter

ezsp

Setup

windows

Device database.db entry

No response

Debug log

No response

Notes

No response

CubeZ2mDeveloper avatar Nov 11 '25 09:11 CubeZ2mDeveloper

After investigation, I found that the issue occurs during the interview stage. Since Zigbee2MQTT only loads the corresponding Definition after the interview is completed, the SWV device sends a read genTime request while the interview is still in progress.

Image

At that moment, the Definition has not yet been loaded, so the device’s customReadResponse is still undefined. As a result, the program falls back to the default read response genTime logic, causing the initial time synchronization to fail.

Image

The device can only successfully complete the time synchronization after the interview is finished, when it performs a second read genTime operation.

CubeZ2mDeveloper avatar Nov 11 '25 09:11 CubeZ2mDeveloper

Currently, my solution is to remove the restriction that the Definition is only loaded after the interview is completed, and it has passed my local tests. However, I don’t consider this an elegant approach, and I hope to find a more proper and refined solution.

Image

CubeZ2mDeveloper avatar Nov 11 '25 09:11 CubeZ2mDeveloper

, I don’t consider this an elegant approach

I agree with that, can't we force sync the time inside the configure? This is called right after the interview finishes.

Koenkk avatar Nov 12 '25 19:11 Koenkk

I don’t think it’s possible, because the time synchronization is initiated by the device itself through a read genTime request. Once the initial synchronization is completed, the time will only be synchronized again if the device is power-cycled (which triggers another read genTime), or when the device performs its next automatic polling. The gateway cannot force the device to initiate a read genTime operation.

CubeZ2mDeveloper avatar Nov 13 '25 02:11 CubeZ2mDeveloper

Hi, I think I’ve already found a solution! I can handle devices that are not fully paired yet inside the generic onEvent method, and define customReadResponse there. Thanks!

CubeZ2mDeveloper avatar Dec 01 '25 08:12 CubeZ2mDeveloper