Skip to content

feat(discovery): Fox Cloud configured through discovery; extra_entities for metered third-party generation - #6517

Merged
springfall2008 merged 15 commits into
mainfrom
feat/fox-discovery
Dec 4, 2026
Merged

springfall2008 merged 15 commits into
mainfrom
feat/fox-discovery

Conversation

@springfall2008

@springfall2008 springfall2008 commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

This is the third slice of discovery-driven inverter configuration, after GE Cloud (#6188) and GivTCP (#6514). Fox Cloud (fox_automatic) now configures its inverters through the discovery coordinator and no longer writes apps.yaml args itself.

Fox's discovery record already named every entity its automatic_config() bound, with one exception. A battery inverter with its own PV and a metered third-party generator (CT2) puts two entries in pv_today/pv_power. A record can bind only one entity per setting. So that this generation isn't lost, records gain a new container, extra_entities.

Design: docs/superpowers/specs/2026-12-04-fox-discovery-automatic-config-design.md. Plan: docs/superpowers/plans/2026-12-04-fox-discovery.md.

What changes

  • extra_entities record container.

    • Shape: {summed setting: [entity descriptor, ...]}, for load_today, import_today, export_today, pv_today and pv_power only.
    • Each entry must name an entity_id. Any entry that doesn't fit drops the whole key, with a warning.
    • inverter_record(..., extra_entities=...) takes it. The web discovery page folds it with entities.
  • Coordinator: summed lists. Each list is built in this order:

    1. the slot entries;
    2. each discovered slot's extra entities, in slot order;
    3. the user's apps.yaml extras;
    4. PV-only devices.

    With no discovered slot at all (every inverter configured by hand), the coordinator decides only pv_today/pv_power, and only when a source counts PV-only devices: the hand-written lists with those devices added after them.

    Exceptions:

    • An entity already in the list is not added again. This includes a PV-only device's entity that the user already lists.
    • A record on standby adds nothing.
    • A setting the source skips adds nothing, PV-only devices included.
  • Fox's record. A driven inverter with its own PV and a CT2 generator reports feedin2/meterpower2 in extra_entities.

  • Fox opts in to the coordinator before its first report.

    • Nothing in apps.yaml wins: the old configuration overwrote every key.
    • fox_automatic_ignore_pv leaves pv_today/pv_power to apps.yaml.
    • PV-only devices follow the Fix for Fox and PV inverter, Fix for Octopus slot robustness #2943 rule. They count while some Fox battery inverter has no PV of its own, or when Fox drives no battery at all (Fox solar beside another make's battery). Fox re-sends its options when the device mix changes that answer.
  • The old configuration survives as a pure _legacy_bindings(). A passive check_automatic_config() compares discovery's result with it and only logs.

    • pv_today, pv_power and the energy totals are compared by what they count, not their order. An entity listed twice is a Warn.
    • It also warns about a slot configured by hand as FoxESS/FoxCloud beside the discovered Fox inverters. That is typically a leftover from the Fox Modbus template, and its entity names never contain the serial, so discovery can't take it over.
  • Which devices Predbat drives is now one helper, FoxAPI._drives(), shared by the record and _driven_serials(). _legacy_bindings() keeps its own copy: it is the reference the checker compares against.

Behaviour changes worth a release note

  • When no Fox device qualifies as a battery inverter, Fox no longer raises out of run().
    • It warns, stays opted in, and configures the inverter once its details arrive.
    • If every Fox device is solar only, this is logged at Info, and its PV is counted beside the other battery, whether discovery or apps.yaml configures it.
    • Predbat itself still stops if no source configures any inverter.
  • A Fox PV-only device is also counted when Fox has no battery inverter. Before, an all-solar Fox account configured nothing.
  • A slot you configured by hand is kept, as with GE Cloud. A leftover FoxESS slot now gets a warning: before, Fox's automatic configuration overwrote it.

Testing

  • The full suite passes (./run_all, 4 workers), and run_pre_commit --checks-only passes.
  • New unit tests:
    • the container's validation;
    • the summed-list order and dedupe;
    • extra_entities on standby and retained slots;
    • the warning for a source that counts only PV-only devices;
    • Fox's record, opt-in options, PV-only rule and option re-sync;
    • the warning when nothing qualifies, and Info when Fox is solar only;
    • the checker's Info and Warn lines.
  • New contract check, assert_summed_settings_agree, in tests/discovery_contract.py. The Fox agreement test now compares the whole PV lists; before, it compared only one entry per device and never reached the CT2 entry. Existing contract functions are unchanged.
  • The existing Fox automatic_config() tests now check _legacy_bindings(), which the checker still compares against.
  • Acceptance tests run a real FoxAPI through run() against the real Coordinator, with only the Fox cloud calls stubbed:
    • one battery inverter with PV;
    • two battery inverters;
    • a battery inverter plus a PV-only device;
    • PV plus CT2;
    • CT2 only;
    • CT2 metering a Fox PV inverter (counted once);
    • fox_automatic_ignore_pv;
    • no device qualifying;
    • a hand-written FoxCloud slot taken over;
    • a leftover FoxESS Modbus slot (warned);
    • Fox solar beside a GE Cloud battery.
  • Checked by mutation: with the coordinator not adding extras, the CT2 acceptance test fails.

Known limits

  • On a site with both GE Cloud and Fox batteries, Fox's checker can warn about battery_temperature_history, which comes from the lowest slot. GivTCP's checker has the same pattern.

🤖 Generated with Claude Code

CI and others added 12 commits December 4, 2026 12:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ra_entities validation and the checker's summed compare

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngs()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nfiguration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot, count a listed PV-only sensor once

Final review fixes: Fox counts PV-only devices while some Fox battery inverter lacks its own PV, or when Fox drives
no battery, re-sending its options when the devices change; a CT2-metered Fox PV inverter is no longer counted twice.
The coordinator no longer adds a PV-only device's entity the user already lists. Fox's checker warns about a slot
configured by hand as FoxESS/FoxCloud beside the discovered ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… two warnings

When every Fox device is PV-only, Fox logs Info rather than warning that no device is a battery inverter, and the
coordinator no longer warns about a source that only counts PV-only devices and never had a slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the BOT_REVIEW Trigger an autotriage label Dec 4, 2026

@springfall2008 springfall2008 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Automated comment from the triage bot.

Verdict: 🟡 Amber - Recommend addressing the feedback, then approval

No defect in the plan or write path: reading the diff and the call paths, the summed-list order, the CT2 extras and the PV-only rule reduce to what _legacy_bindings() counts, and the coordinator does reach the new checker (test_accept_fox_leftover_modbus_slot_warns can only pass through it). I read the tests rather than running them. The changes asked for are that two statements stop being untrue, and one startup cycle stops logging two warnings.

Reviewed at 24837721ee69cfc2cb7b35f9d05cde71f23d94fe. 3 findings posted inline, 0 in the body.

One non-anchored nit: the PR description says _drives() is "shared by the record and the legacy plan", but _legacy_bindings() keeps its own copy of the predicate (which is right — it is the reference the checker compares against). Worth correcting the description so nobody goes looking for a single predicate.

Comment thread apps/predbat/fox.py Resolved
Comment thread apps/predbat/fox.py Resolved
Comment thread apps/predbat/bindings.py Resolved
@springfall2008 springfall2008 removed the BOT_REVIEW Trigger an autotriage label Dec 4, 2026
CI and others added 3 commits December 4, 2026 14:20
…ed; one warning for an unread first cycle; docstrings name _legacy_bindings()

- The solar-only Info line and docs no longer promise Fox PV is counted beside a battery configured by hand in
  apps.yaml: discovery decides no list there, so the user lists it.
- The coordinator no longer warns that a source reported no inverter when that source never had a slot and none of
  its records carries entities yet (a first cycle whose detail read failed); Fox's own warning says why.
- Fox's record docstrings name _legacy_bindings(), which now holds what the previous configuration bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no discovered slot, the coordinator now decides pv_today and pv_power - and only those - when a source counts
PV-only devices: the hand-written lists with the PV-only devices added after them. A source that skips those settings
adds no PV-only device to them. Fox solar beside another make's battery in apps.yaml is counted, as decided.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l components

A real GECloudDirect or GivTCPComponent battery and a real FoxAPI with one PV-only device on one Coordinator, in
either start order: one GivEnergy inverter, the Fox PV counted after the GivEnergy PV, and no warning from any
component or checker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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