Skip to content

Commit

Permalink
Add debug info regarding false read_after_write
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd authored and tomasbedrich committed Oct 19, 2023
1 parent 7e34ac1 commit 994a91f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions custom_components/zha_toolkit/zcl_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,20 @@ async def attr_write( # noqa: C901
f"Reading attr result (attrs, status): {result_read!r}"
)
# read_is_equal = (result_read[0][attr_id] == compare_val)
success = (
success
and (len(result_read[1]) == 0 and len(result_read[0]) == 1)
and (result_read[0][attr_id] == compare_val)
success = success and (
len(result_read[1]) == 0 and len(result_read[0]) == 1
)
if success and compare_val is not None:
if result_read[0][attr_id] != compare_val:
success = False
msg = "Read does not match expected: {!r} <> {!r}".format(
result_read[0][attr_id].serialize(),
compare_val.serialize(),
)
LOGGER.warning(msg)
if "warnings" not in event_data:
event_data["warnings"] = []
event_data["warnings"].append(msg)

if result_read is not None:
event_data["result_read"] = result_read
Expand Down

0 comments on commit 994a91f

Please sign in to comment.