Skip to content

Fix kasa exporter - #5

Merged
mvadu merged 5 commits into
mainfrom
fix_kasa_exporter
Aug 10, 2026
Merged

mvadu merged 5 commits into
mainfrom
fix_kasa_exporter

Conversation

@mvadu

@mvadu mvadu commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Changes

Bug Fixes

  • Docker timezone crash fix - Kasa devices report POSIX timezone strings (e.g., PST8PDT) that Python's zoneinfo cannot resolve when tzdata is incomplete in Docker containers, causing ZoneInfoNotFoundError crashes. Added _patch_timezone_lookup() to gracefully fall back to UTC with debug logging. Installed tzdata package in the Docker image.

Code Quality

  • Renamed kasa-exporter.py to kasa_exporter.py - Proper Python snake_case naming convention compliance.
  • Refactored _poll_device_once() - Extracted outlet processing into a dedicated _process_outlet() helper, reducing local variable count from 16 to under pylint's threshold.
  • Renamed device_cfg to dev_config in poll_device() - Eliminates variable shadowing of the module-level config reference (redefined-outer-name).
  • Added .pylintrc - Documents and suppresses only intentionally-accepted warnings (broad exception catches for device I/O resilience, protected access for kasa internals patching, lazy imports).

New Features

  • Per-poll health logging - Added INFO-level log on successful poll and DEBUG-level log before each connection attempt, enabling visibility into exporter liveness via Docker logs.

mvadu added 5 commits August 9, 2026 13:39
Add `tzdata` package to Docker dependencies and implement a timezone
compatibility fix for Kasa devices that report POSIX timezone strings
(e.g., PST8PDT). Python's zoneinfo fails when tzdata is incomplete in
Docker environments, causing ZoneInfoNotFoundError exceptions. The new
`_patch_timezone_lookup()` function wraps kasa's CachedZoneInfo to
gracefully fall back to UTC when a timezone cannot be resolved, with
appropriate debug logging for visibility.
@mvadu
mvadu merged commit 7745b58 into main Aug 10, 2026
1 check passed
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.

1 participant