♻️ Move site rate ×100 scalar into the sensor #45
No reviewers
Labels
No labels
v1.0 · bloquant
v1.0 · majeur
v1.0 · mineur
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mat/homeassistant-comwatt!45
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/site-rate-scalar-in-sensor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
#19duplicated the "is this a rate?" knowledge in two places that can silently drift apart:coordinator.py→_RATE_KEYSdecided the ×100sensor.py→SITE_METRICSdecided thePERCENTAGEunitAdd a rate key to one set and forget the other → a ×100 value surfaced in Wh, or a raw 0-1 ratio surfaced in %. No test caught that direction.
Change
_RATE_KEYSis deleted.native_unit_of_measurement == PERCENTAGE— the single source of truth, next to the unit it already owns.Behavior
Unchanged at the entity level:
test_auto_production_rate_reads_latest_value(0.42 → 42.0) andtest_site_metrics_expose_every_known_key(0.75 → 75.0) still pass as-is. Re-adding ×100 to the coordinator would double-scale and make0.42 → 4200, so the existing tests lock the new contract.Test plan
0dcacd63205a0a145552