cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.650: full source
This commit is contained in:
1 parent
85edd56ec8
commit
3edd015039
20 files changed
+2021
-35
No files matched your search
@@ -59,18 +59,24 @@ def actions_for(c, want, col, level="plan", why="") -> list[Action]:
|
||||
if c.kind == "battery":
|
||||
if isinstance(want, dict): # a plan entry: power and whether from the grid
|
||||
power, grid = float(want.get("set", 0)), bool(want.get("grid"))
|
||||
auto = bool(want.get("auto")) # the inverter's own self-consumption (optimizer._entry)
|
||||
else:
|
||||
power, grid = float(want), float(want) > 0
|
||||
auto = abs(power) < 50 # a command: about 0 is the inverter's own mode
|
||||
# With a setpoint the power is set there and the grid switch stays
|
||||
# off (it means "full power" on many inverters and would override
|
||||
# the setpoint); a battery with the switch alone is driven by it.
|
||||
switch("charge_from_grid", grid and "setpoint" not in e)
|
||||
if "mode" in e:
|
||||
# the inverter's own mode: manual while the plan sets power,
|
||||
# its self-consumption otherwise (the setpoint counts in manual only)
|
||||
opt = str(c.p("manual_option") if abs(power) >= 50 else c.p("auto_option"))
|
||||
# the inverter's own mode: its self-consumption where the plan's
|
||||
# battery balances the house, else manual at the plan's power (0:
|
||||
# hold, the self-consumption mode would discharge); the setpoint
|
||||
# counts in manual only
|
||||
opt = str(c.p("auto_option") if auto else c.p("manual_option"))
|
||||
if col.state(e["mode"]) != opt:
|
||||
act("mode", "select_option", {"option": opt}, opt)
|
||||
if opt == str(c.p("auto_option")):
|
||||
return out # the setpoint counts in manual only: not touched
|
||||
setnum("setpoint", power, "power_w")
|
||||
elif c.kind in ("heating", "cooling"):
|
||||
v = want.get("set") if isinstance(want, dict) else want
|
||||
@@ -131,7 +137,8 @@ def safe_want(c):
|
||||
"""The control's safe value when plans or data are stale."""
|
||||
if c.kind == "battery":
|
||||
s = c.safe or {}
|
||||
return {"set": float(s.get("setpoint", 0)), "grid": bool(s.get("charge_from_grid", False))}
|
||||
sp = float(s.get("setpoint", 0))
|
||||
return {"set": sp, "grid": bool(s.get("charge_from_grid", False)), "auto": abs(sp) < 50}
|
||||
v = (c.safe or {}).get(next(iter(c.writable()), ""), RELEASE)
|
||||
return v
|
||||
|
||||
|
||||
Reference in new issue
Block a user