Skip to content

Read the Peblar meter history - #181439

Open
syphernl wants to merge 2 commits into
home-assistant:devfrom
syphernl:peblar-meter-history
Open

Read the Peblar meter history#181439
syphernl wants to merge 2 commits into
home-assistant:devfrom
syphernl:peblar-meter-history

Conversation

@syphernl

@syphernl syphernl commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

Peblar chargers with a certified meter keep their own session log, separate from
the energy sensors. Each record holds the meter reading at both ends of a
session, the token the session was authorized with, and the charger's own
verdict on whether the record still matches its checksum.

That log is what you need to bill someone: a neighbour who charges at your
charger on their own RFID token, or a company car whose employer reimburses per
session. The energy sensors cannot answer that, because they do not know who was
charging.

peblar==2.0.0 already reads the log through meter_history(). This adds the
service that hands it to the user:

action: peblar.get_meter_history
data:
  config_entry_id: 01JQ7EXAMPLE
  after: "2026-01-01 00:00:00"
  before: "2026-02-01 00:00:00"

Both bounds are optional, and the charger returns everything it kept when
neither is given. A moment typed without an offset is read in Home Assistant's
timezone and converted before the call, because the charger otherwise reads it
in its own.

Every session comes back with its start and end, the meter reading at each end in
kWh, the difference between them, the token, and the charger's own verdict on
whether the record still matches its checksum. The session that is still running
has no end yet, so it reports null for its end time and its energy.

The service asks nothing of the hardware. A charger without an RFID reader still
has a meter, and that meter still logs every session.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI balanced review requested due to automatic review settings September 6, 2026 10:26
@syphernl
syphernl requested a review from frenck as a code owner September 6, 2026 10:26
@home-assistant

home-assistant Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Hey there @frenck, mind taking a look at this pull request as it has been labeled with an integration (peblar) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of peblar can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign peblar Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The required PR template text must be restored before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an admin-only Peblar action for retrieving certified meter session history with optional UTC-normalized time bounds.

Changes:

  • Registers peblar.get_meter_history and formats session responses.
  • Adds action metadata, translations, and icon.
  • Adds fixtures and tests for responses, errors, hardware independence, and time zones.
File summaries
File Description
homeassistant/components/peblar/services.py Implements and registers the action.
homeassistant/components/peblar/services.yaml Defines action fields and selectors.
homeassistant/components/peblar/strings.json Adds translated action metadata.
homeassistant/components/peblar/icons.json Adds the history action icon.
tests/components/peblar/conftest.py Configures mocked meter history.
tests/components/peblar/fixtures/meter_history.json Provides representative session data.
tests/components/peblar/test_services.py Tests action behavior and failures.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread homeassistant/components/peblar/services.py Outdated
selector:
text:

get_meter_history:
Copilot AI review requested due to automatic review settings September 6, 2026 10:31
@syphernl
syphernl force-pushed the peblar-meter-history branch from b6f28eb to 3bea1ba Compare September 6, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A shortened checksum-status list can currently cause an IndexError while formatting the response.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread homeassistant/components/peblar/services.py Outdated
Comment thread homeassistant/components/peblar/services.py Outdated
Copilot AI review requested due to automatic review settings September 6, 2026 10:36
@syphernl
syphernl force-pushed the peblar-meter-history branch from 3bea1ba to 8ce02dd Compare September 6, 2026 10:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches the upstream API, handles incomplete checksum results, and has focused test coverage.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 7, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches the upstream API and includes focused coverage for its key behaviors.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants