mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Batch send commands in SamsungTV (#67847)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
e199be6391
commit
36049ac514
@ -422,8 +422,7 @@ class SamsungTVWSBridge(SamsungTVBridge):
|
|||||||
for _ in range(retry_count + 1):
|
for _ in range(retry_count + 1):
|
||||||
try:
|
try:
|
||||||
if remote := await self._async_get_remote():
|
if remote := await self._async_get_remote():
|
||||||
for command in commands:
|
await remote.send_command(commands)
|
||||||
await remote.send_command(command)
|
|
||||||
break
|
break
|
||||||
except (
|
except (
|
||||||
BrokenPipeError,
|
BrokenPipeError,
|
||||||
|
@ -641,9 +641,10 @@ async def test_turn_off_websocket(
|
|||||||
)
|
)
|
||||||
# key called
|
# key called
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_command.call_count == 1
|
||||||
command = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_command.call_args_list[0].args[0]
|
||||||
assert isinstance(command, SendRemoteKey)
|
assert len(commands) == 1
|
||||||
assert command.params["DataOfCmd"] == "KEY_POWER"
|
assert isinstance(commands[0], SendRemoteKey)
|
||||||
|
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
|
||||||
|
|
||||||
# commands not sent : power off in progress
|
# commands not sent : power off in progress
|
||||||
remotews.send_command.reset_mock()
|
remotews.send_command.reset_mock()
|
||||||
@ -678,18 +679,17 @@ async def test_turn_off_websocket_frame(
|
|||||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
# key called
|
# key called
|
||||||
assert remotews.send_command.call_count == 3
|
assert remotews.send_command.call_count == 1
|
||||||
command = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_command.call_args_list[0].args[0]
|
||||||
assert isinstance(command, SendRemoteKey)
|
assert len(commands) == 3
|
||||||
assert command.params["Cmd"] == "Press"
|
assert isinstance(commands[0], SendRemoteKey)
|
||||||
assert command.params["DataOfCmd"] == "KEY_POWER"
|
assert commands[0].params["Cmd"] == "Press"
|
||||||
command = remotews.send_command.call_args_list[1].args[0]
|
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
|
||||||
assert isinstance(command, SamsungTVSleepCommand)
|
assert isinstance(commands[1], SamsungTVSleepCommand)
|
||||||
assert command.delay == 3
|
assert commands[1].delay == 3
|
||||||
command = remotews.send_command.call_args_list[2].args[0]
|
assert isinstance(commands[2], SendRemoteKey)
|
||||||
assert isinstance(command, SendRemoteKey)
|
assert commands[2].params["Cmd"] == "Release"
|
||||||
assert command.params["Cmd"] == "Release"
|
assert commands[2].params["DataOfCmd"] == "KEY_POWER"
|
||||||
assert command.params["DataOfCmd"] == "KEY_POWER"
|
|
||||||
|
|
||||||
|
|
||||||
async def test_turn_off_legacy(hass: HomeAssistant, remote: Mock) -> None:
|
async def test_turn_off_legacy(hass: HomeAssistant, remote: Mock) -> None:
|
||||||
@ -1023,9 +1023,10 @@ async def test_play_media_app(hass: HomeAssistant, remotews: Mock) -> None:
|
|||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_command.call_count == 1
|
||||||
command = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_command.call_args_list[0].args[0]
|
||||||
assert isinstance(command, ChannelEmitCommand)
|
assert len(commands) == 1
|
||||||
assert command.params["data"]["appId"] == "3201608010191"
|
assert isinstance(commands[0], ChannelEmitCommand)
|
||||||
|
assert commands[0].params["data"]["appId"] == "3201608010191"
|
||||||
|
|
||||||
|
|
||||||
async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
|
async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
|
||||||
@ -1040,6 +1041,7 @@ async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
|
|||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
assert remotews.send_command.call_count == 1
|
assert remotews.send_command.call_count == 1
|
||||||
command = remotews.send_command.call_args_list[0].args[0]
|
commands = remotews.send_command.call_args_list[0].args[0]
|
||||||
assert isinstance(command, ChannelEmitCommand)
|
assert len(commands) == 1
|
||||||
assert command.params["data"]["appId"] == "3201608010191"
|
assert isinstance(commands[0], ChannelEmitCommand)
|
||||||
|
assert commands[0].params["data"]["appId"] == "3201608010191"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user