Prioritätensteuerung für Fahrzeuge - #3312
Conversation
9ac373b to
110c159
Compare
42ad4be to
a5a8ff5
Compare
8adeb02 to
9139e0f
Compare
a86fb17 to
a8dc062
Compare
a2d2839 to
3a6e222
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated no new comments.
Suppressed comments (3)
packages/control/counter_all/hierarchy.py:335
- In
_add_missing_entrieswird in der Warnmeldungelement['id']verwendet, obwohl hier ein fehlender Eintrag ausdata_structureergänzt wird. In diesem Codepfad istelemententweder der zuletzt iterierte Hierarchie-Eintrag (falsche ID) oder bei leerer Hierarchie sogar nicht definiert (UnboundLocalError). Stattdessen sollte die neu hinzugefügte ID (entry_num) verwendet werden.
pub_system_message({}, f"{component_type_to_readable_text(type_name)} mit ID {element['id']} wurde"
packages/control/counter_all/counter_all_data.py:104
LoadmanagementPrioProtocol._remove_loadmanagement_prio_itemist typisiert als(entry: Dict) -> None, die Implementierung inLoadmanagementPrioMixinarbeitet aber mitList[Dict]und liefert einboolzurück. Das bricht Typprüfungen und erschwert die Weiterentwicklung (z.B. bei mypy/pyright).
def _remove_loadmanagement_prio_item(self, id: int, entry: Dict) -> None: ...
packages/control/counter_all/loadmanagement_prio.py:69
sort_cps_by_loadmanagement_prios_nestedgibt aktuell nur Ladepunkte zurück, deren EV-ID inloadmanagement_priosvorkommt. Wenn die Liste leer/unvollständig ist (z.B. beim ersten Start oder nach inkonsistenten Daten), werden verbleibende Chargepoints komplett ignoriert – die aufrufenden Algorithmen setzen dann für diese CPs keinen Strom mehr. Besser: alle nicht durch Prioritäten abgedeckten CPs am Ende als Fallback-Gruppe (in preferenced Reihenfolge) anhängen.
sorted_cps = []
for entry in self.data.get.loadmanagement_prios:
9909442 to
e454e3b
Compare
6f13dad to
75dd39f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Suppressed comments (4)
packages/helpermodules/command.py:798
- As in the add path, removing from
data.data.counter_all_dataoperates on a replaceable algorithm snapshot. If it lags the retained MQTT state, removal can either raiseIndexErrorfor an existing vehicle or publish a stale list that discards recent priority changes. UseSubData.counter_all_data, matching the command module's hierarchy mutations.
data.data.counter_all_data.remove_loadmanagement_prio_item(payload["data"]["id"])
Pub().pub("openWB/set/counter/get/loadmanagement_prios",
data.data.counter_all_data.data.get.loadmanagement_prios)
packages/helpermodules/command.py:780
- This mutates the algorithm's periodically copied snapshot, rather than the MQTT-backed source of truth.
Data.__copy_counter_datareplaces this object fromSubData.counter_all_data(control/data.py:350-351), and other command-side hierarchy updates useSubData; therefore an add concurrent with a newer priority edit can republish an older ordering and lose that edit. Update and publishSubData.counter_all_datainstead.
This issue also appears on line 796 of the same file.
data.data.counter_all_data.add_loadmanagement_prio_item("vehicle", new_id)
Pub().pub("openWB/set/counter/get/loadmanagement_prios",
data.data.counter_all_data.data.get.loadmanagement_prios)
packages/helpermodules/update_config.py:3536
- The migration has no
(ECO_CHARGING, False)bucket. Every vehicle using Eco charging with the legacy priority flag disabled therefore fails all tuple comparisons and is omitted fromloadmanagement_prios; the new control loops then never allocate current to its chargepoint. Include the missing bucket and cover it in the migration test.
(Chargemode.ECO_CHARGING.value, True),
packages/helpermodules/setdata.py:939
- Using
Noneaccepts every payload, including malformed JSON thatdecode_payloadreturns as a string and lists with missing, duplicate, or malformed vehicle entries. This retained value is consumed directly by the new control loops, where invalid entries raise and missing vehicles are silently skipped. Validate the recursive priority schema and require each configured vehicle exactly once before publishing it.
elif ("openWB/set/counter/get/hierarchy" in msg.topic or
"openWB/set/counter/get/loadmanagement_prios" in msg.topic):
self._validate_value(msg, None)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 60 out of 60 changed files in this pull request and generated 2 comments.
Suppressed comments (4)
packages/helpermodules/command.py:799
- Vehicle removal also edits the algorithm snapshot instead of the authoritative
SubDatastate. A stale snapshot can fail to find the vehicle after its broker topics have already been deleted, or publish an old ordering over a recent UI change. Remove and publish throughSubData.counter_all_data, as the hierarchy commands do.
packages/helpermodules/command.py:781 - This mutates the algorithm's periodically copied
datasnapshot rather than the MQTT-backedSubData.counter_all_dataused by the other command handlers. Before the next copy—or after a recent UI reorder—adding a vehicle can publish a stale list and discard priorities; it also races with algorithm iteration. Update and publish the authoritativeSubDataobject instead.
This issue also appears on line 797 of the same file.
packages/control/counter_all/counter_all_data.py:104
- The protocol declaration disagrees with the mixin implementation: the argument is a list of entries and the method returns
bool. Because the mixin typesselfas this protocol, static analysis sees the line-17is Falsecheck as comparing aNonereturn and cannot verify the implementation contract.
def _remove_loadmanagement_prio_item(self, id: int, entry: Dict) -> None: ...
packages/control/ev/charge_template.py:112
- This field is still operational, not obsolete:
chargepoint.py:236copies it into the control parameters andalgorithm/filter_chargepoints.py:33partitions every algorithm pass by it. Consequently, the new priority list cannot reorder vehicles across the oldpriobuckets. Either complete the algorithm migration away from this flag or document that it remains a higher-level priority.
| elif ("openWB/set/counter/get/hierarchy" in msg.topic or | ||
| "openWB/set/counter/get/loadmanagement_prios" in msg.topic): | ||
| self._validate_value(msg, None) |
08f116c to
982119a
Compare
953304f to
3eaa221
Compare
3eaa221 to
92d9f60
Compare
92d9f60 to
f855518
Compare
ddfaf21 to
19f235d
Compare
19f235d to
ce4465c
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* draft * improve style * improve update config
ce4465c to
da38f18
Compare
UI openWB/openwb-ui-settings#1050