mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Fix shift state in Teslemetry (#139505)
* Fix shift state * Different fix
This commit is contained in:
parent
228a4eb391
commit
ac15d9b3d4
@ -8,6 +8,7 @@ from datetime import datetime, timedelta
|
|||||||
|
|
||||||
from propcache.api import cached_property
|
from propcache.api import cached_property
|
||||||
from teslemetry_stream import Signal
|
from teslemetry_stream import Signal
|
||||||
|
from teslemetry_stream.const import ShiftState
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
RestoreSensor,
|
RestoreSensor,
|
||||||
@ -69,7 +70,7 @@ class TeslemetryVehicleSensorEntityDescription(SensorEntityDescription):
|
|||||||
polling_value_fn: Callable[[StateType], StateType] = lambda x: x
|
polling_value_fn: Callable[[StateType], StateType] = lambda x: x
|
||||||
polling_available_fn: Callable[[StateType], bool] = lambda x: x is not None
|
polling_available_fn: Callable[[StateType], bool] = lambda x: x is not None
|
||||||
streaming_key: Signal | None = 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"
|
streaming_firmware: str = "2024.26"
|
||||||
|
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ VEHICLE_DESCRIPTIONS: tuple[TeslemetryVehicleSensorEntityDescription, ...] = (
|
|||||||
polling_available_fn=lambda x: True,
|
polling_available_fn=lambda x: True,
|
||||||
polling_value_fn=lambda x: SHIFT_STATES.get(str(x), "p"),
|
polling_value_fn=lambda x: SHIFT_STATES.get(str(x), "p"),
|
||||||
streaming_key=Signal.GEAR,
|
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()),
|
options=list(SHIFT_STATES.values()),
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user