Skip to content

fix(dev): canonical api_token and url options (#451) - #34

Merged
MaStr merged 1 commit into
mainfrom
copilot/bugfix-config-key-unification
Oct 14, 2026
Merged

MaStr merged 1 commit into
mainfrom
copilot/bugfix-config-key-unification

Conversation

@MaStr

@MaStr MaStr commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Add-on side of MaStr/batcontrol#452 (fixes MaStr/batcontrol#451). Development add-on only — batcontrol/ (stable, 0.9.1) is untouched and gets this at the next release sync.

Why

Upstream unifies the configuration keys: api_token for a credential, url for an endpoint, in every section. This add-on symlinks /data/options.json as the configuration (entrypoint_ha.sh), so its schema is the only validation layer — and it offered apikey, apitoken and base_url side by side in the same pvinstallations entry. That is how a user ended up pasting a long-lived access token into apikey of a HomeAssistant solar installation and seeing nothing but expected str at 'access_token'. Got None at startup.

Breaking change

The development schema knows the canonical keys only:

old option new option section
apikey api_token utility, pvinstallations
apitoken api_token consumption_forecast
base_url url pvinstallations, consumption_forecast

This has to be a hard rename here, not an alias: the Supervisor refuses to start an add-on whose stored options contain a key the schema does not list, so the upstream alias handling never gets a chance in the add-on. Users have to rename these options once. Prominently stated in the CHANGELOG as ### Breaking Changes and at the top of the DOCS configuration section.

batcontrol itself (Docker, pip, hand-written batcontrol_config.yaml) still reads the old spellings and logs a deprecation warning instead.

Also in here

  • All credentials are password? now, like inverter.password and mqtt.password. utility.apikey was the only masked one; the two HomeAssistant tokens were plain str? and shown in clear text in the UI.
  • pvinstallations gained the optional type key, which upstream uses to identify which entry belongs to the selected provider.
  • cache_ttl_hours default corrected from 24.0 to 12.0 — the value the cache actually uses (upstream wires the option up for the first time in #452).
  • DOCS.md was stale and part of the problem: solar_forecast_provider still named solarprognose, and pvinstallations documented algorithm/item/token of that long-removed provider while not mentioning a single HomeAssistant Solar Forecast ML key. Rewritten per provider, with the consumption_forecast keys added.
  • Version bumped to 0.10.0dev5 so HA offers the update.

Verification

yaml.safe_load over the changed config.yaml passes; every key under options: has a matching schema: entry. translations/en.yaml needs no change — no new top-level block.

Please merge together with MaStr/batcontrol#452.

🤖 Generated with Claude Code

Upstream MaStr/batcontrol#452 unifies the configuration keys: api_token
for a credential, url for an endpoint, in every section. The add-on
symlinks /data/options.json as the configuration, so its schema is the
only validation layer - and it offered apikey, apitoken and base_url
side by side, which is how a user ended up putting a long-lived access
token into "apikey" of a HomeAssistant solar installation and seeing
only "expected str at 'access_token'. Got None" at startup.

The development schema now knows the canonical keys only. This is a
breaking change for stored configurations: the Supervisor refuses to
start an add-on whose options contain a key the schema does not list, so
the upstream alias handling never gets a chance here. The CHANGELOG
entry carries the rename table.

While in there:

- every api_token is typed password? now, like inverter.password and
  mqtt.password - utility.apikey was the only masked credential before,
  the two HomeAssistant tokens were plain str? and shown in clear text
- pvinstallations gained the optional type key, which upstream uses to
  identify which entry belongs to the selected provider
- cache_ttl_hours default corrected from 24.0 to 12.0, the value the
  cache actually uses
- DOCS.md: solar_forecast_provider still named solarprognose, and
  pvinstallations documented algorithm/item/token of that long-removed
  provider while not mentioning a single HomeAssistant Solar Forecast ML
  key. Rewritten per provider, consumption_forecast keys added.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It is a breaking schema rename that forces users to migrate stored options and whose correctness depends on the coupled upstream MaStr/batcontrol#452 being merged together, which needs human coordination and verification.

0 open findings

What changed in this PR

This PR updates the development Home Assistant add-on (batcontrol-development/) to match the upstream configuration-key unification from MaStr/batcontrol#452 (fixing #451). It performs a breaking rename of configuration keys so that every section uses api_token for credentials and url for endpoints, replacing the inconsistent apikey/apitoken/base_url spellings. Because the add-on symlinks /data/options.json as the config, its schema is the only validation layer, so this is a hard rename rather than an alias. The stable batcontrol/ add-on is intentionally left untouched.

Changes:

  • Renamed apikey/apitoken → api_token and base_url → url across utility, pvinstallations, and consumption_forecast in both options: and schema:, with all api_token fields now password? (masked).
  • Added optional pvinstallations.type key, corrected the solar cache_ttl_hours default comment from 24.0 to 12.0, and bumped the version to 0.10.0dev5.
  • Rewrote the stale DOCS.md configuration section per provider (removing the long-removed solarprognose keys and adding HomeAssistant provider keys) and added a ### Breaking Changes CHANGELOG entry with a migration table.
File Description
batcontrol-development/​config.yaml Renames credential/URL keys in options:/schema:, masks tokens as password?, adds type, fixes cache_ttl_hours default comment, bumps version
batcontrol-development/​DOCS.md Adds a breaking-change migration note and rewrites the per-provider parameter docs to match the canonical keys
batcontrol-development/​CHANGELOG.md Documents the breaking rename (with migration table) plus the matched-entry and cache_ttl_hours enhancements

I verified that the YAML parses, that every active options: key has a matching schema: entry at the same path, and that no active apikey/apitoken/base_url keys remain. The changes are internally consistent, and I found no objective code issues to flag.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@MaStr
MaStr merged commit ccb456b into main Oct 14, 2026
4 checks passed
@MaStr
MaStr deleted the copilot/bugfix-config-key-unification branch October 14, 2026 14:50
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.

Apikey - Auth message incorrectly formatted: expected str at 'access_token'. Got None

2 participants