Repository navigation
fix(dev): canonical api_token and url options (#451) - #34
Conversation
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>
There was a problem hiding this comment.
🔵 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_tokenandbase_url→urlacrossutility,pvinstallations, andconsumption_forecastin bothoptions:andschema:, with allapi_tokenfields nowpassword?(masked). - Added optional
pvinstallations.typekey, corrected the solarcache_ttl_hoursdefault comment from24.0to12.0, and bumped the version to0.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 ChangesCHANGELOG 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.
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_tokenfor a credential,urlfor an endpoint, in every section. This add-on symlinks/data/options.jsonas the configuration (entrypoint_ha.sh), so its schema is the only validation layer — and it offeredapikey,apitokenandbase_urlside by side in the samepvinstallationsentry. That is how a user ended up pasting a long-lived access token intoapikeyof a HomeAssistant solar installation and seeing nothing butexpected str at 'access_token'. Got Noneat startup.Breaking change
The development schema knows the canonical keys only:
apikeyapi_tokenutility,pvinstallationsapitokenapi_tokenconsumption_forecastbase_urlurlpvinstallations,consumption_forecastThis 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 Changesand 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
password?now, likeinverter.passwordandmqtt.password.utility.apikeywas the only masked one; the two HomeAssistant tokens were plainstr?and shown in clear text in the UI.pvinstallationsgained the optionaltypekey, which upstream uses to identify which entry belongs to the selected provider.cache_ttl_hoursdefault corrected from24.0to12.0— the value the cache actually uses (upstream wires the option up for the first time in #452).solar_forecast_providerstill namedsolarprognose, andpvinstallationsdocumentedalgorithm/item/tokenof that long-removed provider while not mentioning a single HomeAssistant Solar Forecast ML key. Rewritten per provider, with theconsumption_forecastkeys added.0.10.0dev5so HA offers the update.Verification
yaml.safe_loadover the changedconfig.yamlpasses; every key underoptions:has a matchingschema:entry.translations/en.yamlneeds no change — no new top-level block.Please merge together with MaStr/batcontrol#452.
🤖 Generated with Claude Code