Skip to content

refactor: code quality, logging and reliability improvements#15

Merged
Kannix2005 merged 1 commit into
mainfrom
cleanup
May 11, 2026
Merged

refactor: code quality, logging and reliability improvements#15
Kannix2005 merged 1 commit into
mainfrom
cleanup

Conversation

@Kannix2005
Copy link
Copy Markdown
Owner

Critical fixes:

  • Replace bare except clauses with specific exceptions throughout
  • Fix hass.bus.fire() called from FCM thread → call_soon_threadsafe + async_fire
  • Guard e.response None-check before accessing .status_code in all HTTP methods
  • Save FCM credentials with 0o600 permissions instead of world-readable defaults

Logging cleanup:

  • Standardise all _LOGGER calls to %-style format (no f-strings)
  • Demote verbose SIP connect/register steps from INFO to DEBUG
  • Demote FCM registration details, listener lifecycle, MQTT messages to DEBUG
  • Remove traceback duplication (use _LOGGER.exception instead of error+format_exc)
  • Mask FCM tokens in log output

Architecture:

  • SiedleDataUpdateCoordinator now holds direct ConfigEntry reference; removes O(n) loop over hass.data to find its own entry on every coordinator update
  • binary_sensor.py: replace hardcoded "Siedle Türstation" device name with endpoint_id-based name, matching sensor.py convention
  • Add SIEDLE_DATA_DIR and TASK_NAME_FCM_SETUP constants to replace magic strings

Reliability:

  • MQTT connect_mqtt() retries up to 3 times with exponential backoff (1s, 2s) and enables paho auto-reconnect (1–30s) for post-connect drops

Critical fixes:
- Replace bare except clauses with specific exceptions throughout
- Fix hass.bus.fire() called from FCM thread → call_soon_threadsafe + async_fire
- Guard e.response None-check before accessing .status_code in all HTTP methods
- Save FCM credentials with 0o600 permissions instead of world-readable defaults

Logging cleanup:
- Standardise all _LOGGER calls to %-style format (no f-strings)
- Demote verbose SIP connect/register steps from INFO to DEBUG
- Demote FCM registration details, listener lifecycle, MQTT messages to DEBUG
- Remove traceback duplication (use _LOGGER.exception instead of error+format_exc)
- Mask FCM tokens in log output

Architecture:
- SiedleDataUpdateCoordinator now holds direct ConfigEntry reference; removes
  O(n) loop over hass.data to find its own entry on every coordinator update
- binary_sensor.py: replace hardcoded "Siedle Türstation" device name with
  endpoint_id-based name, matching sensor.py convention
- Add SIEDLE_DATA_DIR and TASK_NAME_FCM_SETUP constants to replace magic strings

Reliability:
- MQTT connect_mqtt() retries up to 3 times with exponential backoff (1s, 2s)
  and enables paho auto-reconnect (1–30s) for post-connect drops

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Kannix2005 Kannix2005 merged commit 960dda1 into main May 11, 2026
2 checks 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