Fix sonos volume always showing 0 (#48685)
parent
30382c3dbe
commit
6dc1414b69
|
@ -885,9 +885,9 @@ class SonosEntity(MediaPlayerEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def volume_level(self) -> int | None:
|
||||
def volume_level(self) -> float | None:
|
||||
"""Volume level of the media player (0..1)."""
|
||||
return self._player_volume and int(self._player_volume / 100)
|
||||
return self._player_volume and self._player_volume / 100
|
||||
|
||||
@property
|
||||
def is_volume_muted(self) -> bool | None:
|
||||
|
|
|
@ -31,6 +31,10 @@ def soco_fixture(music_library, speaker_info, dummy_soco_service):
|
|||
mock_soco.renderingControl = dummy_soco_service
|
||||
mock_soco.zoneGroupTopology = dummy_soco_service
|
||||
mock_soco.contentDirectory = dummy_soco_service
|
||||
mock_soco.mute = False
|
||||
mock_soco.night_mode = True
|
||||
mock_soco.dialog_mode = True
|
||||
mock_soco.volume = 19
|
||||
|
||||
yield mock_soco
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.sonos import DOMAIN, media_player
|
||||
from homeassistant.const import STATE_IDLE
|
||||
from homeassistant.core import Context
|
||||
from homeassistant.exceptions import Unauthorized
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
@ -59,3 +60,17 @@ async def test_device_registry(hass, config_entry, config, soco):
|
|||
assert reg_device.manufacturer == "Sonos"
|
||||
assert reg_device.suggested_area == "Zone A"
|
||||
assert reg_device.name == "Zone A"
|
||||
|
||||
|
||||
async def test_entity_basic(hass, config_entry, discover):
|
||||
"""Test basic state and attributes."""
|
||||
await setup_platform(hass, config_entry, {})
|
||||
|
||||
state = hass.states.get("media_player.zone_a")
|
||||
assert state.state == STATE_IDLE
|
||||
attributes = state.attributes
|
||||
assert attributes["friendly_name"] == "Zone A"
|
||||
assert attributes["is_volume_muted"] is False
|
||||
assert attributes["night_sound"] is True
|
||||
assert attributes["speech_enhance"] is True
|
||||
assert attributes["volume_level"] == 0.19
|
||||
|
|
Loading…
Reference in New Issue