Skip to content

Conversation

@maust
Copy link
Contributor

@maust maust commented Nov 3, 2025

ignore invalid total kWh - cfos returns 0.0

see #12886 (reply in thread)

Copy link
Contributor

@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 there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `charger/cfos.go:170-171` </location>
<code_context>
-
-	return float64(binary.BigEndian.Uint64(b)) / 1e3, nil
+	result := float64(binary.BigEndian.Uint64(b)) / 1e3
+	if result == 0.0 {
+		return 0, errors.New("cfos returned 0")
+	}
+	return result, nil
</code_context>

<issue_to_address>
**issue (bug_risk):** Returning an error for zero energy may mask legitimate zero readings.

Zero energy readings can occur legitimately, such as after initialization. Consider handling zero values without treating them as errors to prevent misclassification.
</issue_to_address>

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.

charger/cfos.go Outdated
Comment on lines 170 to 171
if result == 0.0 {
return 0, errors.New("cfos returned 0")
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Returning an error for zero energy may mask legitimate zero readings.

Zero energy readings can occur legitimately, such as after initialization. Consider handling zero values without treating them as errors to prevent misclassification.

@mfuchs1984
Copy link
Collaborator

A more robust approach might be to store previous read values in the CfosPowerBrain structure and return the stored value in case it reports 0. Only storing values that are not 0 then makes sure it never reports 0 except on completely new cfos chargers.

@maust
Copy link
Contributor Author

maust commented Nov 3, 2025

A more robust approach might be to store previous read values in the CfosPowerBrain structure and return the stored value in case it reports 0. Only storing values that are not 0 then makes sure it never reports 0 except on completely new cfos chargers.

caching now the previous value

@andig andig marked this pull request as draft November 3, 2025 15:08
@andig andig added the devices Specific device support label Nov 3, 2025
@maust
Copy link
Contributor Author

maust commented Nov 3, 2025

Änderungen übernommen. Danke.

@andig ist ein Hinweis in https://github.com/evcc-io/docs/blob/main/docs/devices/chargers.mdx bzgl. der Instabilität der Wallbox bei 1p3p Umschaltungen die zu den regelmäßigen Neustarts gewünscht?

@andig andig marked this pull request as ready for review November 4, 2025 07:21
@andig andig enabled auto-merge (squash) November 4, 2025 07:21
Copy link
Contributor

@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 there - I've reviewed your changes and they look great!


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.

@andig andig merged commit d630fbb into evcc-io:master Nov 4, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants