mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Fix LG webOS TV turn off when device is already off (#137675)
This commit is contained in:
parent
6d6961ae6e
commit
239f2dcb3e
@ -125,7 +125,7 @@ def cmd[_R, **_P](
|
|||||||
self: LgWebOSMediaPlayerEntity, *args: _P.args, **kwargs: _P.kwargs
|
self: LgWebOSMediaPlayerEntity, *args: _P.args, **kwargs: _P.kwargs
|
||||||
) -> _R:
|
) -> _R:
|
||||||
"""Wrap all command methods."""
|
"""Wrap all command methods."""
|
||||||
if self.state is MediaPlayerState.OFF:
|
if self.state is MediaPlayerState.OFF and func.__name__ != "async_turn_off":
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
translation_key="device_off",
|
translation_key="device_off",
|
||||||
|
@ -553,6 +553,17 @@ async def test_control_error_handling(
|
|||||||
assert client.play.call_count == int(is_on)
|
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:
|
async def test_supported_features(hass: HomeAssistant, client) -> None:
|
||||||
"""Test test supported features."""
|
"""Test test supported features."""
|
||||||
client.sound_output = "lineout"
|
client.sound_output = "lineout"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user