Skip to content

fix cp metadata#3209

Merged
LKuemmel merged 3 commits intomasterfrom
feature_fix_cp_metadata
Mar 17, 2026
Merged

fix cp metadata#3209
LKuemmel merged 3 commits intomasterfrom
feature_fix_cp_metadata

Conversation

@LKuemmel
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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": ...} from ChargeTemplate.data and 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.

Comment on lines +698 to +701
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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_template metadata to ChargeTemplate.data (the actual payload object).
  • Remove the topic metadata from ChargepointData.Set.charge_template to allow recursive publishing to the nested data field.

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.

@LKuemmel LKuemmel merged commit a9f2ade into master Mar 17, 2026
5 checks passed
@LKuemmel LKuemmel deleted the feature_fix_cp_metadata branch March 17, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants