mirror of
https://github.com/home-assistant/core.git
synced 2026-04-25 10:45:06 +00:00
Fix Sonos set_volume float precision issue (#152493)
This commit is contained in:
@@ -305,7 +305,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
||||
@soco_error()
|
||||
def set_volume_level(self, volume: float) -> None:
|
||||
"""Set volume level, range 0..1."""
|
||||
self.soco.volume = int(volume * 100)
|
||||
self.soco.volume = int(round(volume * 100))
|
||||
|
||||
@soco_error(UPNP_ERRORS_TO_IGNORE)
|
||||
def set_shuffle(self, shuffle: bool) -> None:
|
||||
|
||||
@@ -1103,11 +1103,11 @@ async def test_volume(
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_VOLUME_SET,
|
||||
{ATTR_ENTITY_ID: "media_player.zone_a", ATTR_MEDIA_VOLUME_LEVEL: 0.30},
|
||||
{ATTR_ENTITY_ID: "media_player.zone_a", ATTR_MEDIA_VOLUME_LEVEL: 0.57},
|
||||
blocking=True,
|
||||
)
|
||||
# SoCo uses 0..100 for its range.
|
||||
assert soco.volume == 30
|
||||
assert soco.volume == 57
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user