Skip to content

fix(ha): bound persisted sensor states to column width - #174

Merged
ichwars merged 2 commits into
mainfrom
dev-issue-143-ha-sensor-state-width
Sep 8, 2026
Merged

fix(ha): bound persisted sensor states to column width#174
ichwars merged 2 commits into
mainfrom
dev-issue-143-ha-sensor-state-width

Conversation

@ichwars

@ichwars ichwars commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Description

Prevent oversized Home Assistant states from aborting a PostgreSQL sensor polling batch.

Related Issue

Closes #143

Changes Made

  • Share the existing 64-character column limit between the model and persistence code.
  • Truncate only persisted state in both batch polling and single-sensor refresh; compare bounded values after a cold start and prior raw readings when available so last_changed tracks real changes without churning.
  • Preserve full readings for evaluation/cache and retain existing fail-open/fail-closed, freshness, notification and audited override semantics.
  • Add regression coverage for long text, invalid numeric states, long valid numeric evaluation and unaffected peer sensors. Run the database regression against SQLite and the existing live PostgreSQL 16 CI service.

Documentation

  • No docs update required — internal persistence bug fix; no new configuration, schema migration or public API. Optional storage-location sensors remain outside scope.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Test addition or update

Testing

  • Focused HA manager, scheduler interlock and API/database tests: 73 passed, 1 skipped locally (live PostgreSQL requires CI service).
  • Backend Ruff lint and format checks.
  • Repository source size budget (1,774 files), dependency boundaries, diff whitespace and PrintOps domain guard.
  • Live PostgreSQL 16 CI on 2a447f954: migration test and both SQLite/PostgreSQL sensor regressions passed, with no skips.
  • Full local backend regression on 2a447f954: 8,630 passed, 255 skipped, 5 warnings in 428.92s (pytest backend/tests/ -q --tb=short -n 4).
  • All 24 jobs across CI, Security Audit and CodeQL passed on 2a447f954.
  • Final production-container integration suite: 2,950 passed, 171 skipped, 4 warnings in 805.04s. Container health/API/static delivery and non-root/capability checks passed.
  • Review finding reproduced, fixed and resolved; four added transition regressions cover both persistence paths.

Additional Notes

Selective adaptation of the state-width fix referenced by maziggy/bambuddy@54af3146a; no bulk upstream import. Existing user changes in static/ are excluded.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00f4cebc1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/app/services/ha_sensor_manager.py Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T08:19:43.510069Z 00f4ceb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ichwars
ichwars merged commit dd46302 into main Sep 8, 2026
31 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.

HA-Sensorpolling gegen überlange Zustände und ausgefallene Schreibvorgänge absichern

1 participant