Skip to content

Commit 9976fcd

Browse files
author
NOisi-X
committed
fix(zeo): address review — narrow exceptions, tighten try/except scope, document _dps_cache
except Exception → except RoborockException (aligns with Bundle's silent fallback to 0) try/except only wraps decode_rpc_response — cache updates and notify must propagate query_values docstring explains cache population and consumer semantics
1 parent d57b81e commit 9976fcd

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

roborock/devices/traits/a01/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,16 @@ async def _discover_features(self) -> None:
209209
start pushing its full state — equivalent to how V1's
210210
``discover_features()`` uses ``device_features.refresh()`` to
211211
initiate the push cycle.
212+
213+
Only devices that support the FeatureBits DP will respond;
214+
older or unsupported devices return nothing.
215+
A failed query defaults to 0 — all feature-gated DPs are
216+
disabled and the device operates in basic mode.
212217
"""
213218
try:
214219
result = await self.query_values([RoborockZeoProtocol.FEATURE_BITS])
215220
self._feature_bits = result.get(RoborockZeoProtocol.FEATURE_BITS, 0)
216-
except Exception:
221+
except RoborockException:
217222
self._feature_bits = 0
218223

219224
def supports(self, feature: ZeoFeatureBits) -> bool:
@@ -232,10 +237,11 @@ def _on_dps_message(self, message: RoborockMessage) -> None:
232237
return
233238
try:
234239
decoded = decode_rpc_response(message)
235-
self._dps_cache.update(decoded)
236-
self._notify_update()
237240
except RoborockException:
238-
_LOGGER.debug("Failed to decode push message, skipping: %s", message, exc_info=True)
241+
_LOGGER.debug("Dropped malformed push message", exc_info=True)
242+
return
243+
self._dps_cache.update(decoded)
244+
self._notify_update()
239245

240246
async def query_values(self, protocols: list[RoborockZeoProtocol]) -> dict[RoborockZeoProtocol, Any]:
241247
"""Query the device for the values of the given protocols."""

0 commit comments

Comments
 (0)