Fix shift state in Teslemetry (#139505)

* Fix shift state

* Different fix
pull/139859/head
Brett Adams 2025-02-28 23:26:39 +10:00 committed by Bram Kragten
parent fdb4c0a81f
commit 342e04974d
1 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@ from datetime import datetime, timedelta
from propcache.api import cached_property
from teslemetry_stream import Signal
from teslemetry_stream.const import ShiftState
from homeassistant.components.sensor import (
RestoreSensor,
@ -69,7 +70,7 @@ class TeslemetryVehicleSensorEntityDescription(SensorEntityDescription):
polling_value_fn: Callable[[StateType], StateType] = lambda x: x
polling_available_fn: Callable[[StateType], bool] = lambda x: x is not None
streaming_key: Signal | None = None
streaming_value_fn: Callable[[StateType], StateType] = lambda x: x
streaming_value_fn: Callable[[str | int | float], StateType] = lambda x: x
streaming_firmware: str = "2024.26"
@ -212,7 +213,7 @@ VEHICLE_DESCRIPTIONS: tuple[TeslemetryVehicleSensorEntityDescription, ...] = (
polling_available_fn=lambda x: True,
polling_value_fn=lambda x: SHIFT_STATES.get(str(x), "p"),
streaming_key=Signal.GEAR,
streaming_value_fn=lambda x: SHIFT_STATES.get(str(x)),
streaming_value_fn=lambda x: str(ShiftState.get(x, "P")).lower(),
options=list(SHIFT_STATES.values()),
device_class=SensorDeviceClass.ENUM,
entity_registry_enabled_default=False,