Skip to content

Commit

Permalink
Use 'unicode_escape' encoding to convert bytes to string (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd authored Nov 6, 2023
1 parent 00f98e1 commit e320f98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/zha_toolkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def dict_to_jsonable(src_dict):
value = value.serialize()
if isinstance(value, bytes):
# "bytes" is not compatible with json, get a "string"
value = str(value, encoding="ascii")
value = str(value, encoding="unicode_escape")
else:
# Anything else: get a textual representation
value = repr(value)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/zha_toolkit/zcl_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def my_read_reporting_configuration_multiple(
record.direction = direction
# LOGGER.warning(f"Record {record.direction} {record.attrid}")
cfg.append(record)
LOGGER.warning("Read reporting with %s %r", cfg, kwargs)
LOGGER.debug("Read reporting with %s %r", cfg, kwargs)
param = t.List[f.ReadReportingConfigRecord](cfg)
LOGGER.debug("Resolves to %s", param)

Expand All @@ -88,9 +88,9 @@ async def my_read_reporting_configuration_multiple(
)

try:
LOGGER.warning("Read reporting with %s result %s", cfg, res)
LOGGER.debug("Read reporting with %s result %s", cfg, res)
except Exception as e:
LOGGER.debug("Error when reporting result of Read Report %r", e)
LOGGER.warning("Error when reporting result of Read Report %r", e)

# Parse configure reporting result for unsupported attributes
records = res[0]
Expand Down

0 comments on commit e320f98

Please sign in to comment.