Skip to content
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

MaxACPower: fix decoration #19237

Merged
merged 2 commits into from
Feb 27, 2025
Merged

MaxACPower: fix decoration #19237

merged 2 commits into from
Feb 27, 2025

Conversation

mfuchs1984
Copy link
Contributor

@mfuchs1984 mfuchs1984 commented Feb 27, 2025

@andig I had a look at #18943 and #18937 and did some debugging.
After a while, I figured out, that the test for api.MaxACPower in

if m, ok := meter.(api.MaxACPower); ok {
always failed, although the interface was decorated.
After renaming the interface from MaxACPower to something not matching the api function name, in this case MaxACPowerGetter, it started to work. As a golang newbie, I am not sure exactly why.

@andig
Copy link
Member

andig commented Feb 27, 2025

Das kann nicht das Problem sein: https://play.golang.com/p/81MisrDtabG

@mfuchs1984
Copy link
Contributor Author

Ich verstehe es auch nicht, aber es ist ganz simpel nachzuvollziehen. Einfach ein Meter anlegen mit maxacpower (muss nicht in echt existieren) und einen Breakpoint in

if m, ok := meter.(api.MaxACPower); ok {
setzen und warten, bis das entsprechende Meter dran ist. Ohne die Änderung schlägt der Test bei mir reproduzierbar fehl, mit der Änderung geht's reproduzierbar.

@andig
Copy link
Member

andig commented Feb 27, 2025

However this test confirms that it's not working as expected:

func TestACPower(t *testing.T) {
	m, err := NewConfigurableFromConfig(context.TODO(), map[string]any{
		"maxacpower": 1000,
		"power": map[string]any{
			"source": "const",
			"value":  1000,
		},
	})
	require.NoError(t, err)
	_, ok := m.(api.MaxACPower)
	require.True(t, ok)
}

Let's find out why.

@andig
Copy link
Member

andig commented Feb 27, 2025

See https://groups.google.com/g/golang-nuts/c/nOrO4mDW-7U

@mfuchs1984
Copy link
Contributor Author

Habe das auch nur ausprobiert, weil das der einzige Unterschied war, den ich zu den funktionierenden Interfaces gefunden habe.

@andig
Copy link
Member

andig commented Feb 27, 2025

pls run

make assets

to fix the build

@mfuchs1984
Copy link
Contributor Author

Will do later today.

@mfuchs1984
Copy link
Contributor Author

Done

@andig andig merged commit b2fb1aa into evcc-io:master Feb 27, 2025
6 checks passed
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