Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts how ChargeTemplate instances are instantiated and how MQTT topic metadata is attached, aiming to “fix cp metadata” for chargepoint charge templates.
Changes:
- Removed static
metadata={"topic": ...}fromChargeTemplate.dataand introduced factory helpers to create templates with/without topic metadata. - Updated multiple call sites (runtime + tests) to use the new factory helpers instead of
ChargeTemplate(). - Updated chargepoint data wiring and removed the explicit publish in
Chargepoint.update_charge_template().
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/helpermodules/subdata.py | Uses new factory helpers when creating charge templates from subscribed topics. |
| packages/control/ev/ev.py | Initializes Ev.charge_template via the “without metadata” factory. |
| packages/control/ev/charge_template_test.py | Updates tests to construct templates via the new factory. |
| packages/control/ev/charge_template.py | Removes static field metadata and adds new instantiate helper functions. |
| packages/control/counter_test.py | Updates tests to use the new factory. |
| packages/control/chargepoint/chargepoint_data.py | Switches Set.charge_template default factory to metadata-aware instantiation. |
| packages/control/chargepoint/chargepoint.py | Removes explicit MQTT publish from update_charge_template(). |
| packages/control/auto_phase_switch_test.py | Updates tests to use the new factory. |
| packages/control/algorithm/additional_current_test.py | Updates tests to use the new factory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| def instantiate_charge_template_with_metadata() -> ChargeTemplate: | ||
| template = ChargeTemplate() | ||
| template.__dataclass_fields__['data'].metadata = {"topic": "set/charge_template"} | ||
| return template |
| class Set: | ||
| charge_template: ChargeTemplate = field(default_factory=charge_template_factory, | ||
| metadata={"topic": "set/charge_template"}) | ||
| charge_template: ChargeTemplate = field(default_factory=instantiate_charge_template_with_metadata) |
|
|
||
| def update_charge_template(self, charge_template: ChargeTemplate) -> None: | ||
| # Prüfen, ob ein temporäres Ladeprofil aktiv ist und dieses übernehmen | ||
| self.data.set.charge_template = charge_template |
This reverts commit e723f19.
There was a problem hiding this comment.
Pull request overview
This PR fixes the MQTT topic metadata wiring for chargepoint charge template updates so that the published payload on .../set/charge_template matches the expected ChargeTemplateData shape.
Changes:
- Move the
topic: set/charge_templatemetadata toChargeTemplate.data(the actual payload object). - Remove the
topicmetadata fromChargepointData.Set.charge_templateto allow recursive publishing to the nesteddatafield.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/control/ev/charge_template.py |
Sets ChargeTemplate.data metadata topic to set/charge_template so the published payload is ChargeTemplateData. |
packages/control/chargepoint/chargepoint_data.py |
Removes topic metadata from Set.charge_template to avoid publishing a wrapped { "data": ... } payload and enable nested publishing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
No description provided.