Robust entity discovery via registry and visible demo-mode notice - #5
Open
Optic00 wants to merge 1 commit into
Open
Robust entity discovery via registry and visible demo-mode notice#5Optic00 wants to merge 1 commit into
Optic00 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The card discovers its data by guessing exact entity IDs (
sensor.bms_1_cells_average_voltage,sensor.bmu_power, ...) and silently renders demo data when nothing matches. This PR makes discovery robust and the demo fallback visible:_ensureRegistries()for product names): entries are filtered byplatform === 'byd_battery_box', then matched with relaxed patterns that tolerate any entity_id prefix and the numeric duplicate suffix HA appends (..._2). Without registry access (e.g. card preview), it falls back to the previous state-key scan, with the same relaxed patterns.unavailableduplicate never shadows the live entity.Fixes #4.
Why exact-ID matching breaks
_2to entity IDs when the old registry entries still hold the original names. This happens whenever the byd_battery_box integration is removed and re-added, which is exactly the workaround users perform for First-time config entry setup fails with setup_error (no auto-retry) — should raise ConfigEntryNotReady on transient Modbus connect byd_battery_box#14 (first-time setup fails intosetup_error; fix in Raise ConfigEntryNotReady on transient connect failure (fixes #14) byd_battery_box#15). After that,/^sensor\.bms_(\d+)_cells_average_voltage$/no longer matches anything and the card quietly shows fake values (SoC 75 %, "BMS demo", 0 W).Testing
node --checkon source and rebuilt bundle;npm run buildregenerated the committed bundle (CI's up-to-date check passes)._2suffix -> real data (previously demo); prefixed IDs -> real data (previously demo); integration absent or not running -> demo data plus visible notice.