mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Fix LG webOS TV turn off when device is already off (#137675)
This commit is contained in:
parent
657e3488ba
commit
e3d649d349
@ -125,7 +125,7 @@ def cmd[_R, **_P](
|
||||
self: LgWebOSMediaPlayerEntity, *args: _P.args, **kwargs: _P.kwargs
|
||||
) -> _R:
|
||||
"""Wrap all command methods."""
|
||||
if self.state is MediaPlayerState.OFF:
|
||||
if self.state is MediaPlayerState.OFF and func.__name__ != "async_turn_off":
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="device_off",
|
||||
|
@ -553,6 +553,17 @@ async def test_control_error_handling(
|
||||
assert client.play.call_count == int(is_on)
|
||||
|
||||
|
||||
async def test_turn_off_when_device_is_off(hass: HomeAssistant, client) -> None:
|
||||
"""Test no error when turning off device that is already off."""
|
||||
await setup_webostv(hass)
|
||||
client.is_on = False
|
||||
await client.mock_state_update()
|
||||
|
||||
data = {ATTR_ENTITY_ID: ENTITY_ID}
|
||||
await hass.services.async_call(MP_DOMAIN, SERVICE_TURN_OFF, data, True)
|
||||
assert client.power_off.call_count == 1
|
||||
|
||||
|
||||
async def test_supported_features(hass: HomeAssistant, client) -> None:
|
||||
"""Test test supported features."""
|
||||
client.sound_output = "lineout"
|
||||
|
Loading…
x
Reference in New Issue
Block a user