-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tinkerforge WARP HTTP API (BC) #26334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- In
meterValuesthe length checklen(res) <= 5will still allow slices of length 5 and thencurrents/voltagesindex up tores[5], so this should belen(res) < 6(or equivalent) to avoid a potential out-of-bounds panic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `meterValues` the length check `len(res) <= 5` will still allow slices of length 5 and then `currents`/`voltages` index up to `res[5]`, so this should be `len(res) < 6` (or equivalent) to avoid a potential out-of-bounds panic.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
OT, bitte neuer PR. |
|
Nice PR! |
Hast Du dazu eine Referenz? |
Ah, missverständlich. Die ist nicht in der WARP Firmware deprecated, sondern die evcc Templates sind als deprecated markiert ;). |
|
Ah- für mich auch ok. Ohne Umwege ist egtl. immer besser! |
| // CurrentPower implements the api.Meter interface | ||
| func (wb *WarpHTTP) currentPower() (float64, error) { | ||
| var res warp.MeterValues | ||
| uri := fmt.Sprintf("%s/meter/values", wb.uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://docs.warp-charger.com/docs/interfaces/mqtt_http/api_reference/meter this endpoint is deprecated. They recommend to use https://docs.warp-charger.com/docs/interfaces/mqtt_http/api_reference/meters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ja, stelle ich um. Habs erstmal einfach 1:1 von MQTT übernommen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich werds so machen, dass am Anfang geprüft wird, ob die meters API überhaupt unterstützt wird, sonst Fallback auf die alte API.
mfuchs1984
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline comment.
|
Für Setups wo neben evcc auch andere Systeme auf die Wallbox zugreifen, hat MQTT den Vorteil dass alle Clients parallel per Publish/Subscribe lauschen können, ohne die Wallbox mehrfach zu pollen. Wäre es sinnvoll, die MQTT Templates nicht als deprecated zu markieren, sondern als gleichwertige Alternative zu belassen – für Nutzer die ohnehin einen Broker betreiben? |
|
|
||
| var phases func(int) error | ||
| var getPhases func() (int, error) | ||
| if cc.EnergyManagerURI != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bei der WARP3 ist kein separater WEM notwendig, da die WARP3 die Phasenumschaltung selbst über die /power_manager/ API unterstützt. Der Code sollte prüfen ob die Wallbox-URI selbst das Feature hat.
Weiterhin sollte der Kommentar im Template angepasst werden, da dies für WARP3 Nutzer sonst irreführend ist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guter Punkt, in dem Fall würde ich vermutlich für WARP3 einfach ein eigenes Template machen und dort die EnergyManagerURI auch auf die Wallbox URI hardcoden. Dann kann man auch die Dokumentation auseinander ziehen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wie wäre es so?
if cc.EnergyManagerURI == "" {
wb.emURI = wb.uri
wb.emHelper = wb.Helper
}
if res, err := wb.emState(); err == nil && res.ExternalControl != 1 {
phases = wb.phases1p3p
getPhases = wb.getPhases
}Das hier wäre die Antwort einer WARP2:
curl http://172.20.10.50/power_manager/state
{"config_error_flags":0,"external_control":1}
WEM:
curl http://172.20.10.60/power_manager/state
{"config_error_flags":0,"external_control":0}
und einer WARP3:
curl http://192.168.179.250/power_manager/state
{"config_error_flags":0,"external_control":0}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ich hab einfach so gedacht:
template: tinkerforge-warp3-http
products:
- brand: TinkerForge
description:
generic: WARP3 Charger Smart
- brand: TinkerForge
description:
generic: WARP3 Charger Pro
capabilities: ["mA", "1p3p", "rfid"]
evcc: ["skiptest"]
params:
- name: uri
required: true
- name: user
- name: password
render: |
type: warp-http
uri: {{ .uri }}
user: {{ .user }}
password: {{ .password }}
energyManagerUri: {{ .uri }}
energyManagerUser: {{ .user }}
energyManagerPassword: {{ .password }}
Da muss man als Nutzer dann auch nur noch eine URI eingeben. Und die Beschreibung mit WEM und Firmware Version ist auch gleich weg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wieder Geschmackssache, bin ich persönlich neutral. Hat beides Vor- und Nachteile.
| } | ||
|
|
||
| var res interface{} | ||
| return wb.DoJSON(req, &res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verursacht bei mir einen EOF mit WARP2 und WEM:
[warp-http] TRACE 2026/01/03 14:54:57 GET http://172.20.10.50/info/features
[warp-http] TRACE 2026/01/03 14:54:57 ["evse","cp_disconnect","button_configuration","ethernet","firmware_update","meters","nfc","evse_gp_output","meter","meter_all_values","meter_phases"]
[warp-http] TRACE 2026/01/03 14:54:57 GET http://172.20.10.60/power_manager/state
[warp-http] TRACE 2026/01/03 14:54:57 {"config_error_flags":0,"external_control":0}
[warp-http] TRACE 2026/01/03 14:54:57 PUT http://172.20.10.50/evse/phase_auto_switch
[warp-http] TRACE 2026/01/03 14:54:57 {"enabled":false}
[warp-http] INFO 2026/01/03 14:54:57 disabling phase auto switch skipped: EOF
[warp-http] TRACE 2026/01/03 14:55:01 GET http://172.20.10.50/meter/values
[warp-http] TRACE 2026/01/03 14:55:01 {"power":2.832569361,"energy_rel":7784.958984,"energy_abs":7784.958984}
[warp-http] TRACE 2026/01/03 14:55:03 GET http://172.20.10.50/evse/external_current
Das hier ist die Antwort des WEMs auf den Endpunkt:
curl http://172.20.10.60/power_manager/state
{"config_error_flags":0,"external_control":0}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EOF bei phase_auto_switch ist expected, weil die WARP2 das nicht unterstützt (glaube ich), deswegen auch nur ein INFO log und kein Fehler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aber nicht wenn ich einen WEM konfiguriert habe. Dann sollte kein EOF kommen, weil die WARP2 damit ja auch Phaseumschaltung kann.
Aber ja, ist korrekt, die WARP2 kann nur mit WEM Phasenumschaltung.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auf der offiziellen Dokumentationsseite der API existiert der Auto Switch Endpunkt nur für WARP3: https://docs.warp-charger.com/docs/interfaces/mqtt_http/api_reference/evse/?hardwareType=warp3#evse_phase_auto_switch_warp3
Wenn man rechts WARP1/2 auswählt, dann fehlt dieser. Da ich selbst eine WARP2 habe, kann ich bestätigen, dass der Endpunkt nicht existiert.
Das heißt nicht, dass die WARP2 keine Phasenumschaltung kann, sondern bedeutet nur, dass sie das nicht selbst automatisch macht und man ein Verhalten wie hier #14403 hat.
Die API wird ja nicht tausendfach pro Sekunde gepollt, insofern ist das denke ich kein Problem. HTTP mit JSON kann schon einiges ab, da kommt man mit evcc nicht so schnell an Grenzen. Andere Clients können ja weiterhin MQTT nutzen. Sollte sich Gegenteiliges herausstellen, kann man das deprecated ja wieder rückgängig machen. Aber besser ist glaube ich schon perspektivisch nur eine API zu pflegen. |
| } | ||
|
|
||
| // phases1p3p implements the api.PhaseSwitcher interface | ||
| func (wb *WarpHTTP) phases1p3p(phases int) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gleiches Problem wie https://github.com/evcc-io/evcc/pull/26334/files#r2658941559 :
Der WEM gibt hier nichts zurück. Schalte ich auf "Schnell" wird zwar mit 3p geladen, aber nur mit 6 A weil evcc davon ausgeht, dass der Phasenwechsel fehlschlug.
Bei Bedarf kann ich die Trace Logs auch noch zur Verfügung stellen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Danke, ist tatsächlich ein anderes Problem. Auf der Startseite der API Doku schreiben sie, dass MQTT und HTTP dieselbe API haben und dann ist es doch nicht so :D. Jedenfalls heißt der Endpunkt bei HTTP wohl einfach nur external_control.
Danke fürs Testen!
|
Ich nutze ein WARP2 mit WEM der die Phaseumschaltung macht.
Ich wollte das nur anmerken, da ich persönlich lieber weiter den Broker nutzen wollen würde. Ist aber nicht konstruktiv begründet, sondern nur Geschmackssache. |
Die WARP Charger von Tinkerforge implementieren inzwischen alle eine HTTP API. Dieser PR implementiert diese API analog zur MQTT API. Die MQTT API wird weiter unterstützt, ist aber als deprecated markiert. Zukünftige Nutzer können die Wallbox jetzt einfacher konfigurieren, es ist nur die Angabe einer IP/eines Hostnamens erforderlich.
Damit wird der MQTT Broker für mich dann auch endlich überflüssig und kann abgeschaltet werden.
Außerdem:
- devcontainer baute nicht, deswegen moby deaktiviert#26335