FU11: anchor cumulative cost at recording start; add daily-reset cost entities; prefill add-version form
frontend / frontend (push) Successful in 2m6s
pytest / test (push) Successful in 7m32s

- MQTT import_cost_total / export_revenue_total now anchor fixed-fee / tax-credit
  accrual at max(contract start, first recorded period), so standing charges for
  untracked pre-recording days are no longer folded into the running total.
- Add energy.import_cost_today / energy.export_revenue_today (monetary,
  total_increasing) that reset at server-local midnight, for per-day cost
  aggregation in Home Assistant alongside the running totals.
- ContractForm add-version mode prefills the contract's open version values, so
  only the fields that actually change need editing.
This commit is contained in:
2026-06-25 12:45:24 +02:00
parent b71009620a
commit 96e85fb48e
5 changed files with 689 additions and 63 deletions
+8 -7
View File
@@ -205,9 +205,10 @@ def test_register_provider_direct_call():
def test_build_catalog_empty_with_no_devices(expose_db):
"""build_catalog with no enabled modbus devices must contain no modbus entities.
The energy_cost provider is always registered and always produces its 4 entities
regardless of device state, so the catalog will not be empty. This test checks
that no *modbus* entities are present when there are no enabled modbus devices.
The energy_cost provider is always registered and always produces its 6 entities
(4 original + 2 daily) regardless of device state, so the catalog will not be empty.
This test checks that no *modbus* entities are present when there are no enabled
modbus devices.
"""
from app.integrations.expose import build_catalog
@@ -215,16 +216,16 @@ def test_build_catalog_empty_with_no_devices(expose_db):
catalog = build_catalog(session)
# The modbus provider finds no enabled devices → no modbus entities.
# The energy_cost provider always produces 4 entities, so the catalog is non-empty.
# The energy_cost provider always produces 6 entities, so the catalog is non-empty.
modbus_entities = [e for e in catalog if e.entity.key.startswith("modbus.")]
assert modbus_entities == [], (
"Expected no modbus entities when no modbus devices are enabled"
)
# The 4 energy_cost entities should always be present.
# The 6 energy_cost entities should always be present (4 original + 2 daily).
energy_keys = {e.entity.key for e in catalog if e.entity.key.startswith("energy.")}
assert len(energy_keys) == 4, (
f"Expected exactly 4 energy_cost entities, got {energy_keys!r}"
assert len(energy_keys) == 6, (
f"Expected exactly 6 energy_cost entities (4 original + 2 daily), got {energy_keys!r}"
)