Repository navigation
Feature/simpleapi chargepoint limit - #4278
ChristophCaina wants to merge 3 commits into
Conversation
Die simpleAPI liefert bisher nicht, warum openWB die Ladeleistung eines
Ladepunkts gerade begrenzt (openWB/chargepoint/<id>/control_parameter/limit).
Damit kann ein HTTP-Client z.B. nicht erkennen, ob der Ladepunkt nach
§14a EnWG gedimmt wird (Dimmen per EMS, Dimmen per Direktsteuerung,
RSE-Kontakt) oder durch Lastmanagement/Zählerabsicherung begrenzt ist.
- neuer Parameter get_chargepoint_limit
- get_chargepoint_all enthält zusätzlich das Feld "limit"
Antwort (Werte wie im MQTT-Topic, beide null ohne Begrenzung):
{"chargepoint_1": {"limit": {"message": ", da die Dimmung die
Ladeleistung begrenzt.", "limiting_value": "..."}}}
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bisher kann die simpleAPI nur die Ausgaenge eines IO-Geraets lesen
(get_io_output_all). Die Eingaenge, z.B. die Kontakte des Dimm & Control
Kits, sind nur per MQTT verfuegbar.
Neuer Parameter get_io_input_all=<ID|auto>, analog zu get_io_output_all:
{"io_0": {"digital_input": {"DI1": true, ...},
"analog_input": {"AI1": 4.98, ...}}}
Nur lesend; die Auswertung der Eingaenge erfolgt weiterhin in openWB
ueber die IO-Aktionen.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAPIExpose the new chargepoint-limit parameter, include
Add
ImplementationDiscover input-only IO devices for automatic ID selection by scanning input topics while leaving the existing output-device scan unchanged.
Route automatic IO-input discovery to its auxiliary scan type rather than the standard IO scan.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="simpleAPI/src/ParameterHandler.php" line_range="1498" />
<code_context>
+ $topic = "openWB/chargepoint/{$id}/control_parameter/limit";
+ $value = $this->mqttClient->getValue($topic);
+ return ["chargepoint_{$id}" => ['limit' => $this->parseLimitValue($value)]];
+ } catch (Exception $e) {
+ return ["chargepoint_{$id}" => ['limit' => $this->parseLimitValue(null)]];
+ }
</code_context>
<issue_to_address>
**Missing MQTT topics abort reads**
When an input or chargepoint limit MQTT topic has no data, `getValue()` throws global `\Exception`, but these catches resolve `Exception` inside the `SimpleAPI` namespace, so the exception escapes instead of producing null limit values or empty input maps. Chargepoint reads can then fall back to ID 0, while IO reads omit their result.
Catch `\Exception` (or import the global `Exception` class) in these helpers.
Also at `simpleAPI/src/ParameterHandler.php:2833-2834`.
</issue_to_address>
### Comment 2
<location path="simpleAPI/src/ParameterHandler.php" line_range="2833-2834" />
<code_context>
+ */
+ private function getIoInputAll($id)
+ {
+ $digital = $this->getIoOutputMap($id, 'digital_input');
+ $analog = $this->getIoOutputMap($id, 'analog_input');
+
+ return [
</code_context>
<issue_to_address>
**Auto lookup misses input-only devices**
When an IO device publishes inputs but has no discoverable digital-output topic and the caller uses `get_io_input_all=auto`, `handleReadRequest()` calls `getLowestId('io')`, whose scan only finds `digital_output` topics, so the input-only device is skipped and the caller receives no input readings.
Update `getLowestId('io')` to discover devices from input topics as well as digital-output topics.
Also at `simpleAPI/simpleapi.php:337`.
</issue_to_address>
### Comment 3
<location path="simpleAPI/simpleapi.php" line_range="257" />
<code_context>
'get_chargepoint_pv_charging_min_current',
'get_chargepoint_soc',
'get_chargepoint_state_str',
+ 'get_chargepoint_limit',
'get_chargepoint_fault_str',
'get_chargepoint_fault_state',
</code_context>
<issue_to_address>
**Raw limit response is invalid**
When a caller requests `get_chargepoint_limit` with `raw=true`, `isComplexParameter()` does not classify `get_chargepoint_limit` as complex, so the request reaches `formatRawOutput()` and prints `Array` instead of returning the limit data or a raw-mode error.
Classify `get_chargepoint_limit` as a complex parameter so raw requests are rejected.
</issue_to_address>| $topic = "openWB/chargepoint/{$id}/control_parameter/limit"; | ||
| $value = $this->mqttClient->getValue($topic); | ||
| return ["chargepoint_{$id}" => ['limit' => $this->parseLimitValue($value)]]; | ||
| } catch (Exception $e) { |
There was a problem hiding this comment.
🟡 Medium · Missing MQTT topics abort reads
When an input or chargepoint limit MQTT topic has no data, getValue() throws global \Exception, but these catches resolve Exception inside the SimpleAPI namespace, so the exception escapes instead of producing null limit values or empty input maps. Chargepoint reads can then fall back to ID 0, while IO reads omit their result.
Catch \Exception (or import the global Exception class) in these helpers.
Also at simpleAPI/src/ParameterHandler.php:2833-2834.
Prompt for AI agents
In `simpleAPI/src/ParameterHandler.php` at line 1498:
**Missing MQTT topics abort reads**
When an input or chargepoint limit MQTT topic has no data, `getValue()` throws global `\Exception`, but these catches resolve `Exception` inside the `SimpleAPI` namespace, so the exception escapes instead of producing null limit values or empty input maps. Chargepoint reads can then fall back to ID 0, while IO reads omit their result.
Catch `\Exception` (or import the global `Exception` class) in these helpers.
Also at `simpleAPI/src/ParameterHandler.php:2833-2834`.- get_io_input_all=auto: openWB publiziert get/digital_output nur fuer IO-Geraete mit Ausgaengen, reine Eingabe-Geraete wurden von der Auto-ID daher nicht gefunden. Eigene Suche ueber die Eingangs-Topics (digital_input/analog_input, ohne *_prev). Die bestehende Suche fuer Ausgaenge und die Typen in list_components bleiben unveraendert. - get_chargepoint_limit liefert ein Objekt und wird daher wie get_chargepoint_all als komplexer Parameter behandelt: raw=true wird mit einer Fehlermeldung abgelehnt statt "Array" auszugeben. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2f14114 to
e73a023
Compare
Zwei Informationen sind bisher nur per MQTT verfügbar und fehlen in der simpleAPI. Ein reiner HTTP-Client kann daher z. B. nicht erkennen, ob ein Ladepunkt nach §14a EnWG gedimmt wird, und die Kontakte eines IO-Geräts (z. B. Dimm & Control Kit) nicht auslesen.
1. Grund der Leistungsbegrenzung eines Ladepunkts
openWB/chargepoint/<id>/control_parameter/limitgibt an, warum openWB die Ladeleistung gerade begrenzt: Dimmen per EMS, Dimmen per Direktsteuerung, RSE-Kontakt, Lastmanagement, Zählerabsicherung usw.get_chargepoint_limitget_chargepoint_allenthält zusätzlich das FeldlimitDie Werte werden unverändert aus dem MQTT-Topic übernommen; ohne Begrenzung sind beide
null.2. IO-Eingänge lesen
Neuer Parameter
get_io_input_all=<ID|auto>, aufgebaut wie das vorhandeneget_io_output_all. Er liefert die digitalen und analogen Eingänge ausopenWB/io/states/<id>/get/digital_inputund.../analog_input. Nur lesend; die Auswertung der Eingänge erfolgt weiterhin in openWB über die IO-Aktionen.Getestet
Der Code wurde von einem KI-Agenten (Claude Code) erstellt und geprüft.
Die folgenden Tests liefen in der Arbeitsumgebung des Agenten, nicht auf einer echten openWB:
php -lfür beide DateiengetChargepointLimit(),getChargepointAll()undgetIoInputAll()mit einem Fake-MQTT-Client: Begrenzung aktiv,null-Werte, Topic bzw. IO-Gerät nicht vorhandenget_io_output_allliefert unverändert dasselbe ErgebnisEin Test auf echter Hardware steht noch aus.
Hintergrund
Anbindung des Dimm & Control Kits in der Home-Assistant-Integration openwb2mqtt für Ladepunkte und IO-Geräte, die per simpleAPI eingebunden sind.
Summary by Sourcery
Extend the simpleAPI with chargepoint limitation status and IO input readings for HTTP-based integrations.
New Features:
Enhancements: