customReadResponse not triggered when reading "genTime" cluster during interview phase
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
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.
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.
The device can only successfully complete the time synchronization after the interview is finished, when it performs a second read genTime operation.
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.
, 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.
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.
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ļ¼