Skip to content

fix: preserve measured numbers in display gauge labels - #26

Merged
flowcool merged 1 commit into
upstream/staging-v2r1from
upstream/raw-gauge-labels
Oct 20, 2026
Merged

flowcool merged 1 commit into
upstream/staging-v2r1from
upstream/raw-gauge-labels

Conversation

@flowcool

@flowcool flowcool commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Behavior

Port fork PR #11. Out-of-range readings retain their measured numeric labels; only the needle clamps to the existing scale. Keep staging artwork, scale defaults and entity naming.

Target: flowcool/Smart_Plant:upstream/staging-v2r1. Source c3229d0, predecessor ad385e9. Open after the preceding contribution merges so this PR contains only its owned change. The upstream baseline is bcf373144b2d5c7e3a712fd02698e2e98e45aeed. No PR to JGAguado is authorized.

Verification

Three tests compile and execute the actual C++ renderer for out-of-range, exact endpoint and missing/nonfinite inputs. Both exact-source firmware builds are recorded in the delivery note.

Inspect the semantic diff and git -c core.whitespace=cr-at-eol diff --check; preserve existing line endings. All tracked YAML parses. Firmware fixtures use local fonts/public images and synthetic credentials, never devices or shared builders. Local compilation does not prove deployment.

Rollback: revert this isolated PR on staging. No automatic deployment, fleet/NAS/cache purge/MQTT/HA action.

Exact-source isolated ESPHome 2026.9.0 builds: api 0x9fecf2a7, mqtt 0x8e41153f.

AI assistance

Codex prepared the port or extraction. The author inspected the behavior, contribution boundary, actual-source tests, compatibility and diff. Existing staging OTA confirmation and native shutdown remain intact.

CodeRabbit review

Require current-head completed review and yaml-syntax before merge. Florent approved one manual review request per ignored PR for this series only. Documentation-only PRs use the standing docs gate. Record review/head/checks/merge in owner infra-3rr.66.

Summary by CodeRabbit

  • Améliorations

    • Les jauges affichent désormais les valeurs mesurées originales, même lorsqu’elles sont hors de la plage définie.
    • La position de l’aiguille reste limitée aux bornes configurées pour garantir un affichage cohérent.
    • Les valeurs invalides ou indisponibles affichent « -- » sans aiguille.
  • Tests

    • Ajout de tests couvrant le formatage, les limites, les valeurs hors plage et les états invalides.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c4357503-8c38-4133-82c6-3a8ddba48c27
📥 Commits

Reviewing files that changed from the base of the PR and between f057866 and c3229d0.

📒 Files selected for processing: 2
  • examples/multi-device/packages/smart_plant_core.yaml
  • tests/test_display_gauge.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📜 Recent review details
🧰 Additional context used
📚 Code guidelines: 2
.claude/rules/esphome-yaml.md — auto-discovered
AGENTS.md — auto-discovered
📓 Path-based instructions: 2
Source excerpt: `use_address` must be in the `wifi:` block of the device YAML, not only in `substitutions:` — the ESPHome CLI reads YAML without resolving packages.

📄 CodeRabbit inference engine (.claude/rules/esphome-yaml.md)

Files:

  • examples/multi-device/packages/smart_plant_core.yaml
Source excerpt: Parse changed YAML and run `git diff --check`; inspect both `git diff --numstat` and the semantic diff before committing.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • examples/multi-device/packages/smart_plant_core.yaml
🪛 ast-grep (0.45.3)
tests/test_display_gauge.py

[error] 88-92: Command coming from incoming request
Context: subprocess.run(
[compiler, "-std=c++17", "-Wall", "-Wextra", str(cpp),
"-o", str(cls.executable)],
check=True, capture_output=True, text=True,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)

[error] 95-99: Command coming from incoming request
Context: subprocess.run(
[str(self.executable), str(value), "1" if has_state else "0",
str(minimum), str(maximum), fmt, *map(str, position)],
check=True, capture_output=True, text=True,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)

🪛 Ruff (0.16.9)
tests/test_display_gauge.py

[error] 88-88: subprocess call: check for execution of untrusted input

(S603)

[error] 95-95: subprocess call: check for execution of untrusted input

(S603)

🔇 Additional comments: 2
tests/test_display_gauge.py: 1

1-142: Test à vérifier : la limite de Display::printf et l'extraction par index.

Le test extrait la lambda de production par recherche de chaînes (" float pi =", " };"). Si l'indentation du YAML change, source.index lève une ValueError. L'échec reste visible, donc il n'est pas silencieux. Les alertes de sous-processus (S603, CWE-78) sont des faux positifs. Les arguments sont des constantes du test et subprocess.run n'utilise pas de shell.

Le code est correct pour le comportement modifié. Aucun changement n'est requis.

examples/multi-device/packages/smart_plant_core.yaml: 1

331-335: LGTM!

Walkthrough

La jauge conserve la valeur mesurée pour l’affichage et borne une copie pour calculer la position de l’aiguille. De nouveaux tests compilent la lambda de production et vérifient les valeurs affichées, les limites de l’aiguille et les entrées invalides.

Changes

Affichage des jauges

Layer / File(s) Summary
Valeur affichée et position de l’aiguille
examples/multi-device/packages/smart_plant_core.yaml
draw_gauge borne une copie de la valeur pour calculer l’aiguille. La valeur mesurée reste inchangée pour l’affichage.
Tests du rendu de la jauge
tests/test_display_gauge.py
La suite extrait et compile la lambda de production avec g++. Elle vérifie les formats affichés, les positions aux limites et les cas sans état ou avec des valeurs non finies.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c3229

Gauge labels now show the measured value, and only the needle position is clamped. No merge-blocking issue was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed Le titre décrit clairement la modification principale : conserver les valeurs mesurées dans les libellés de la jauge.
Description check Passed La description couvre le comportement, la vérification, l’assistance IA et les conditions de revue. Elle reste ciblée et fournit le contexte technique, les tests, les builds et le plan de retour arriè…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

La description couvre le comportement, la vérification, l’assistance IA et les conditions de revue. Elle reste ciblée et fournit le contexte technique, les tests, les builds et le plan de retour arrière. Les champs Command, Expected result et Observed result ne sont pas renseignés sous forme explicite, mais l’information de vérification est suffisamment détaillée.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Un lapin observe l’aiguille tourner,
La valeur brute reste affichée.
Aux limites, l’aiguille sait s’arrêter,
Les tests veillent sur chaque tracé.
Le jardin peut continuer à pousser.

Comment @coderabbitai help to get the list of available commands.

@flowcool

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@flowcool
flowcool merged commit 99ab638 into upstream/staging-v2r1 Oct 20, 2026
2 checks passed
@flowcool
flowcool deleted the upstream/raw-gauge-labels branch October 20, 2026 19:33
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