Skip to content

test(validate): pin the repeated entity pointer for per-car sensor args - #5191

Merged
springfall2008 merged 1 commit into
mainfrom
test/validate-per-car-sensor-pointer
Sep 24, 2026
Merged

springfall2008 merged 1 commit into
mainfrom
test/validate-per-car-sensor-pointer

Conversation

@mgazza

@mgazza mgazza commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

car_charging_battery_size and car_charging_limit are sensor-typed keys with
entries: num_cars, so a scalar fails validation as soon as runtime num_cars > 1
("Invalid type, expected list"). Anything publishing one of these as a pointer to a
single entity therefore has to emit a list, and rely on two behaviours that nothing
currently pins:

  • the validator trims a list longer than num_cars rather than rejecting it, so a
    fixed-length list is safe at any car count; and
  • each slot is read by index, so repeating the same entity id across the list
    resolves per car.

This adds a case to test_validate_config covering both. It seeds one sensor and
points every slot at it, then checks num_cars 0, 1, 2 and 8 all validate, that a
bare scalar still fails at 2, and that each slot resolves through get_arg(..., index=slot) as a float — the fractional value matters, since an int default
silently truncates a 10.5 kWh battery to 10.

No production code changes.

Follow-up to #5117, which fixed the gateway's unindexed read of the same key. The
test was written alongside that fix but landed after it merged, so it needs its own
PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@springfall2008
springfall2008 merged commit 1daa164 into main Sep 24, 2026
2 checks passed
@springfall2008
springfall2008 deleted the test/validate-per-car-sensor-pointer branch September 24, 2026 07:09
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.

2 participants