From dac45802f4fe23bbbf108c8382b17de9613d3480 Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Sat, 21 Nov 2026 21:27:20 +0200 Subject: [PATCH] Keep webOS TV volume set when the TV speaker is active (#193694) Co-authored-by: Claude Fable 5.2 --- .../components/webostv/media_player.py | 10 ++++--- tests/components/webostv/test_media_player.py | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/webostv/media_player.py b/homeassistant/components/webostv/media_player.py index 077fcb25ec46..98d31d919aaf 100644 --- a/homeassistant/components/webostv/media_player.py +++ b/homeassistant/components/webostv/media_player.py @@ -125,9 +125,13 @@ class LgWebOSMediaPlayerEntity(WebOsTvEntity, RestoreEntity, MediaPlayerEntity): elif tv_state.sound_output != "lineout": supported = supported | SUPPORT_WEBOSTV_VOLUME volume_status = tv_state.volume_status - # webOS 22+ reports volumeSyncable, webOS 4.x supportvolume, - # webOS 5/6 neither, so keep volume set when unknown - if volume_status.get( + # 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 + # neither, so keep volume set when unknown + if volume_status.get("soundOutput", "").startswith( + "tv_" + ) or volume_status.get( "volumeSyncable", volume_status.get("supportvolume", True) ): supported = supported | MediaPlayerEntityFeature.VOLUME_SET diff --git a/tests/components/webostv/test_media_player.py b/tests/components/webostv/test_media_player.py index 0f156fae0840..80065cac14a7 100644 --- a/tests/components/webostv/test_media_player.py +++ b/tests/components/webostv/test_media_player.py @@ -845,6 +845,21 @@ WEBOS_23_TV_SPEAKER_SYNCABLE = { "volumeSyncable": True, "adjustVolume": True, } +WEBOS_24_TV_AND_OPTICAL_NOT_SYNCABLE = { + "volumeLimitable": True, + "activeStatus": True, + "maxVolume": 100, + "ossActivate": False, + "volumeLimiter": "none", + "soundOutput": "tv_external_speaker", + "volume": 1, + "dedicatedSpeakerConnected": False, + "mode": "normal", + "externalDeviceControl": False, + "muteStatus": False, + "volumeSyncable": False, + "adjustVolume": True, +} WEBOS_4_ARC_NO_SUPPORT_VOLUME = { "returnValue": True, "volumeMax": 100, @@ -904,6 +919,18 @@ SUPPORT_WEBOSTV_VOLUME_SET = ( SUPPORT_WEBOSTV_VOLUME_SET, id="webos_23_tv_speaker", ), + pytest.param( + "tv_external_speaker", + WEBOS_24_TV_AND_OPTICAL_NOT_SYNCABLE, + SUPPORT_WEBOSTV_VOLUME_SET, + id="webos_24_tv_and_optical_not_syncable", + ), + pytest.param( + "tv_speaker", + WEBOS_24_ARC_NOT_SYNCABLE, + SUPPORT_WEBOSTV | SUPPORT_WEBOSTV_VOLUME, + id="webos_22_not_syncable_stale_sound_output", + ), pytest.param( "external_arc", WEBOS_4_ARC_NO_SUPPORT_VOLUME,