Add OTA last query cmd to diagnostics#727
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #727 +/- ##
=======================================
Coverage 97.63% 97.63%
=======================================
Files 62 62
Lines 10814 10814
=======================================
Hits 10558 10558
Misses 256 256 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds OTA cluster “last cached query” details to the ZHA device diagnostics JSON so diagnostics can reveal a device’s OTA image_type (and related fields) when available.
Changes:
- Extend
Device.get_diagnostics_json()to includelast_query_cmdfor OTA out clusters when present. - Add tests verifying diagnostics includes
last_query_cmdfor OTA clusters and omits it when unset.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
zha/zigbee/device.py |
Emits OTA last_query_cmd details in per-endpoint out_clusters diagnostics output when cached. |
tests/test_discover.py |
Adds coverage for presence/absence of last_query_cmd in diagnostics for the OTA cluster. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if isinstance(cluster, Ota) | ||
| and getattr(cluster, "last_query_cmd", None) is not None | ||
| else {} |
There was a problem hiding this comment.
The getattr guard is for someone messing up a (quirked) OTA cluster badly, but I think we can just remove it. If someone manages this, congrats.
There was a problem hiding this comment.
Eh, actually. We need a is not None check anyway, so I guess we can just keep this. It's one line either way.
| ota_cluster = zigpy_device.endpoints[1].out_clusters[Ota.cluster_id] | ||
| ota_cluster.last_query_cmd = QueryNextImageCommand( | ||
| field_control=0, | ||
| manufacturer_code=0x117C, | ||
| image_type=0x1234, | ||
| current_file_version=0x00AABBCC, | ||
| ) |
There was a problem hiding this comment.
Side note: In the future, we may wanna consider if we can also restore from diagnostics files to our device object generated from it, so the last_query_cmd is available on it then.
Proposed change
This adds the last cached OTA query command to JSON diagnostics, so we know the
image_typeof a device.