Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions custom_components/catlink/devices/litter_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ def litter_weight(self) -> float:
"""Return the litter weight."""
litter_weight = 0.0
try:
cat_litter_weight = self.detail.get(
"catLitterWeight", self.empty_litter_box_weight
)
cat_litter_weight = self.detail.get("catLitterWeight")
if cat_litter_weight is None:
# The API sends the key with a null value on some models, so the
# dict.get() default never fires - guard explicitly.
cat_litter_weight = self.empty_litter_box_weight
litter_weight = cat_litter_weight - self.empty_litter_box_weight
self._litter_weight_during_day.append(litter_weight)
if litter_weight == 0.0:
Expand Down Expand Up @@ -105,7 +107,9 @@ def manual_clean_time(self) -> int:
def deodorant_countdown(self) -> int:
"""Return the deodorant countdown."""
try:
return int(self.detail.get("deodorantCountdown", 0))
raw = self.detail.get("deodorantCountdown")
# Same here: the key is present but null, so the default is skipped.
return int(raw) if raw is not None else 0
except Exception as exc:
_LOGGER.error("Get deodorant countdown failed: %s", exc)
return 0
Expand Down