Skip to content

Indicate protocol for devices #15293

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

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Conversation

premultiply
Copy link
Member

@premultiply premultiply commented Aug 7, 2024

  • 🔌 add protocol field to templates to distinguish different implementations for the same product (e.g. localapi & ocpp)
  • 🌟 presets in defaults.yaml now can have requirements and protocol

TODOs

  • verify evcc configure works correctly
  • config ui: generalize naming adjustment @naltatis
  • decide multiple-protocol support @andig

@premultiply premultiply added the devices Specific device support label Aug 7, 2024
@naltatis
Copy link
Member

naltatis commented Aug 9, 2024

Wo wir hier gerade beim Namensaufräumen sind. Wie unterscheiden sich denn die beiden Victron-Implementierungen?

Bildschirmfoto 2024-08-09 um 21 05 41

Ist das eine die "Charging Station NS" und wenn ja welche? Oder sind das auch zwei unterschiedliche Implementierungen für das gleiche Gerät?

Bildschirmfoto 2024-08-09 um 21 07 13

\cc @philipptrenz @andig

@naltatis
Copy link
Member

Das Victron Thema hat sich erledigt: 260c13e

@premultiply premultiply mentioned this pull request Aug 12, 2024
1 task
@andig
Copy link
Member

andig commented Aug 12, 2024

Mir ist nicht so richtig klar, was wir hier erreichen wollen. Insbesondere: warum sollten wir zwei Implementierungen für eine Box anbieten? Auch bei diesem PR wäre es schön, ihn in kleinere Portionen zu zerteilen. Z.b. sind requirements von presets auch alleine nützlich.

@premultiply
Copy link
Member Author

premultiply commented Aug 13, 2024

Hier kommen eine Ladung neue OCPP-Templates rein.
Gleichtzeitig die erforderlichen Umbauten um dies in UI, configure und Doku entsprechend schön aufzubereiten - auch wenn es stellenweise mehrere Wege gibt eine Box anzusprechen.

@andig
Copy link
Member

andig commented Aug 13, 2024

auch wenn es stellenweise mehrere Wege gibt eine Box anzusprechen.

Das sollten wir nach Möglichkeit nicht tun. Lasst uns gerne diskutieren wo das absolut notwendig ist.

@premultiply
Copy link
Member Author

premultiply commented Aug 13, 2024

Das wäre wenn überhaupt nur ein Sonderfall für Boxen die über mehrere Wege angesprochen werden können und dabei verschiedene Features haben (z.B. Keba und Sungrow). Steht hier nicht im Fokus.

Hier geht vor allem mal darum einheitlich anzeigen, suchen, sortieren und filtern zu können welche Box mit welcher Schnittstelle angesprochen/konfiguriert werden muss.

@philipptrenz
Copy link
Contributor

Wo wir hier gerade beim Namensaufräumen sind. Wie unterscheiden sich denn die beiden Victron-Implementierungen?

Sorry für die späte Rückmeldung, bin gerade im Urlaub. Aber ja, so hätte ich es auch gelöst 👍🏼
Der Hinweis auf das notwendige Sponsorship muss noch entfernt werden, richtig?

@github-actions github-actions bot added the stale Outdated and ready to close label Aug 28, 2024
@github-actions github-actions bot closed this Sep 2, 2024
@naltatis naltatis mentioned this pull request Jan 21, 2025
@andig
Copy link
Member

andig commented Mar 7, 2025

Sollen wir hier fertig machen oder schließen? Ich nehme mal tentatively das backlog raus.

@andig andig removed the backlog Things to do later label Mar 7, 2025
@premultiply premultiply self-assigned this Mar 10, 2025
@premultiply premultiply added the backlog Things to do later label Mar 10, 2025
@premultiply premultiply marked this pull request as ready for review April 13, 2025 16:28
@premultiply premultiply assigned naltatis and andig and unassigned premultiply Apr 13, 2025
@naltatis
Copy link
Member

naltatis commented Apr 15, 2025

Protokoll wird nun im Dropdown angezeigt, wenn sonst nicht eindeutig.

Bildschirmfoto 2025-04-15 um 06 51 34

@andig Wir haben mit dem "SG Ready" bei den WPs gerade ein ähnliches durcheinander (zumindest in der Darstellung). Hier ists aber weniger das technische Protokoll sondern eher der Betriebsmodus der die SG-Ready von den nicht SG-Ready-Geräten unterscheidet, richtig? Hier könnten wir auch noch mal über eine strukturiertere Erfassung (Flag/Attribut) nachdenken und die dann in Doku/Config UI Anzeigen sofern für den Endnutzer relevant. (out of scope für dieses Ticket)

@naltatis naltatis added the needs documentation Triggers issue creation in evcc-io/docs label Apr 15, 2025
@andig
Copy link
Member

andig commented May 1, 2025

Was fehlt hier noch? Mir ist ehrlich gesagt nicht klar, wofür es "protocol" braucht und in welchen Fällen es hinzu gefügt wird oder eben nicht. Das ist eine gültige Auswahl für "protocol"?

@andig andig marked this pull request as draft May 1, 2025 11:03
@premultiply
Copy link
Member Author

Um bei Chargern die über mehrere Protokolle implementiert wurden (z. B. auf Grund von von unterschiedlichen Funktionalitäten der Protokolle) dem Nutzer einen Indikator zu geben was er da genau konfiguriert (hat) bzw. einrichten muss.

@premultiply premultiply marked this pull request as ready for review May 4, 2025 21:01
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @premultiply - I've reviewed your changes - here's some feedback:

  • Splitting every product model into its own entry increases YAML verbosity; consider if grouping closely related models might offer a better trade-off.
  • Review the template file naming convention for consistency, particularly regarding the use of protocol prefixes like ocpp-.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -124,7 +128,26 @@ func (t *Template) ResolvePresets() error {
return fmt.Errorf("could not find preset definition: %s", p.Preset)
}
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring the inline preset merging logic into smaller helper functions to improve readability and reduce nesting.

The inline preset merging logic now handles several responsibilities at once. Consider breaking out the logic into small helper functions to reduce nesting and increase clarity. For example:

func mergePreset(t *Template, base PresetDefinition) error {
	// Merge params
	t.Params = append(t.Params, base.Params...)
	applyProtocol(t, base)
	applyDescription(t, base)
	appendRequirements(t, base)
	return nil
}

func applyProtocol(t *Template, base PresetDefinition) {
	if t.Protocol == "" && base.Protocol != "" {
		t.Protocol = base.Protocol
	}
}

func applyDescription(t *Template, base PresetDefinition) {
	if t.Requirements.Description.DE == "" &&
		t.Requirements.Description.EN == "" &&
		t.Requirements.Description.Generic == "" {
		t.Requirements.Description = base.Requirements.Description
	}
}

func appendRequirements(t *Template, base PresetDefinition) {
	for _, r := range base.Requirements.EVCC {
		if !slices.Contains(t.Requirements.EVCC, r) {
			t.Requirements.EVCC = append(t.Requirements.EVCC, r)
		}
	}
}

Then update your loop in ResolvePresets() to simply call:

if p.Preset != "" {
	base, ok := ConfigDefaults.Presets[p.Preset]
	if !ok {
		return fmt.Errorf("could not find preset definition: %s", p.Preset)
	}
	if err := mergePreset(t, base); err != nil {
		return err
	}
	continue
}

This refactor reduces inline complexity while keeping functionality intact.

@premultiply premultiply changed the title OCPP: new templates Indicate protocol for devices May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Things to do later devices Specific device support enhancement New feature or request needs documentation Triggers issue creation in evcc-io/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants