cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.901: full source

This commit is contained in:
Setti Solutions S.R.L committed 2026-11-05 13:14:49 +02:00
1 parent d48b9aff87
commit e2c7085d2c
76 files changed
+5380 -330

No files matched your search

+43 -5
View File
@@ -46,8 +46,12 @@ var texts = map[string]map[string]string{
"passon": "Passed on to", "kind_control-box": "Control box", "kind_heat-pump": "Heat pump", "kind_wallbox": "Wallbox",
"kind_inverter": "Inverter", "kind_meter": "Meter", "kind_other": "Device", "untested": "untested on hardware",
"on": "on", "off": "off",
"no_control": "Control: no consent. Cantabile reads these devices and hands the grid operator's limit to its agent, but writes nothing to them (not even the grid operator's limit). Give your consent in the add-on's configuration (Cantabile may control devices).",
"all_ro": "Read only (a dry run): commands are checked and logged, nothing is written to the devices.",
"no_control": "Control: no consent. Cantabile reads these devices and hands the grid operator's limit to its agent, but writes nothing to them (not even the grid operator's limit). Give your consent in the add-on's configuration (Cantabile may control devices).",
"all_ro": "Read only (a dry run): commands are checked and logged, nothing is written to the devices.",
"lpc_declared": "Toward the control box: nominal power {} W declared (LPC offered).",
"lpc_refused": "LPC not offered: {}. Nothing is declared to the grid operator's control box until it is known.",
"rating": "Rated power (kW)", "rating_none": "not entered",
"rating_note": "From the device's nameplate, where it reports no power itself: the bridge declares the devices' power to the grid operator's control box only when it knows it, never a guess.",
},
"de": {
"title": "Cantabile EEBUS", "intro": "Wärmepumpen, Wallboxen und die Steuerbox des Netzbetreibers sprechen EEBUS. Koppeln Sie jedes Gerät hier einmal: vergleichen Sie die SKI mit der auf dem Display, dem Etikett oder in der App des Geräts, dann bestätigen.",
@@ -66,8 +70,12 @@ var texts = map[string]map[string]string{
"passon": "Weitergegeben an", "kind_control-box": "Steuerbox", "kind_heat-pump": "Wärmepumpe", "kind_wallbox": "Wallbox",
"kind_inverter": "Wechselrichter", "kind_meter": "Zähler", "kind_other": "Gerät", "untested": "nicht an echter Hardware getestet",
"on": "an", "off": "aus",
"no_control": "Steuern: keine Einwilligung. Cantabile liest diese Geräte und gibt das Limit des Netzbetreibers an seinen Agenten weiter, schreibt aber nichts an sie (auch nicht das Limit des Netzbetreibers). Geben Sie Ihre Einwilligung in der Konfiguration des Add-ons (Cantabile darf Geräte steuern).",
"all_ro": "Nur lesen (Probelauf): Befehle werden geprüft und protokolliert, nichts wird an die Geräte geschrieben.",
"no_control": "Steuern: keine Einwilligung. Cantabile liest diese Geräte und gibt das Limit des Netzbetreibers an seinen Agenten weiter, schreibt aber nichts an sie (auch nicht das Limit des Netzbetreibers). Geben Sie Ihre Einwilligung in der Konfiguration des Add-ons (Cantabile darf Geräte steuern).",
"all_ro": "Nur lesen (Probelauf): Befehle werden geprüft und protokolliert, nichts wird an die Geräte geschrieben.",
"lpc_declared": "Gegenüber der Steuerbox: Nennleistung {} W gemeldet (LPC angeboten).",
"lpc_refused": "LPC nicht angeboten: {}. Der Steuerbox des Netzbetreibers wird nichts gemeldet, bis sie bekannt ist.",
"rating": "Nennleistung (kW)", "rating_none": "nicht eingetragen",
"rating_note": "Vom Typenschild des Geräts, wo es selbst keine Leistung meldet: Die Bridge meldet der Steuerbox des Netzbetreibers die Leistung der Geräte nur, wenn sie bekannt ist, nie geschätzt.",
},
}
@@ -132,6 +140,9 @@ type dview struct {
Status string
Untested bool
Applied string
Rated bool // a heat pump or wallbox: the owner may enter its rating
RatedKW string // its rating now (kW), "" none
Reported bool // the device reports its power itself
}
type pview struct {
@@ -147,6 +158,8 @@ type pview struct {
Version string
Notice string // no consent to control, or the whole bridge read only
AllReadOnly bool
LPC string // the nominal power declared toward the control box, or why none (docs/parameters.md U3)
LPCRefused bool
}
func fmtValue(s Spec, v any, lang string) string {
@@ -185,6 +198,11 @@ func (p *Page) view(lang string) pview {
GridSKI: gridSKI(p.core.backend),
Events: events, Log: p.core.store.Recent(20), Sim: p.sim != nil, Version: version}
pv.GridText = t[grid.State]
if w, missing := p.core.NominalW(); w > 0 {
pv.LPC = strings.Replace(t["lpc_declared"], "{}", strconv.FormatFloat(w, 'f', 0, 64), 1)
} else {
pv.LPC, pv.LPCRefused = strings.Replace(t["lpc_refused"], "{}", NominalRefusal(w, missing), 1), true
}
pv.AllReadOnly = p.core.opts.ReadOnly
if p.core.opts.NoControl {
pv.Notice = t["no_control"]
@@ -210,6 +228,15 @@ func (p *Page) view(lang string) pview {
}
p.core.mu.Lock()
dv.Level, dv.Custodian = p.core.Level(&d, "*")
if d.Controllable() {
dv.Rated = true
if d.RatedW > 0 {
dv.RatedKW = strconv.FormatFloat(d.RatedW/1000, 'f', -1, 64)
}
x := d
x.RatedW = 0
_, dv.Reported = p.core.maxW(&x)
}
if pr := p.core.profiles[d.Profile]; pr != nil && pr.Status != "verified" {
dv.Untested = true
}
@@ -295,6 +322,7 @@ var tmpl = template.Must(template.New("page").Funcs(template.FuncMap{
{{if .Grid.ControlBox}}<div class="row"><span class="big {{if .Grid.Active}}bad{{else}}ok{{end}}">{{.GridText}}</span>
{{if .Grid.Active}}<span class="big">{{printf "%.0f" .Grid.LimitW}} W</span> <span class="note">{{.Until}}</span>{{end}}</div>
<div class="note">{{.T.sealed_note}}</div>{{else}}<div class="note">{{.T.no_cb}}</div>{{end}}
<div class="note{{if .LPCRefused}} bad{{end}}" id="lpc">{{.LPC}}</div>
{{if .Sim}}<div class="row" style="margin-top:.5rem">
<form method="post"><input type="hidden" name="action" value="sim_limit"><button>{{.T.sim_limit}}</button></form>
<form method="post"><input type="hidden" name="action" value="sim_end"><button class="off">{{.T.sim_end}}</button></form>
@@ -330,6 +358,8 @@ var tmpl = template.Must(template.New("page").Funcs(template.FuncMap{
{{else}}<form method="post"><input type="hidden" name="action" value="command"><input type="hidden" name="dev" value="{{$d.ID}}"><input type="hidden" name="key" value="{{.Key}}"><input type="number" name="value" min="{{.Min}}" max="{{.Max}}" step="{{.Step}}" required> {{.Unit}} <button>{{$.T.set}}</button></form>{{end}}
{{if eq .Level "protected"}}<form method="post" data-confirm="{{tr $.T "confirm_lift" .Name}}"><input type="hidden" name="action" value="protect"><input type="hidden" name="dev" value="{{$d.ID}}"><input type="hidden" name="key" value="{{.Key}}"><input type="hidden" name="level" value="none"><button class="off">{{$.T.lift}}</button></form>
{{else}}<form method="post"><input type="hidden" name="action" value="protect"><input type="hidden" name="dev" value="{{$d.ID}}"><input type="hidden" name="key" value="{{.Key}}"><input type="hidden" name="level" value="protected"><button class="off">{{$.T.protect}}</button></form>{{end}}{{end}}</td></tr>{{end}}</table></div>{{end}}
{{if .Rated}}<div class="card" id="rating"><h3>{{$.T.rating}}</h3><p class="note">{{$.T.rating_note}}</p>
<form method="post"><input type="hidden" name="action" value="rating"><input type="hidden" name="dev" value="{{.ID}}"><input type="number" name="kw" min="0" max="1000" step="any" value="{{.RatedKW}}" placeholder="{{$.T.rating_none}}"> kW <button>{{$.T.set}}</button></form></div>{{end}}
{{if eq .Level "sealed"}}<p class="note lock">{{$.T.sealed_note}} ({{$.T.custodian}}: {{.Custodian}})</p>{{else}}
<form method="post" data-confirm="{{tr $.T "confirm_unpair" .Name}}"><input type="hidden" name="action" value="unpair"><input type="hidden" name="dev" value="{{.ID}}"><button class="off">{{$.T.unpair}}</button></form>{{end}}
</section>{{end}}
@@ -398,6 +428,14 @@ func (p *Page) post(w http.ResponseWriter, r *http.Request) {
err = p.core.SetLevel(dev, r.FormValue("key"), r.FormValue("level"), who)
case "command":
_, err = p.core.Command(dev, r.FormValue("key"), r.FormValue("value"), who)
case "rating":
kw := 0.0
if v := strings.TrimSpace(r.FormValue("kw")); v != "" {
if kw, err = strconv.ParseFloat(strings.Replace(v, ",", ".", 1), 64); err != nil {
break
}
}
err = p.core.SetRating(dev, kw*1000, who)
case "sim_limit", "sim_end", "sim_hb_off", "sim_hb_on", "sim_plug":
if p.sim == nil {
err = errors.New("not simulating")
@@ -405,7 +443,7 @@ func (p *Page) post(w http.ResponseWriter, r *http.Request) {
}
switch r.FormValue("action") {
case "sim_limit":
p.sim.GridLimit(4200, 15)
p.sim.GridLimit(Para14aMinW, 15) // the simulated control box: §14a's minimum
case "sim_end":
p.sim.GridLimit(0, 0)
case "sim_hb_off":