Read the Peblar meter history - #181439
Conversation
|
Hey there @frenck, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
🟡 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_historyand 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.
| selector: | ||
| text: | ||
|
|
||
| get_meter_history: |
b6f28eb to
3bea1ba
Compare
There was a problem hiding this comment.
🟡 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
3bea1ba to
8ce02dd
Compare
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.0already reads the log throughmeter_history(). This adds theservice that hands it to the user:
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
nullfor 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
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: