Fix Tessie volume max and step (#145835)

* Use fixed volume max and step

* Update snapshot
This commit is contained in:
Brett Adams 2025-05-29 11:58:29 +10:00 committed by GitHub
parent b80195df81
commit 881ce45afa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -20,6 +20,10 @@ STATES = {
"Stopped": MediaPlayerState.IDLE, "Stopped": MediaPlayerState.IDLE,
} }
# Tesla uses 31 steps, in 0.333 increments up to 10.333
VOLUME_STEP = 1 / 31
VOLUME_FACTOR = 31 / 3 # 10.333
PARALLEL_UPDATES = 0 PARALLEL_UPDATES = 0
@ -38,6 +42,7 @@ class TessieMediaEntity(TessieEntity, MediaPlayerEntity):
"""Vehicle Location Media Class.""" """Vehicle Location Media Class."""
_attr_device_class = MediaPlayerDeviceClass.SPEAKER _attr_device_class = MediaPlayerDeviceClass.SPEAKER
_attr_volume_step = VOLUME_STEP
def __init__( def __init__(
self, self,
@ -57,9 +62,7 @@ class TessieMediaEntity(TessieEntity, MediaPlayerEntity):
@property @property
def volume_level(self) -> float: def volume_level(self) -> float:
"""Volume level of the media player (0..1).""" """Volume level of the media player (0..1)."""
return self.get("vehicle_state_media_info_audio_volume", 0) / self.get( return self.get("vehicle_state_media_info_audio_volume", 0) / VOLUME_FACTOR
"vehicle_state_media_info_audio_volume_max", 10.333333
)
@property @property
def media_duration(self) -> int | None: def media_duration(self) -> int | None:

View File

@ -41,7 +41,7 @@
'device_class': 'speaker', 'device_class': 'speaker',
'friendly_name': 'Test Media player', 'friendly_name': 'Test Media player',
'supported_features': <MediaPlayerEntityFeature: 0>, 'supported_features': <MediaPlayerEntityFeature: 0>,
'volume_level': 0.22580323309042688, 'volume_level': 0.2258032258064516,
}), }),
'context': <ANY>, 'context': <ANY>,
'entity_id': 'media_player.test_media_player', 'entity_id': 'media_player.test_media_player',
@ -64,7 +64,7 @@
'media_title': 'Song', 'media_title': 'Song',
'source': 'Spotify', 'source': 'Spotify',
'supported_features': <MediaPlayerEntityFeature: 0>, 'supported_features': <MediaPlayerEntityFeature: 0>,
'volume_level': 0.22580323309042688, 'volume_level': 0.2258032258064516,
}), }),
'context': <ANY>, 'context': <ANY>,
'entity_id': 'media_player.test_media_player', 'entity_id': 'media_player.test_media_player',