Xiomi IR remote cannot learn commands

Whenever I call the command remote_learn_command for my xiaomi IR remote, I get the following error:

  • Transmit of IR command failed, remote_learn_command, exception: {‘code’: -5008, ‘message’: ‘magic error’}

Any previously learnt commands work just fine. What could be happening? Using version 2023.6.2.
Thanks!