Fix sensor entity description in Teslemetry (#115614)

Add description back to sensor entity
pull/116045/head
Brett Adams 2024-04-21 07:54:24 +10:00 committed by Franck Nijhof
parent 3d68ee99a4
commit 66918d1686
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 428 additions and 115 deletions

View File

@ -58,7 +58,7 @@ SHIFT_STATES = {"P": "p", "D": "d", "R": "r", "N": "n"}
class TeslemetrySensorEntityDescription(SensorEntityDescription):
"""Describes Teslemetry Sensor entity."""
value_fn: Callable[[StateType], StateType | datetime] = lambda x: x
value_fn: Callable[[StateType], StateType] = lambda x: x
VEHICLE_DESCRIPTIONS: tuple[TeslemetrySensorEntityDescription, ...] = (
@ -447,12 +447,13 @@ class TeslemetryVehicleSensorEntity(TeslemetryVehicleEntity, SensorEntity):
description: TeslemetrySensorEntityDescription,
) -> None:
"""Initialize the sensor."""
self.entity_description = description
super().__init__(vehicle, description.key)
@property
def native_value(self) -> StateType:
"""Return the state of the sensor."""
return self._value
return self.entity_description.value_fn(self._value)
class TeslemetryVehicleTimeSensorEntity(TeslemetryVehicleEntity, SensorEntity):

File diff suppressed because it is too large Load Diff