8000 Add meter plugin by andig · Pull Request #21477 · evcc-io/evcc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add meter plugin #21477

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

Merged
merged 5 commits into from
May 29, 2025
Merged

Add meter plugin #21477

merged 5 commits into from
May 29, 2025

Conversation

andig
Copy link
Member
@andig andig commented May 27, 2025

Fix #21467

Configure similarly to charger plugin, but specify measurement:

source: meter
config:
- ...
method: power # power/energy/soc

More methods can be added if required, even setters are possible.

@andig andig added the enhancement New feature or request label May 27, 2025
@andig andig marked this pull request as draft May 27, 2025 11:53
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 @andig - I've reviewed your changes - here's some feedback:

  • plugin/meter.go calls registry.AddCtx but never imports a registry package—add the correct import or fully qualify the registry reference.
  • In plugin/meter.go the imported meter/config package and the local variable both named meter can be confusing—consider a distinct alias (e.g. metercfg) to avoid shadowing.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 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.

@naltatis naltatis added the needs documentation Triggers issue creation in evcc-io/docs label May 28, 2025
@andig andig marked this pull request as ready for review May 29, 2025 07:44
@andig andig merged commit 02d3a36 into master May 29, 2025
6 checks passed
@andig andig deleted the feat/meter-plugin branch May 29, 2025 07:47
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 @andig - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.


var _ FloatGetter = (*meterPlugin)(nil)

func (o *meterPlugin) FloatGetter() (func() (float64, error), error) {
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): Type assertions in FloatGetter may panic if interface is not implemented.

The default case (Power) does not verify if o.meter implements api.MeterPower, which could cause a runtime panic. Use the 'ok' idiom for type assertions or ensure all cases are safely handled.

@VolkerK62
Copy link
Contributor

@andig
Bin mir nicht sicher, wie das dann vollständig aussieht.
Ist es so richtig?

- name: battery
  type: custom
  power:
    source: meter
    config:
    - type: template
      template: shelly
      host: 192.168.178.88
    method: power  
soc:
    source: mqtt
    topic: Haus/Bat_SoC
    timeout: 60m
  capacity: 7.5

@andig
Copy link
Member Author
andig commented May 29, 2025

Bis uf die Einrückung deines soc, ja

@VolkerK62
Copy link
Contributor

Nach einigen Versuchen hab ich es hinbekommen. Ohne - in "config"

Bei method ist noch ein Bug drin
cannot parse 'Method' as int: strconv.ParseInt: parsing "power": invalid syntax
Wenn ich eine Zahl eintrage oder es ganz weglasse, funktioniert es

- name: source_test1
  type: custom
  power:
    source: meter
    config:
      type: template
      template: shelly-1pm
      host: 192.168.178.21
      channel: 1
    method: 1

@andig
Copy link
Member Author
andig commented May 30, 2025

Ups- im master behoben.

@VolkerK62
Copy link
Contributor

passt, jetzt tut´s. Danke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

new plugin: meter
3 participants
0