Skip to content

feat: expose filtered soil voltage for calibration - #27

Merged
flowcool merged 1 commit into
upstream/staging-v2r1from
upstream/soil-voltage-diagnostic
Oct 20, 2026
Merged

flowcool merged 1 commit into
upstream/staging-v2r1from
upstream/soil-voltage-diagnostic

Conversation

@flowcool

@flowcool flowcool commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Behavior

Extract the generic diagnostic from fork PR #7. One ADC median/plausibility pipeline publishes Soil Voltage; a copy sensor derives Soil Moisture. Keep upstream 1.25 V / 2.8 V calibration, five samples, 3-second spacing, existing moisture name/id and retained conventions.

Target: flowcool/Smart_Plant:upstream/staging-v2r1. Source c16403e, predecessor c3229d0. 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 execute exact pinned ESPHome 2026.9.0 median scheduling/computation, voltage rejection and calibration with the real YAML settings. They cover single fifth-sample publication, spikes, invalid windows and unchanged calibration/cadence. Integrated actual-YAML mode regressions pass. 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 0x878c9917, mqtt 0x9f000cd0.

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.67.

Summary by CodeRabbit

  • Nouvelles fonctionnalités

    • Le capteur de sol publie désormais une tension diagnostique en volts, avec trois décimales.
    • L’humidité du sol est calculée automatiquement à partir de cette tension filtrée, calibrée et limitée entre 0 et 100 %.
    • La détection des valeurs aberrantes et la cadence de mesure sont conservées.
  • Tests

    • Ajout de tests couvrant le filtrage, la calibration, la conversion en pourcentage et la cadence de publication.

@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: 1744af98-1aba-4713-bdf6-69729831dcf2
📥 Commits

Reviewing files that changed from the base of the PR and between 99ab638 and c16403e.

📒 Files selected for processing: 4
  • examples/multi-device/packages/smart_plant_core.yaml
  • tests/display_automation.py
  • tests/test_maintenance_storage.py
  • tests/test_soil_voltage.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 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_soil_voltage.py

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

(subprocess-from-request)

[error] 121-121: Command coming from incoming request
Context: subprocess.run([str(self.executable), *map(str, values)], check=True, text=True, capture_output=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_soil_voltage.py

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

(S603)

[error] 116-116: Starting a process with a partial executable path

(S607)

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

(S603)

🔇 Additional comments: 4
examples/multi-device/packages/smart_plant_core.yaml: 1

251-257: LGTM!

Also applies to: 272-284, 439-439

tests/test_soil_voltage.py: 1

1-149: LGTM!

tests/display_automation.py: 1

113-113: LGTM!

tests/test_maintenance_storage.py: 1

198-198: LGTM!

Also applies to: 241-241, 276-276, 301-301, 333-333, 351-351, 362-362, 376-376

Walkthrough

Le capteur ADC publie désormais la tension du sol dans soil_voltage. Le capteur soil dérive l’humidité de cette tension filtrée et applique la calibration existante. Les tests valident le filtrage et la conversion, tandis que les scénarios de maintenance suivent les mises à jour de soil_voltage.

Changes

Acquisition et conversion du capteur de sol

Layer / File(s) Summary
Mesure de tension et dérivation de l’humidité
examples/multi-device/packages/smart_plant_core.yaml, tests/test_soil_voltage.py
Le capteur ADC publie soil_voltage en volts avec trois décimales. Le capteur soil dérive l’humidité de la tension filtrée, puis applique la calibration et les bornes existantes. Les tests valident les publications, le rejet des pics et des valeurs invalides, ainsi que la calibration et la cadence d’acquisition.
Adaptation des scénarios de maintenance
tests/display_automation.py, tests/test_maintenance_storage.py
L’état simulé inclut soil_voltage. Les tests de maintenance et de stockage comptent ses mises à jour et simulent une lecture de tension.

Priority: ⬇️ Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ADC
  participant soil_voltage
  participant soil
  ADC->>soil_voltage: Publie la tension filtrée
  soil_voltage->>soil: Transmet la tension
  soil->>soil: Applique la calibration et les bornes
Loading
Merge Risk: ⚪ Minimal · up to c1640

No actionable issue remains identified in the voltage and moisture acquisition change; it is mergeable after the required checks.

Security architecture risk: ⚪ Minimal · up to c1640

The change adds a filtered diagnostic reading without introducing a new control interface or expanding device privileges. The existing moisture identity, calibration, sampling cadence and bounded acquisition behavior are preserved. No material security risk introduced or worsened by this change was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The introduced exposure is one additional measurement on devices adopting the shared package and their existing telemetry consumers. The inspected change does not grant a new administrative operation or cross-device authority; the number and configuration of deployed devices are not established.

Security Findings and Attack Paths

  • inferred — The routed Python declarations do not create a production attack path. They load local package configuration and compile or execute local test code; production MQTT command handlers remain separate YAML actions. The soil test subprocess calls use argument arrays rather than shell command construction.

Trust Boundaries and Controls

  • observed — The analog-input plausibility boundary remains before moisture calibration: the filtered voltage must pass the existing 0.5–3.3 V rejection stage. The derived sensor consumes that same filtered publication rather than acquiring another unfiltered value.

Resilience and Maintainability Implications

  • inferred — No newly introduced failure-containment regression was identified in acquisition or maintenance/storage transitions. Acquisition retains bounded waits, and the existing transition paths stop pending work and route recovery back to normal acquisition or storage as appropriate. Physical timing remains outside the offline harness.
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 17 functions across 3 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 précisément la modification principale : l’exposition de la tension filtrée du sol pour la calibration. Il est court et clair.
Description check Passed La description contient les sections Behavior, Verification, AI assistance et CodeRabbit. Elle décrit le comportement, les tests, les limites, le rollback et les contrôles requis. Les preuves finales …
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 contient les sections Behavior, Verification, AI assistance et CodeRabbit. Elle décrit le comportement, les tests, les limites, le rollback et les contrôles requis. Les preuves finales de revue et le SHA révisé restent à renseigner avant la fusion.

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 17 functions across 3 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

Lapin des champs, je bondis près du capteur,
La tension du sol s’affiche en douceur.
Le filtre écarte le pic passager,
soil traduit la mesure pour l’arrosier.
Calibration, cadence : tout est au point,
Je croque une feuille et saute au loin.

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 ce16a1b into upstream/staging-v2r1 Oct 20, 2026
2 checks passed
@flowcool
flowcool deleted the upstream/soil-voltage-diagnostic branch October 20, 2026 19:43
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