Skip to content

Sonnenbatterie: multipe consumption counters#3506

Merged
LKuemmel merged 6 commits into
openWB:masterfrom
ndrsnhs:sonnenbatterie-multipe-consumption-counters
Jun 10, 2026
Merged

Sonnenbatterie: multipe consumption counters#3506
LKuemmel merged 6 commits into
openWB:masterfrom
ndrsnhs:sonnenbatterie-multipe-consumption-counters

Conversation

@ndrsnhs

@ndrsnhs ndrsnhs commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

openWB/openwb-ui-settings#990

Ticket #66003974
Aktuell lesen wir immer den ersten Verbrauchs-Zähler der Sonnenbatterie aus.
Es gibt Systeme bei denen mehrere Zähler installiert sind. Dort besteht der Wunsch weitere Zähler einbinden zu können.
Die Unterscheidung erfolgt über die ID des Zählers.

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.

Pull request overview

This PR extends the Sonnenbatterie Verbrauchs-Zähler component so installations with multiple consumption meters can select which meter to read by an identifier (configured via counter_id).

Changes:

  • Added counter_id to the consumption counter component configuration and wiring (config.py, device.py, counter_consumption.py).
  • Extended the JSON API consumption-counter read path to accept a counter_id selector (api.py).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/modules/devices/sonnen/sonnenbatterie/device.py Passes configured counter_id into the consumption counter component creation.
packages/modules/devices/sonnen/sonnenbatterie/counter_consumption.py Reads counter_id during initialization and forwards it to the API call.
packages/modules/devices/sonnen/sonnenbatterie/config.py Adds counter_id to the consumption counter configuration object (default 0).
packages/modules/devices/sonnen/sonnenbatterie/api.py Adds counter_id parameter to update_consumption_counter and uses it to pick a consumption meter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 420 to +421
counter_state = self.__state_from_channel(
self.__read_power_meter(direction=self.PowerMeterDirection.CONSUMPTION)[0])
self.__read_power_meter(direction=self.PowerMeterDirection.CONSUMPTION)[counter_id])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

channel ist bei der Testanlage für alle Zähler gleich, kann also nicht zur Unterscheidung herangezogen werden.
Aktuelle Strategie ist nach allen consumption countern zu filtern und dann stumpf die Liste durchzugehen.
Vorher wurde schlicht der erste ausgewertet.

Comment on lines 31 to +35
self.__device_id: int = self.kwargs['device_id']
self.__device_address: str = self.kwargs['device_address']
self.__device_variant: int = self.kwargs['device_variant']
self.__api_v2_token: Optional[str] = self.kwargs['device_api_v2_token']
self.counter_id: int = self.kwargs['counter_id']

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.

bitte noch in Z. 23 ergänzen.

@ndrsnhs ndrsnhs requested a review from LKuemmel June 9, 2026 10:27
Comment on lines 31 to +35
self.__device_id: int = self.kwargs['device_id']
self.__device_address: str = self.kwargs['device_address']
self.__device_variant: int = self.kwargs['device_variant']
self.__api_v2_token: Optional[str] = self.kwargs['device_api_v2_token']
self.counter_id: int = self.kwargs['counter_id']

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.

bitte noch in Z. 23 ergänzen.

@LKuemmel LKuemmel added this to the 2.3.0 milestone Jun 10, 2026
@LKuemmel LKuemmel merged commit 44388e0 into openWB:master Jun 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants