Session status event without `sessionEnergy` kills the websocket reader (MissingField in PeblarSessionMeterData)

オープン
#473 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Start by reading PeblarSessionMeterData and PeblarSessionStatus.from_dict() in the package, then trace the session status callback and _read_messages error handling mentioned in the traceback. Check the existing tests for session status payloads and add coverage for the shown payload without sessionEnergy and for malformed messages. Done when the status parses and a bad payload does not terminate the websocket reader.

索引モデルが issue の本文から書いたものです。

説明

What happens

With no car connected, the charger's session status event carries a meter_data object without sessionEnergy. PeblarSessionMeterData declares session_energy as a required int, so PeblarSessionStatus.from_dict() raises and the websocket reader task dies. The charger sends the current status right after subscribing, so this happens on every connect while no car is plugged in.

Payload received (energy counter rounded):

{'instantaneousPower': [0, 0, 0], 'totalEnergy': 1700000}
Traceback
mashumaro.exceptions.MissingField: Field "session_energy" of type int is missing in PeblarSessionMeterData instance

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/peblar/websocket.py", line 41, in async_run
    await self._async_listen()
  File "/usr/local/lib/python3.14/site-packages/peblar/websocket.py", line 209, in disconnect
    await self._reader
  File "/usr/local/lib/python3.14/site-packages/peblar/websocket.py", line 267, in _read_messages
    self._handle_message(payload)
  File "/usr/local/lib/python3.14/site-packages/peblar/websocket.py", line 323, in _handle_message
    callback(data)
  File "/usr/local/lib/python3.14/site-packages/peblar/websocket.py", line 129, in <lambda>
    lambda data: callback(PeblarSessionStatus.from_dict(data)),
mashumaro.exceptions.InvalidFieldValue: Field "meter_data" of type Optional[PeblarSessionMeterData] in PeblarSessionStatus has invalid value {'instantaneousPower': [0, 0, 0], 'totalEnergy': 1700000}
Effect in Home Assistant

The exception is a mashumaro error, not a PeblarError, so the retry loop in the integration's PeblarSessionListener.async_run does not catch it. The listener task ends with "Task exception was never retrieved" (once per start) and is not restarted until the entry is reloaded. Polling continues, so entities keep updating; only the early refresh on a session change is lost.

Expected

A session status without sessionEnergy parses (field optional, or defaulting to 0), and a payload that fails to parse does not end the reader. The comment in _read_messages already states that intent for unparsable JSON.

Versions
  • peblar 2.1.0
  • Home Assistant Core 2026.11.2
  • Charger firmware 1.10.0+1+WL-1, customization Peblar-1.16
  • State at the time: no EV connected
主要言語
Python
スター
12
フォーク
10
PR マージ指標
30日以内にマージされた PR はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

frenck/python-peblar のほかの issue

frenck/python-peblar の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。