zigpy / zigpy-deconz

A library which communicates with Deconz radios for zigpy
GNU General Public License v3.0
86 stars 20 forks source link

Register the command response listener before writing to the UART #248

Closed puddly closed 7 months ago

puddly commented 7 months ago

See https://github.com/home-assistant/core/issues/109931.

More precisely:

2024-02-08 00:17:53.874 DEBUG (MainThread) [zigpy.application] Feeding watchdog
2024-02-08 00:17:53.874 DEBUG (MainThread) [zigpy_deconz.api] Sending CommandId.write_parameter{'parameter_id': <NetworkParameter.watchdog_ttl: 38>, 'parameter': b'<\x00\x00\x00'} (seq=98)
2024-02-08 00:17:53.874 DEBUG (MainThread) [zigpy_deconz.uart] Send: 0b62000c000500263c000000
2024-02-08 00:17:53.876 DEBUG (MainThread) [zigpy_deconz.uart] Frame received: 0x0b62000800010026
2024-02-08 00:17:53.876 DEBUG (MainThread) [zigpy_deconz.api] Received command CommandId.write_parameter{'status': <Status.SUCCESS: 0>, 'frame_length': 8, 'payload_length': 1, 'parameter_id': <NetworkParameter.watchdog_ttl: 38>} (seq 98)
2024-02-08 00:17:55.675 DEBUG (MainThread) [zigpy_deconz.api] No response to 'CommandId.write_parameter' command with seq 98

It appears that we can write to the serial port and receive a response before the listener is registered a few lines down.

This is a bug probably exposed by us switching to pyserial-asyncio-fast.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (df9c0c6) 98.69% compared to head (b29cb4f) 98.81%. Report is 2 commits behind head on dev.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #248 +/- ## ========================================== + Coverage 98.69% 98.81% +0.11% ========================================== Files 7 7 Lines 920 925 +5 ========================================== + Hits 908 914 +6 + Misses 12 11 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.