Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["setuptools>=77.0"]

[project]
name = "teslemetry_stream"
version = "0.11.0"
version = "0.11.1"
license = "Apache-2.0"
description = "Teslemetry Streaming API library for Python"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion teslemetry_stream/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def upper_options(self) -> list[str]:

# Unused
BuckleStatus = TeslemetryEnum(
"BuckleStatus", ["Unknown", "Unlatched", "Latched", "Faulted"]
"BuckleStatus", ["Unknown", "Unlatched", "Latched", "Faulted", "SNA"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recognize the wire's BuckleStatusFault value

When PassengerSeatBelt reports its fault state, the protobuf wire value is BuckleStatusFault, but this options list contains Faulted. The newly used BuckleStatus.get() therefore strips the prefix to Fault, fails the membership check, and invokes the callback with None, conflating a real buckle fault with an unrecognized or absent value; use Fault here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rejecting this suggestion: the wire value is BuckleStatusFaulted, not BuckleStatusFault. Verified against three independent authoritative sources: Tesla's upstream fleet-telemetry proto (protos/vehicle_data.proto:417), our tesla-protocol mirror (proto/telemetry/vehicle_data.proto:424), and api's schema (src/schema/fields.ts:2085) — all three define the enum member as BuckleStatusFaulted. Applying this change would break the fault case that currently works correctly. Keeping Faulted as-is.

)

CarType = TeslemetryEnum(
Expand Down
21 changes: 16 additions & 5 deletions teslemetry_stream/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from .const import (
BMSState,
BuckleStatus,
CabinOverheatProtectionModeState,
CableType,
CarType,
Expand Down Expand Up @@ -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}},
)

Expand Down Expand Up @@ -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}},
)

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading