cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.1789: full source

This commit is contained in:
Setti Solutions S.R.L committed 2026-11-12 06:28:42 +02:00
1 parent 94f46db8f8
commit b24675fe9c
25 files changed
+766 -40

No files matched your search

+52
View File
@@ -30,6 +30,19 @@ owner: "we still have no saving from gas/oil?"; methods E14):
not_planned the heating or tank on it was refused (its refusal's why: e.g.
no gas price); 0 in plan and base, nothing of it is planned
Electricity whose saving rounds to 0.00 EUR carries why and note too (audit
2026-11-09: 28 homes showed electricity 0 without a reason):
no_lever the plan moves no electricity: no battery, no car plugged in
or expected, no electric heating (heat pump, heater) and no
electric hot water; the household's own use is a fixed term
(a district-heat or gas flat, a car away)
flat_price it has a lever, but one import price at every step and no
battery: the lever's draw costs the same whenever it runs
not_shifted the price varies (or a battery could store), but the plan
found nothing cheaper than the baseline: the draw already lies
in the cheapest hours, or nothing is due in the horizon
The levers found are in the note.
base_eur − plan_eur summed over the carriers is the plan's own saving,
baseline_eur − cost_eur: the plan's electricity carries the market's
contracts (a tenant-power flat's energy bought from its building at the
@@ -56,6 +69,10 @@ def saving_parts(s: dict, m, x, steps: dict | None) -> dict | None:
if p is not None:
heating += m.eur_wh(t, mean - pi[t]) * x(p)
out["electricity"]["heating_eur"] = round(heating, 4)
if "electricity" in out:
why = electricity_zero_why(s, m, out["electricity"])
if why is not None:
out["electricity"].update(why)
for carrier in HEAT_CARRIERS:
why = zero_why(s, m, carrier, out.get(carrier))
if why is not None:
@@ -95,3 +112,38 @@ def zero_why(s: dict, m, carrier: str, part: dict | None) -> dict | None:
+ ("; a lower room temperature is not counted as a saving" if rooms else "")
+ tail}
return {"why": "not_shifted", "note": f"the {words} price varies, but the heat was needed when it was made" + tail}
def electric_levers(m) -> list[str]:
"""What in this plan can move electricity in time (its words)."""
out = []
for kind, v in m.devices.values():
if not v:
continue # e.g. a car not plugged in and none expected
if kind == "battery" and float(v.get("cap") or 0) > 0:
out.append("battery")
elif kind == "ev":
out.append("car")
elif kind in ("heating", "cooling") and v.get("src") in ("electric", "heat_pump", "hybrid"):
out.append({"heat_pump": "heat pump", "hybrid": "hybrid's heat pump"}.get(v["src"], "electric heating")
if kind == "heating" else "cooling")
elif kind == "dhw_tank" and v.get("src") == "electric":
out.append("electric hot water")
return sorted(set(out))
def electricity_zero_why(s: dict, m, part: dict) -> dict | None:
"""Why the electricity saving is 0 in this plan ({why, note}; module docstring), None where it has one."""
if abs(part["base_eur"] - part["plan_eur"]) >= ZERO_EUR:
return None
levers = electric_levers(m)
if not levers:
return {"why": "no_lever", "note": "nothing in this plan moves electricity in time (no battery, no car plugged in "
"or expected, no heat pump or electric heating, no electric hot water): "
"the household's own use is the same with and without the plan"}
ps = [p for p in (s.get("price_import") or [])[:m.T] if p is not None]
if ps and max(ps) - min(ps) < 1e-9 and "battery" not in levers:
return {"why": "flat_price", "note": f"one electricity price ({ps[0]:.2f} ct/kWh) at every hour of the plan: "
f"the {', '.join(levers)} costs the same whenever it runs"}
return {"why": "not_shifted", "note": f"the {', '.join(levers)} found nothing cheaper in this plan: its draw "
"already lies in the cheapest hours, or nothing is due in the horizon"}