Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1361 +/- ##
=======================================
Coverage 99.88% 99.88%
=======================================
Files 6 6
Lines 898 907 +9
Branches 126 128 +2
=======================================
+ Hits 897 906 +9
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…rsion for passkey, username, and password.
|
There was a problem hiding this comment.
Pull request overview
This PR enhances python-bsblan’s parameter parsing so that BSB-LAN values returned as STRING but containing an embedded unit (e.g., "7968 kWh") are normalized into structured EntityInfo data (numeric value + populated unit). It also exposes a new sensor field for total energy and adds an example utility script for debugging raw parameter responses.
Changes:
- Extend
EntityInfo.convert_raw_valueto extract numeric values + known units fromSTRINGvalues when theunitfield is empty. - Add sensor parameter mapping + model field for
total_energy(parameter3113). - Add/extend tests and fixtures to cover embedded-unit parsing and sensor energy handling; introduce a new
fetch_param.pyexample script.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/bsblan/models.py |
Adds embedded-unit parsing logic in EntityInfo and introduces Sensor.total_energy. |
src/bsblan/constants.py |
Maps parameter 3113 to the new total_energy sensor attribute. |
tests/test_entity_info.py |
Adds unit-parsing tests for integer/float cases and non-parsing scenarios. |
tests/test_sensor.py |
Extends sensor test assertions to validate total_energy when present. |
tests/fixtures/sensor.json |
Adds fixture data for parameter 3113 with value "7968 kWh". |
examples/fetch_param.py |
New example script to fetch arbitrary parameter IDs and print the raw API response. |



This pull request adds support for parsing and handling BSB-LAN parameters whose values are strings containing both a number and a unit (e.g., "7968 kWh"). The code now automatically extracts the numeric value and unit for known units when the
unitfield is empty, improving the accuracy and usability of sensor data. It also introduces a new example script for fetching parameters and updates tests to cover the new parsing logic.Enhanced parameter parsing and model updates:
convert_raw_valuemethod inEntityInfonow detects string values with embedded units (like "7968 kWh") when theunitfield is empty. It extracts the numeric value and sets the correct unit for known units, ensuring downstream code receives structured data.Sensormodel adds a newtotal_energyfield (EntityInfo[int] | None), and parameter 3113 (total_energy) is now mapped inBASE_SENSOR_PARAMS. [1] [2]Testing improvements:
total_energyis correctly parsed and available when present in the response.Developer tooling:
fetch_param.pyfor fetching one or more BSB-LAN parameters and printing the raw API response, to help with debugging and development.Internal code quality:
refor regex matching).