# Buggy code
async def turn_on(self, await_new_state: bool = False) -> None:
    """Turn device on."""
    await self.protocol.send_and_receive(messages.wake_device())

    if await_new_state and self.power_state != PowerState.On:
        await self._waiters.setdefault(PowerState.On, asyncio.Event()).wait()


# Traceback (exceptions.TimeoutError)
**pyatv> wake_up
2020-08-13 13:39:01 ERROR: Unknown command: wake_up
pyatv> wakeup
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py:614: DeprecationWarning: Call to deprecated function wakeup.
value = await tmp(*args)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 648, in _run_application
return await cli_handler(loop)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 460, in cli_handler
return await _handle_commands(args, config, loop)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 558, in _handle_commands
ret = await _handle_device_command(args, cmd, atv, loop)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 580, in _handle_device_command
return await _exec_command(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 614, in _exec_command
value = await tmp(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 228, in cli
await _handle_device_command(self.args, command, self.atv, self.loop)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 585, in _handle_device_command
return await _exec_command(atv.remote_control, cmd, True, *cmd_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/scripts/atvremote.py", line 614, in _exec_command
value = await tmp(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/mrp/__init__.py", line 263, in wakeup
await self._press_key("wakeup", InputAction.SingleTap)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/mrp/__init__.py", line 154, in _press_key
await _do_press(keycode, False)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/mrp/__init__.py", line 137, in _do_press
await self.protocol.send_and_receive(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/mrp/protocol.py", line 138, in send_and_receive
return await self._receive(identifier, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyatv/mrp/protocol.py", line 146, in _receive
await asyncio.wait_for(semaphore.acquire(), timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/tasks.py", line 490, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

An error occurred, full stack trace above**

# Fixed code
async def turn_on(self, await_new_state: bool = False) -> None:
    """Turn device on."""
    await self.protocol.send(messages.wake_device())

    if await_new_state and self.power_state != PowerState.On:
        await self._waiters.setdefault(PowerState.On, asyncio.Event()).wait()