mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Hide webOS TV volume controls when the sound output has none (#193711)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b54164d72c
commit
95363d8cec
@@ -120,11 +120,14 @@ class LgWebOSMediaPlayerEntity(WebOsTvEntity, RestoreEntity, MediaPlayerEntity):
|
||||
|
||||
if tv_state.is_on or not self._supported_features:
|
||||
supported = SUPPORT_WEBOSTV
|
||||
volume_status = tv_state.volume_status
|
||||
if tv_state.sound_output == "external_speaker":
|
||||
supported = supported | SUPPORT_WEBOSTV_VOLUME
|
||||
elif tv_state.sound_output != "lineout":
|
||||
# webOS reports volume -1 when the sound output has no volume control
|
||||
elif (
|
||||
tv_state.sound_output != "lineout" and volume_status.get("volume") != -1
|
||||
):
|
||||
supported = supported | SUPPORT_WEBOSTV_VOLUME
|
||||
volume_status = tv_state.volume_status
|
||||
# The TV speaker always supports volume set, also when combined
|
||||
# with an output that does not. For other outputs webOS 22+
|
||||
# reports volumeSyncable, webOS 4.x supportvolume, webOS 5/6
|
||||
@@ -150,7 +153,7 @@ class LgWebOSMediaPlayerEntity(WebOsTvEntity, RestoreEntity, MediaPlayerEntity):
|
||||
self._attr_is_volume_muted = cast(bool, tv_state.muted)
|
||||
|
||||
self._attr_volume_level = None
|
||||
if tv_state.volume is not None:
|
||||
if tv_state.volume is not None and tv_state.volume >= 0:
|
||||
self._attr_volume_level = tv_state.volume / 100.0
|
||||
|
||||
self._attr_source = self._current_source
|
||||
|
||||
@@ -383,6 +383,13 @@ async def test_entity_attributes(
|
||||
|
||||
assert attrs.get(ATTR_MEDIA_VOLUME_LEVEL) is None
|
||||
|
||||
# Sound output without volume control reports volume -1
|
||||
client.tv_state.volume = -1
|
||||
await client.mock_state_update()
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs.get(ATTR_MEDIA_VOLUME_LEVEL) is None
|
||||
|
||||
# Channel change
|
||||
client.tv_state.current_channel = CHANNEL_2
|
||||
await client.mock_state_update()
|
||||
@@ -884,6 +891,18 @@ WEBOS_4_TV_SPEAKER_SUPPORT_VOLUME = {
|
||||
"active": False,
|
||||
"mute": False,
|
||||
}
|
||||
WEBOS_4_OPTICAL_NO_VOLUME_CONTROL = {
|
||||
"returnValue": True,
|
||||
"volumeMax": 100,
|
||||
"scenario": "mastervolume_ext_speaker_optical",
|
||||
"muted": False,
|
||||
"subscribed": True,
|
||||
"volume": -1,
|
||||
"action": "requested",
|
||||
"supportvolume": False,
|
||||
"slider": False,
|
||||
"active": False,
|
||||
}
|
||||
WEBOS_6_ARC_UNKNOWN = {
|
||||
"activeStatus": True,
|
||||
"adjustVolume": True,
|
||||
@@ -943,6 +962,12 @@ SUPPORT_WEBOSTV_VOLUME_SET = (
|
||||
SUPPORT_WEBOSTV_VOLUME_SET,
|
||||
id="webos_4_support_volume",
|
||||
),
|
||||
pytest.param(
|
||||
"external_optical",
|
||||
WEBOS_4_OPTICAL_NO_VOLUME_CONTROL,
|
||||
SUPPORT_WEBOSTV,
|
||||
id="webos_4_no_volume_control",
|
||||
),
|
||||
pytest.param(
|
||||
"external_arc",
|
||||
WEBOS_6_ARC_UNKNOWN,
|
||||
|
||||
Reference in New Issue
Block a user