Skip to content

fix: guard present-but-null API fields; stop per-poll log spam (#63) - #70

Open
Sylph wants to merge 2 commits into
hasscc:mainfrom
Sylph:pr/null-guards
Open

Sylph wants to merge 2 commits into
hasscc:mainfrom
Sylph:pr/null-guards

Conversation

@Sylph

@Sylph Sylph commented Oct 20, 2026

Copy link
Copy Markdown

Fixes #63 (supersedes/extends #67)

Same root cause as PR #67: the CatLink API returns catLitterWeight / deodorantCountdown present but null on C08/SCOOPER models, and dict.get(key, default) only fires on missing keys — so int(None) / None - float raised every poll (~60s) and flooded the log. PR #67 fixes those two fields; this extends the identical pattern to the same class of crash in three more places I found in the file:

  • total_clean_time (int(inductionTimes) + int(manualTimes)) — same null-API exposure
  • manual_clean_time (get("manualTimes", 0) default skipped when value is null)
  • _base_state_attrs()["total_clean_times"] — now reuses the guarded property instead of duplicating the unsafe expression
  • empty-but-successful device-log responses logged as warning every poll → downgraded to debug (kept warning for real failures), including the duplicated block in scooper_pro_ultra.py

Tests

229 passed locally (Python 3.13).

Sylph added 2 commits October 20, 2026 14:25
The CatLink API returns catLitterWeight/deodorantCountdown/inductionTimes/
manualTimes present-but-null on some models (C08/SCOOPER especially).
dict.get(key, default) only fires on missing keys, so int(None)/None-minus-
float raised on every read (~every 60s poll) and empty successful log
responses were logged as warnings.

- guard all four fields explicitly (extends upstream PR hasscc#67 with the same
  pattern applied to the clean-time fields and state attrs)
- demote 'successful but empty device logs' from warning to debug
- regression tests for each null field + the log-warning behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unhandled NoneType exception every ~60s parsing deodorant countdown / device logs (SCOOPER C08, v2.1.1)

1 participant