Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Nov 6, 2022
1 parent e92b57b commit 30bba85
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 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 @@ -108,7 +108,7 @@ def normalize_filename(filename: str) -> str:
Normalize filename so that slashes and other problematic
characters are replaced with hyphen
"""
result="".join([c if re.match(r"[\w.]", c) else "-" for c in filename])
result = "".join([c if re.match(r"[\w.]", c) else "-" for c in filename])
LOGGER.debug(f"Normalize {filename}->{result}")
return "".join([c if re.match(r"[\w.]", c) else "-" for c in filename])

Expand Down
43 changes: 25 additions & 18 deletions custom_components/zha_toolkit/zcl_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ async def my_read_reporting_configuration_multiple(

# Exception is propagated to caller if any
res = await self._read_reporting_configuration(
t.List[f.ReadReportingConfigRecord](cfg),
**kwargs
t.List[f.ReadReportingConfigRecord](cfg), **kwargs
)

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


# Parse configure reporting result for unsupported attributes
records = res[0]
Expand All @@ -101,16 +99,20 @@ async def my_read_reporting_configuration_multiple(
and not (len(records) == 1 and records[0].status == f.Status.SUCCESS)
and len(records) >= 0
):
try:
failed = [
r.attrid
for r in records
if r.status == f.Status.UNSUPPORTED_ATTRIBUTE
]
for attr in failed:
self.add_unsupported_attribute(attr)
except Exception as e:
LOGGER.error("Issue when reading ReadReportingConfig result %r", records)
try:
failed = [
r.attrid
for r in records
if r.status == f.Status.UNSUPPORTED_ATTRIBUTE
]
for attr in failed:
self.add_unsupported_attribute(attr)
except Exception as e:
LOGGER.error(
"Issue when reading ReadReportingConfig result %r : %r",
records,
e,
)
return res


Expand Down Expand Up @@ -147,7 +149,7 @@ async def conf_report_read(
0x08, # Command id
schema, # Schema
param,
manufacturer=params[p.MANF], # Added, not tested
manufacturer=params[p.MANF], # Added, not tested
expect_reply=True,
)

Expand Down Expand Up @@ -197,11 +199,16 @@ async def conf_report_read(
}
try:
r_conf["type"] = f"0x{rcfg.datatype:02X}"
r_conf["min_interval"] = rcfg.min_interval,
r_conf["max_interval"] = rcfg.max_interval,
#r_conf["reportable_change"] = rcfg.reportable_change,
r_conf["min_interval"] = (rcfg.min_interval,)
r_conf["max_interval"] = (rcfg.max_interval,)
# r_conf["reportable_change"] = rcfg.reportable_change,
except Exception as e: # nosec
LOGGER.error("Issue when reading AttributesReportingConfig result %r %r", rcfg, e)
LOGGER.error(
"Issue when reading AttributesReportingConfig"
" result %r %r",
rcfg,
e,
)
try:
# Try to add name of the attribute
attr_name = cluster.attributes.get(
Expand Down

0 comments on commit 30bba85

Please sign in to comment.