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

Eliminate temporary override of site.batterySoc with incorrect value. #18612

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

m1cm1c
Copy link
Contributor

@m1cm1c m1cm1c commented Feb 5, 2025

the value currently gets set to a vastly incorrect value. this PR eliminates the possibility of a concurrent access reading a very wrong value

@andig
Copy link
Member

andig commented Feb 5, 2025

Thank you for this change. The value has no intermediary use- does this fix any problem or just makes the code nicer (which is good anyhow)?

@m1cm1c
Copy link
Contributor Author

m1cm1c commented Feb 5, 2025

Thank you for this change. The value has no intermediary use- does this fix any problem or just makes the code nicer (which is good anyhow)?

i'm not aware of any intermediary use. i did not come across this facing a problem. it just struck me as odd that it was done that way and i thought there might be some execution happening in a different goroutine that might access it and then get a value that's way too high but did not check whether any such access actually occurs


btw the code

if totalCapacity == 0 {
	totalCapacity = float64(len(site.batteryMeters))
}

right between the code i changed struck me as odd too because i cannot see why the number of battery meters would ever be equated to battery capacity in a completely unrelated unit but i did not touch it because while i think it might be a weird approach to avoiding a division by zero and that it probably behaves weirdly if you have both capacity-reporting batteries and non-capacity-reporting batteries (very heavy bias to capacity-reporting batteries in the result), i did not feel confident that i could provide code that's better in all situations

core/site.go Outdated Show resolved Hide resolved
core/site.go Outdated Show resolved Hide resolved
@andig andig merged commit 49dcf95 into evcc-io:master Feb 5, 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