Conversation
The CatLink API returns these two keys *present but null* on some models.
`dict.get(key, default)` only falls back when the key is absent, so the
defaults never fire and both properties raise on every read:
Got litter weight failed: unsupported operand type(s) for -: 'NoneType' and 'float'
Get deodorant countdown failed: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Because these are @Property getters whose exception is caught and logged at
ERROR, the message is emitted every time Home Assistant reads the property,
not once per poll. On a 7-device account with the default 1-minute
SCAN_INTERVAL that measured ~17 lines/minute, about 24,000 lines a day, which
is enough to push everything else out of the log buffer.
Guard both values explicitly rather than relying on a dict.get() default.
`empty_litter_box_weight` is always a float (`additional_config.empty_weight
or 0.0`), so it remains a safe substitute, and an explicit None check keeps a
legitimate 0 reading intact where `or` would discard it.
Fixes hasscc#63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #63.
The bug
The CatLink API returns
catLitterWeightanddeodorantCountdownpresent but null on some models.dict.get(key, default)only falls back when the key is absent, so the defaults never fire and both properties raise on every read:devices/litter_device.py:Why it floods the log
Both are
@propertygetters whose exception is caught and logged atERROR, so the message is emitted every time Home Assistant reads the property, not once per poll cycle.Measured on a 7-device account (2 litter boxes + 5 cat profiles, 156 entities) with the default
SCAN_INTERVALof 1 minute: ~17 lines/minute, roughly 24,000 a day. On that instance it was ~60% of all Home Assistant log output and shortened the readable log buffer to under an hour, which makes the log useless for anything else.Worth noting:
_LOGGERis defined inconst.pyand imported by 18 modules, so everything the integration logs appears undercustom_components.catlink.const. That means there is no way for a user to silence just these two messages with alogger:rule without silencing the whole integration, including genuine auth and API failures.The change
Guard both values explicitly instead of relying on a
dict.get()default.empty_litter_box_weightis always a float (additional_config.empty_weight or 0.0), so it stays a safe substitute for a missing weight.is Nonecheck rather thanorkeeps a legitimate0reading intact — withor, a genuine zero weight would be silently replaced by the empty-box weight.The existing
_LOGGER.debugguards for the "value is 0" case are untouched; they were previously unreachable in the null case because the exception was raised first.Testing
Applied to a live 2.1.1-beta install with two Open-X boxes (MODEL_00 and MODEL_01) that were producing both errors continuously. Both messages stop;
litter_weightreports0.0anddeodorant_countdownreports0for the null fields rather than raising, which matches the intended fallbacks.Not covered here
The same issue report also mentions
Got device logs for <device> failed: {...'scooperLogTop5': []...}. That is a separate warning about an unexpected response shape and is left alone to keep this change minimal.