From ead88978117f12cf3e99271fc21ecd0f5cd786fb Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Sat, 22 Aug 2026 11:55:49 +1000 Subject: [PATCH 1/2] fix: decode PassengerSeatBelt as BuckleStatus enum, not a bool make_bool's string handling only ever recognizes the literal "true", so wrapping the BuckleStatus-valued PassengerSeatBelt signal in make_bool silently turned every real state (Unlatched/Latched/ Faulted/SNA) into a permanent false. Decode it via BuckleStatus.get, matching the lookup-map pattern already used by listen_DetailedChargeState. This is a breaking change: the callback type changes from bool to str. Also corrected both seat belt docstrings against live telemetry: PassengerSeatBelt reports the 2nd row centre belt, not the front passenger; DriverSeatBelt is true only when the driver seat is occupied and its belt is undone (the safety-warning condition), not raw belt state. Removed the stale "# BuckleStatus?" comment, which sat on the driver listener (a plain bool) instead of the passenger one. Swept the rest of vehicle.py's make_bool call sites for other enum-valued fields wrapped this way; none of the other Signal names match a defined TeslemetryEnum, so this appears to be the only instance of the defect. Bumped to 0.12.0 (minor, matching this project's pre-1.0 convention for breaking changes - see the prefer_typed removal in 0.11.0) and regenerated uv.lock. --- pyproject.toml | 2 +- teslemetry_stream/const.py | 2 +- teslemetry_stream/vehicle.py | 21 ++++++++++++++++----- uv.lock | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a29fcc6..a12eef8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["setuptools>=77.0"] [project] name = "teslemetry_stream" -version = "0.11.0" +version = "0.12.0" license = "Apache-2.0" description = "Teslemetry Streaming API library for Python" readme = "README.md" diff --git a/teslemetry_stream/const.py b/teslemetry_stream/const.py index 1fa300a..2a01dd2 100644 --- a/teslemetry_stream/const.py +++ b/teslemetry_stream/const.py @@ -597,7 +597,7 @@ def upper_options(self) -> list[str]: # Unused BuckleStatus = TeslemetryEnum( - "BuckleStatus", ["Unknown", "Unlatched", "Latched", "Faulted"] + "BuckleStatus", ["Unknown", "Unlatched", "Latched", "Faulted", "SNA"] ) CarType = TeslemetryEnum( diff --git a/teslemetry_stream/vehicle.py b/teslemetry_stream/vehicle.py index 5daf84e..70c7949 100644 --- a/teslemetry_stream/vehicle.py +++ b/teslemetry_stream/vehicle.py @@ -12,6 +12,7 @@ from .const import ( BMSState, + BuckleStatus, CabinOverheatProtectionModeState, CableType, CarType, @@ -1301,10 +1302,14 @@ def listen_DriveRail( def listen_DriverSeatBelt( self, callback: Callable[[bool | None], None] ) -> Callable[[], None]: - """Listen for Driver Seat Belt.""" + """Listen for Driver Seat Belt. + + True only when the driver seat is occupied and its belt is undone - + this is the safety-warning condition, not raw belt state. + """ self._enable_field(Signal.DRIVER_SEAT_BELT) return self.stream.async_add_listener( - make_bool(Signal.DRIVER_SEAT_BELT, callback), # BuckleStatus? + make_bool(Signal.DRIVER_SEAT_BELT, callback), {"vin": self.vin, "data": {Signal.DRIVER_SEAT_BELT: None}}, ) @@ -1946,12 +1951,18 @@ def listen_PairedPhoneKeyAndKeyFobQty( ) def listen_PassengerSeatBelt( - self, callback: Callable[[bool | None], None] + self, callback: Callable[[str | None], None] ) -> Callable[[], None]: - """Listen for Passenger Seat Belt.""" + """Listen for Passenger Seat Belt. + + Despite the name, this reports the 2nd row centre belt, not the + front passenger belt. + """ self._enable_field(Signal.PASSENGER_SEAT_BELT) return self.stream.async_add_listener( - make_bool(Signal.PASSENGER_SEAT_BELT, callback), + lambda x: callback( + BuckleStatus.get(x["data"][Signal.PASSENGER_SEAT_BELT]) + ), {"vin": self.vin, "data": {Signal.PASSENGER_SEAT_BELT: None}}, ) diff --git a/uv.lock b/uv.lock index 1d72232..ded6cdd 100644 --- a/uv.lock +++ b/uv.lock @@ -612,7 +612,7 @@ wheels = [ [[package]] name = "teslemetry-stream" -version = "0.11.0" +version = "0.12.0" source = { editable = "." } dependencies = [ { name = "aiohttp" }, From ee04f38fa416df170426e9b7b3d31a466d152995 Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Sat, 22 Aug 2026 12:00:42 +1000 Subject: [PATCH 2/2] chore: bump to 0.11.1 (patch), not 0.12.0 - bugfix to previously-broken field --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a12eef8..d3e9499 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["setuptools>=77.0"] [project] name = "teslemetry_stream" -version = "0.12.0" +version = "0.11.1" license = "Apache-2.0" description = "Teslemetry Streaming API library for Python" readme = "README.md" diff --git a/uv.lock b/uv.lock index ded6cdd..d0d73b2 100644 --- a/uv.lock +++ b/uv.lock @@ -612,7 +612,7 @@ wheels = [ [[package]] name = "teslemetry-stream" -version = "0.12.0" +version = "0.11.1" source = { editable = "." } dependencies = [ { name = "aiohttp" },