cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.1541: full source
This commit is contained in:
1 parent
05802d6f87
commit
94f46db8f8
19 files changed
+863
-60
No files matched your search
@@ -14,11 +14,29 @@ of the electricity saving is load shifting and off-peak buying (battery,
|
||||
car, appliances). Gas and district heat are the heating's alone.
|
||||
|
||||
{"electricity": {"plan_eur", "base_eur", "heating_eur"},
|
||||
"gas": {"plan_eur", "base_eur"}, "heat": {"plan_eur", "base_eur"}}
|
||||
"gas": {"plan_eur", "base_eur"[, "why", "note"]}, "heat": {...}, "oil": {...}}
|
||||
|
||||
base_eur − plan_eur summed over the carriers is the plan's saving without
|
||||
the market's contracts (cost_eur carries them, step_costs does not). None
|
||||
without a tariff (no step costs)."""
|
||||
Gas, heating oil and district heat whose saving rounds to 0.00 EUR carry
|
||||
why (a code) and note (in words) instead of a bare 0 (2026-11-09, the
|
||||
owner: "we still have no saving from gas/oil?"; methods E14):
|
||||
not_used the carrier is priced, the plan makes no heat with it (a
|
||||
hybrid's heat pump made all of it)
|
||||
flat_price one price at every step of the horizon: the plan's heat costs
|
||||
the same whenever it is made, there is nothing to move in time
|
||||
(the baseline counts the plan's own heat at the mean price,
|
||||
A12.2; a lower room temperature is not counted as a saving,
|
||||
E14; a hybrid's choice of source is not counted either)
|
||||
not_shifted the price varies, but the heat lies where it is needed
|
||||
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
|
||||
|
||||
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
|
||||
offer's price per slot, GGV §42b / Mieterstrom §42a / §42c; before, only the
|
||||
grid meter was priced and such a flat showed electricity 0.00 against a
|
||||
baseline of its whole load). None without a tariff (no step
|
||||
costs)."""
|
||||
|
||||
|
||||
def saving_parts(s: dict, m, x, steps: dict | None) -> dict | None:
|
||||
@@ -38,4 +56,42 @@ 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)
|
||||
for carrier in HEAT_CARRIERS:
|
||||
why = zero_why(s, m, carrier, out.get(carrier))
|
||||
if why is not None:
|
||||
out.setdefault(carrier, {"plan_eur": 0.0, "base_eur": 0.0}).update(why)
|
||||
return out
|
||||
|
||||
|
||||
HEAT_CARRIERS = {"gas": ("price_gas", "gas"), "oil": ("price_oil", "heating oil"), "heat": ("price_heat", "district heat")}
|
||||
ZERO_EUR = 0.005 # a saving that rounds to 0.00 EUR
|
||||
|
||||
|
||||
def zero_why(s: dict, m, carrier: str, part: dict | None) -> dict | None:
|
||||
"""Why a heat carrier's saving is 0 in this plan ({why, note}; module
|
||||
docstring), None where it has a saving or is not there at all."""
|
||||
key, words = HEAT_CARRIERS[carrier]
|
||||
if part is None:
|
||||
# not in the plan: a heating control or tank on it refused for want of its price
|
||||
for r in (s.get("refused") or {}).values():
|
||||
if f"{carrier}_price" in (r.get("missing") or []):
|
||||
return {"why": "not_planned", "note": f"its heating is not planned: {r.get('why') or 'refused'}"}
|
||||
return None
|
||||
if abs(part["base_eur"] - part["plan_eur"]) >= ZERO_EUR:
|
||||
return None
|
||||
hybrid = any(kind == "heating" and v and v.get("src") == "hybrid" and (v.get("fuel") or "gas") == carrier
|
||||
for kind, v in m.devices.values())
|
||||
col = "district" if carrier == "heat" else "gas"
|
||||
rooms = any(kind == "heating" and v and any(c is not None for c in v.get(col) or [])
|
||||
and (carrier == "heat" or (v.get("fuel") or "gas") == carrier) for kind, v in m.devices.values())
|
||||
tail = "; a hybrid's choice between heat pump and boiler is not counted as a saving" if hybrid else ""
|
||||
if abs(part["plan_eur"]) < ZERO_EUR and abs(part["base_eur"]) < ZERO_EUR:
|
||||
return {"why": "not_used", "note": (f"the heat pump made all the heat in this plan: no {words} used" if hybrid
|
||||
else f"no {words} used in this plan") + tail}
|
||||
ps = [p for p in (s.get(key) or [])[:m.T] if p is not None]
|
||||
if ps and max(ps) - min(ps) < 1e-9:
|
||||
return {"why": "flat_price", "note": f"one {words} price ({ps[0]:.2f} ct/kWh) at every hour of the plan: its heat "
|
||||
"costs the same whenever it is made, nothing to move in time"
|
||||
+ ("; 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}
|
||||
Reference in new issue
Block a user